Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Run xtext workflow from another plugin project
Run xtext workflow from another plugin project [message #989897] Sun, 09 December 2012 16:53 Go to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
hello all ,
I searched about how i can run xtext workflow from another plugin project but I did not find a complete explanation for the process
I have the grammar.xtext file and the workflow file (generator.mwe2) and I created a class to run the generator programmatically using this code
Injector inj = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
		Mwe2Runner runner = inj.getInstance(Mwe2Runner.class);
		runner.run("org.eclipse.xtext.example.tutorial.GenerateTutorial", new HashMap<String, String>());

this code work fine from within xtext Project , but does not from another plugin or java project .
any help or reference to website to read about


thanks in advance


adnan
Re: Run xtext workflow from another plugin project [message #990080 is a reply to message #989897] Mon, 10 December 2012 19:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what is the error you get? i guess it is a classpath thing.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Run xtext workflow from another plugin project [message #990538 is a reply to message #990080] Thu, 13 December 2012 00:11 Go to previous messageGo to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Thanks for response ,

after fixing a lot of dependencies , I could not fix this exception

although the class org/eclipse/xtext/impl/GrammarImpl is exist the exception still .

[code] while locating org.eclipse.xtext.conversion.impl.IDValueConverter
while locating org.eclipse.xtext.conversion.impl.AbstractIDValueConverter
for field at org.eclipse.xtext.common.services.DefaultTerminalConverters.idValueConverter(Unknown Source)
while locating org.eclipse.emf.mwe2.language.Mwe2ValueConverters
while locating org.eclipse.xtext.conversion.IValueConverterService
for field at org.eclipse.xtext.parsetree.reconstr.impl.ValueSerializer.converter(Unknown Source)
while locating org.eclipse.xtext.parsetree.reconstr.impl.ValueSerializer
while locating org.eclipse.xtext.parsetree.reconstr.ITokenSerializer$IValueSerializer
for field at org.eclipse.xtext.validation.impl.AssignmentQuantityAllocator.valueSerializer(Unknown Source)
while locating org.eclipse.xtext.validation.impl.AssignmentQuantityAllocator
while locating org.eclipse.xtext.validation.IAssignmentQuantityAllocator
for field at org.eclipse.xtext.validation.impl.ConcreteSyntaxValidator.quantityProvider(Unknown Source)
while locating org.eclipse.xtext.validation.impl.ConcreteSyntaxValidator
while locating org.eclipse.xtext.validation.IConcreteSyntaxValidator
for field at org.eclipse.xtext.resource.XtextResource.validator(Unknown Source)
while locating org.eclipse.xtext.linking.lazy.LazyLinkingResource
while locating org.eclipse.xtext.resource.XtextResource
Caused by: java.lang.NoClassDefFoundError: org/eclipse/xtext/impl/GrammarImpl
at org.eclipse.xtext.impl.XtextFactoryImpl.createGrammar(XtextFactoryImpl.java:100)
at org.eclipse.xtext.impl.XtextFactoryImpl.create(XtextFactoryImpl.java:63)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XMLHelperImpl.java:883)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XMLHelperImpl.java:919)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2051)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1270)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1336)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:970)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:83)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:953)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:684)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:167)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at

[Updated on: Sun, 20 January 2013 10:35]

Report message to a moderator

