| Run xtext workflow from another plugin project [message #989897] |
Sun, 09 December 2012 11:53  |
Adnan AL-SOSWA Messages: 21 Registered: May 2010 |
Junior 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 #990538 is a reply to message #990080] |
Wed, 12 December 2012 19:11   |
Adnan AL-SOSWA Messages: 21 Registered: May 2010 |
Junior 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 05:35] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
| Re: Run xtext workflow from another plugin project [message #1006320 is a reply to message #1006190] |
Wed, 30 January 2013 15:01   |
Bhanu Pratap 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 .
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 15:03] Report message to a moderator
|
|
|
|
| Re: Run xtext workflow from another plugin project [message #1006524 is a reply to message #1006325] |
Thu, 31 January 2013 10:05  |
Bhanu Pratap 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.
|
|
|
Powered by
FUDForum. Page generated in 0.05097 seconds