Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext with ATL
Xtext with ATL [message #1051220] Sun, 28 April 2013 12:02 Go to next message
serhat gezgin is currently offline serhat gezginFriend
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
Re: Xtext with ATL [message #1051227 is a reply to message #1051220] Sun, 28 April 2013 12:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

it is a bad idea to call something that is called standalonesetup from eclipse.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext with ATL [message #1051230 is a reply to message #1051227] Sun, 28 April 2013 12:25 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Hi,

Is there anything you can offer me to use xtext as a ATL input ?

Regards
Re: Xtext with ATL [message #1051248 is a reply to message #1051230] Sun, 28 April 2013 13:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi you should ask this to the atl guys. xtext has everything that it should work out of the box. btw if you want to use guice
have a look at http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext with ATL [message #1051992 is a reply to message #1051248] Mon, 29 April 2013 13:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Christian

That's not quite true. Xtext has 99.9% of what's required, unfortunately
it has an inconsistent EPackage registry initialization that mandates
that applications invoke StandaloneSetup. Unfortunately
https://bugs.eclipse.org/bugs/show_bug.cgi?id=340408 was WONTFIXed so
applications such as ATL cannot use Xtext until they are enhanced to
work around the non-standard API. In many cases this is not particularly
hard since the user already has to provide some initialization to which
another line can be added; it's just an unhelpful trap for novices.

Regards

Ed Willink


On 28/04/2013 14:03, Christian Dietrich wrote:
> Hi you should ask this to the atl guys. xtext has everything that it
> should work out of the box. btw if you want to use guice
> have a look at
> http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html
Re: Xtext with ATL [message #1053171 is a reply to message #1051220] Thu, 02 May 2013 19:41 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Quote:
FilesystemStandaloneSetup dsl = new FilesystemStandaloneSetup();
Injector injector = dsl.createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);

As Christian said: never use standalone setups in Eclipse plug-ins, since they interfer with what is usually initialized through eclipse's plug-in.xml.

Instead use the injector from the generated activator class in your language's ui plug-in.
Should be something like the following in your case:

FileSystemActiviator.getInstance().getInjector(FileSystemActiviator.MY_PACKAGE_FILESYSTEM)
Quote:



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");

Is that the FilesystemEPackage you are trying to load here via file URI?
I think you should 'inject' FileSystemPackage.eINSTANCE instead.
Re: Xtext with ATL [message #1053172 is a reply to message #1051992] Thu, 02 May 2013 19:50 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Ed Willink wrote on Mon, 29 April 2013 15:34
Hi Christian

That's not quite true. Xtext has 99.9% of what's required, unfortunately
it has an inconsistent EPackage registry initialization that mandates
that applications invoke StandaloneSetup.


Inconsistent? In what way?

Quote:

Unfortunately
https://bugs.eclipse.org/bugs/show_bug.cgi?id=340408 was WONTFIXed so
applications such as ATL cannot use Xtext until they are enhanced to
work around the non-standard API.

Could you be more specific in what ATL actually does or expects that renders it
incompatible?
Previous Topic:creating abstract class in the meta model
Next Topic:default value for INT parameter
Goto Forum:
  


Current Time: Sat Apr 20 01:46:47 GMT 2024

Powered by FUDForum. Page generated in 0.04663 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top