Re: Run xtext workflow from another plugin project [message #990695 is a reply to message #990538] Thu, 13 December 2012 06:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Missing EMF or using wrong version?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Run xtext workflow from another plugin project [message #1003133 is a reply to message #990695] Sun, 20 January 2013 10:44 Go to previous messageGo to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Hi Christian ,

I could finally run it from with one project in the same workspace . but now i have a problem to run it from a plug in project .

when i try to run it using the same code
Injector inj = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
		Mwe2Runner runner = inj.getInstance(Mwe2Runner.class);
		runner.run(path+"mygenrartor", new HashMap<String, String>());


I have a exption can not finde module mygenrartor
path is registed in the class path and the system path . is there any changes should i do for the generator component ?
Re: Run xtext workflow from another plugin project [message #1003136 is a reply to message #1003133] Sun, 20 January 2013 10:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

it should work, are you sure the classpath is ok.
what do you mean with "to run it from a plug in project"


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Run xtext workflow from another plugin project [message #1004612 is a reply to message #1003136] Wed, 23 January 2013 14:49 Go to previous messageGo to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Hi Christian,

I mean plugin project , where i wanted the work flow of xtext to be implented throw a command in context menue

we Launch this plugin as an eclipse application

In the new workbench, Right click on any file and we choose "New SubMenu -> New Action" as the new action has the coder of workflow implementation

should run the workflow successfully, but it fails with the following exception even when all the dependencies are satisfied:
"org.eclipse.core.internal.resources.ResourceException:
Resource '/org.eclipse.xtext.xbase/model/Xbase.genmodel' does not exist"

thanks
Re: Run xtext workflow from another plugin project [message #1004622 is a reply to message #1004612] Wed, 23 January 2013 14:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
As I said: an action IS NOT standalone

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Run xtext workflow from another plugin project [message #1006176 is a reply to message #1004622] Wed, 30 January 2013 11:00 Go to previous messageGo to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Hi christian ,

Thank you for your patience ,
I really read Runner and luncher but I could not undrerstand how i can find alternative for standalonesetup , I read also the blog of Jan
http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html but also still did not get the point .
we want to generate StandaloneSetup as in the workflow

Workflow {
bean = StandaloneSetup {

as we need it after that in the serialization process .

could please guide me to clear example or better explantion of the problem and how to be solved ?


thanks in advance
Re: Run xtext workflow from another plugin project [message #1006190 is a reply to message #1006176] Wed, 30 January 2013 12:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i meant something like (not tested): call Mwe2Activator.getInstance()ö.getInjector("org.eclipse.emf.mwe2.language.Mwe2")
to obtain the injector.
or not to do your approarch at all but stick together the workflow with java means and call it programmatically.
or to use no workflow at all.

~Christian



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Run xtext workflow from another plugin project [message #1006320 is a reply to message #1006190] Wed, 30 January 2013 20:01 Go to previous messageGo to next message
Bhanu Pratap is currently offline Bhanu PratapFriend
Messages: 13
Registered: April 2010
Junior Member
Hi Christian

I tried using "Mwe2Activator.getInstance()ö.getInjector("org.eclipse.emf.mwe2.language.Mwe2") but with no luck Sad.

I want to point it again that we are trying to process models in xtext whose grammar would be available dynamically(i.e. language artifacts would not be available before hand).

So, how does that work in xtext? I guess in the above case of using Mwe2Activator, language is not initialized thus we get an exception:
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Content is not allowed in prolog.
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:201)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:242)


I have already looked up entire xtext documentation, but couldn't find any help on how this can be done. Could you please suggest any?

Thanks,
Bhanu

[Updated on: Wed, 30 January 2013 20:03]

Report message to a moderator

Re: Run xtext workflow from another plugin project [message #1006325 is a reply to message #1006320] Wed, 30 January 2013 20:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the activator should do the initialization. (and it does it in a trivial example)

Injector injector = Mwe2Activator.getInstance().getInjector("org.eclipse.emf.mwe2.language.Mwe2") ;
	    Mwe2Runner instance = injector.getInstance(Mwe2Runner.class);
	    instance.run(URI.createURI("platform:/resource/testa/src/test.mwe2"), null);



but i still do not understand. do you try to read .xtext files or .mwe files?
and what is this dynamic thing? what do you exactly what to do from a top view.

but i just remembered https://bugs.eclipse.org/bugs/show_bug.cgi?id=318721
which might lead to problems anyway.

you may have a look at the class WorkflowLaunchUtils in org.eclipse.xtext.xtext.ui to cirumvent the problems.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Run xtext workflow from another plugin project [message #1006524 is a reply to message #1006325] Thu, 31 January 2013 15:05 Go to previous message
Bhanu Pratap is currently offline Bhanu PratapFriend
Messages: 13
Registered: April 2010
Junior Member
Hi Christian

Thanks for your helpful response, the problem seems to be much clear now after reading that bug report.

Here is the top view of what we are trying to do:

1. Read a model & its metamodel (.xmi, .ecore files) and generate
text files that represent the model and metamodel in a different
language : this is done using xpand
2. Generate grammar file (.xtext) for parsing these files:
again using xpand
3. Run an xtext workflow (.mwe2) for generating language artifacts
for the grammar file generated in step 2.
[4. Use the other language to analyse and transform the model
generated in step 1.]
5. Load the transformed model files using the Xtext-based environment
generated in step 3.
6. Serialize the model to create new .xmi files.

To automate all these steps, an Eclipse plugin with context menu contribution was created. The user clicks on any model (.xmi)
file to invoke the entire process for that file.

However, we keep getting errors in the (3rd) step that requires running
of the Xtext workflow to initialize a language whose's grammar had been generated based on the model selected by the user (this is the dynamic part here).

Please let us know if you have any suggestions how to avoid the reported
errors.

Thanks.
Previous Topic:Custom error message for unordered groups
Next Topic:Unit Test - type is 'null'
Goto Forum:
  


Current Time: Fri Apr 19 06:07:51 GMT 2024

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

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

Back to the top