Xtext with ATL [message #1051220] |
Sun, 28 April 2013 12:02 |
serhat gezgin Messages: 243 Registered: January 2013 Location: Izmir |
Senior Member |
|
|
Hi all,
I create atl plug-in project for invoke transformation programmaticaly. First i
create command and i invoke this command from file right click and generate button.
But i cant run transformation i always get error. When i debug i see asm variable
always null and error occurs because of this. My code and error is blow
Not : i use xtext as a input
Anyone can help me to fix this ?
Code;
public class deneme {
public static void aaa(String filepath, String outPutFilePath) throws ATLCoreException, IOException {
// Replace DSL by your Language name
FilesystemStandaloneSetup dsl = new FilesystemStandaloneSetup();
Injector injector = dsl.createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resourceSet.getResource(URI.createURI(filepath), true);
// Create factory and injector
EMFModelFactory factory = new EMFModelFactory();
EMFInjector emfinjector = new EMFInjector();
// Load the DSL metamodel
EMFReferenceModel dslMetamodel = (EMFReferenceModel) factory.newReferenceModel();
emfinjector.inject(dslMetamodel, "File://C:\\Users\\unituser\\XtextAndGmfSynchronization\\org.eclipse.m2m.atl.filesystem\\model\\Filesystem.ecore");
// Load the XtextResource as an EMFModel
EMFModel model = (EMFModel) factory.newModel(dslMetamodel);
emfinjector.inject(model, resource);
EMFReferenceModel outMetamodel = (EMFReferenceModel) factory.newReferenceModel();
emfinjector.inject(outMetamodel, "File://C:\\Users\\unituser\\XtextAndGmfSynchronization\\org.eclipse.m2m.atl.filesystem\\model\\filesystem2.ecore");
EMFModel outModel = (EMFModel) factory.newModel(outMetamodel);
EMFVMLauncher launcher = new EMFVMLauncher();
launcher.initialize(Collections.<String, Object> emptyMap());
launcher.addInModel(model, "IN", "Filesystem");
launcher.addOutModel(outModel, "OUT", "filesystem2");
InputStream asm = deneme.class.getResourceAsStream("org.eclipse.m2m.atl.filesystem/files/transformation.asm");
launcher.launch(
ILauncher.RUN_MODE,
new NullProgressMonitor(),
Collections.<String, Object> emptyMap(),
new Object[] {asm} );
outModel.getResource().setURI(URI.createURI(outPutFilePath));
outModel.getResource().save(Collections.EMPTY_MAP);
}
}
Error;
java.lang.NullPointerException
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch(EMFVMLauncher.java:139)
at org.eclipse.m2m.atl.filesystem.files.deneme.aaa(deneme.java:53)
at org.xtext.example.filesystem.generator.plugin.handler.Translate.createOutput(Translate.java:58)
at org.xtext.example.filesystem.generator.plugin.handler.Translate.execute(Translate.java:29)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:231)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:212)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:131)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:171)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:831)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:724)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:708)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:647)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Regards
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04663 seconds