Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiple Xtext files and Same Ecore(Multiple Xtext and Same Ecore)
Multiple Xtext files and Same Ecore [message #1852066] Thu, 28 April 2022 10:12 Go to next message
Antonio Garmendia is currently offline Antonio GarmendiaFriend
Messages: 93
Registered: May 2014
Member
Hi,

I am trying to create several grammars for the same ecore within a project. The thing is that I think that I have problem in the generation of the Xtext Artifacts (Run the MWE2 Workflow), because I think that only one grammar is generated. So, probably I miss something in the mwe2 file. I put combined grammar= false, but it seems that is not sufficient.

Find attached a zip file with both xtext files and the mwe2 file. What am I missing? Of course, If is necessary I can upload a complete minimal example. Xtext version 2.25.

Thanks a lot.

Kind regards,
Antonio

Re: Multiple Xtext files and Same Ecore [message #1852070 is a reply to message #1852066] Thu, 28 April 2022 10:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
the grammars should have different names

can you provide the workflow log too?
what do you derive " because I think that only one grammar is generated" from?
what error do you see?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 28 April 2022 10:29]

Report message to a moderator

Re: Multiple Xtext files and Same Ecore [message #1852074 is a reply to message #1852070] Thu, 28 April 2022 11:40 Go to previous messageGo to next message
Antonio Garmendia is currently offline Antonio GarmendiaFriend
Messages: 93
Registered: May 2014
Member
Hi Christian,

Thanks for the prompt reply.

Indeed, the grammars have different names

language = StandardLanguage {
			name = "org.xtext.example.mydsl.MyDsl8"
			fileExtensions = "mydsl8"
			referencedResource = "platform:/resource/mydsl8/model/MyDSL8.genmodel"
			
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

			formatter = {
				generateStub = true
				generateXtendStub = true
			}

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
				// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
				generateDeprecationValidation = true
			}
			parserGenerator={
				combinedGrammar=false
			}
			generator = {
				generateXtendStub = true
			}
			junitSupport = {
				junitVersion = "5"
			}
						
		}
		
		language = StandardLanguage {
			name = "org.xtext.example.mydsl.MyDsl9"
			
			fileExtensions = "mydsl9"
			referencedResource = "platform:/resource/mydsl8/model/MyDSL8.genmodel"
			
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

			formatter = {
				generateStub = true
				generateXtendStub = true
			}

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
				// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
				generateDeprecationValidation = true
			}
			parserGenerator={
				combinedGrammar=false
			}
			generator = {
				generateXtendStub = true
			}
			junitSupport = {
				junitVersion = "5"
			}
			
		}


This is the log:

0    [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
4    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
104  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl8 at 'file:/D:/EclipseS/2022/1.Eclipse-DSL/workspaces/6.xtext-cross-references-semantic-predicates/org.xtext.example.mydsl8.parent/org.xtext.example.mydsl8/'
105  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl8.tests at 'file:/D:/EclipseS/2022/1.Eclipse-DSL/workspaces/6.xtext-cross-references-semantic-predicates/org.xtext.example.mydsl8.parent/org.xtext.example.mydsl8.tests/'
105  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl8.ide at 'file:/D:/EclipseS/2022/1.Eclipse-DSL/workspaces/6.xtext-cross-references-semantic-predicates/org.xtext.example.mydsl8.parent/org.xtext.example.mydsl8.ide/'
105  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl8.ui at 'file:/D:/EclipseS/2022/1.Eclipse-DSL/workspaces/6.xtext-cross-references-semantic-predicates/org.xtext.example.mydsl8.parent/org.xtext.example.mydsl8.ui/'
106  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.example.mydsl8.ui.tests at 'file:/D:/EclipseS/2022/1.Eclipse-DSL/workspaces/6.xtext-cross-references-semantic-predicates/org.xtext.example.mydsl8.parent/org.xtext.example.mydsl8.ui.tests/'
113  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
253  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
255  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
261  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
261  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
263  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://myDSL8' from 'platform:/resource/mydsl8/model/MyDSL8.genmodel'
372  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
455  [main] INFO  text.xtext.generator.XtextGenerator  - Generating org.xtext.example.mydsl.MyDsl8
1172 [main] INFO  text.xtext.generator.XtextGenerator  - Generating org.xtext.example.mydsl.MyDsl8
1632 [main] INFO  text.xtext.generator.XtextGenerator  - Generating common infrastructure
1647 [main] INFO  .emf.mwe2.runtime.workflow.Workflow  - Done.



I said this "because I think that only one grammar is generated" because in the log I only see that this grammar "Generating org.xtext.example.mydsl.MyDsl8" is generated and nothing w.r.t. Generating org.xtext.example.mydsl.MyDsl9

Kind regards,
Antonio
Re: Multiple Xtext files and Same Ecore [message #1852076 is a reply to message #1852074] Thu, 28 April 2022 11:43 Go to previous messageGo to next message
Antonio Garmendia is currently offline Antonio GarmendiaFriend
Messages: 93
Registered: May 2014
Member
Hi again,

sorry, I also get these errors.

index.php/fa/42024/0/

Thanks.

Kind regards,
Antonio
Re: Multiple Xtext files and Same Ecore [message #1852078 is a reply to message #1852076] Thu, 28 April 2022 11:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you want multiple *.xtext and a single *.ecore, it is very unlikely that there is an auto-generated *.ecore that is identical for each *.xtext. You must therefore use the manual *.ecore approach by commenting out the "generate ..." clause from your Xtext grammars. This forces/allows you to define the *.ecore yourself which should enable you to identify a single *.ecore that is a superset of the requirements of each *.xtext. I don't think you will need to change the *.mwe2 script at all, for the first *.xtext, but you will probably need to adjust the paths so that the one *.ecore is shared by its many consumers.

Note that migrating from the autogenerated *.ecore structure to the manual *.ecore structure has a few gotchas even for EMF experts. I think the Bugzilla suggesting a refactoring wizard is outstanding. You should study a working manual *.ecore example to see what is necessary. If necessary look at the OCL grammars and build scripts.

Regards

Ed Willink
Re: Multiple Xtext files and Same Ecore [message #1852082 is a reply to message #1852078] Thu, 28 April 2022 13:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
455 [main] INFO text.xtext.generator.XtextGenerator - Generating org.xtext.example.mydsl.MyDsl8
1172 [main] INFO text.xtext.generator.XtextGenerator - Generating org.xtext.example.mydsl.MyDsl8

i see

// automatically generated by Xtext
grammar org.xtext.example.mydsl.MyDsl8 with org.eclipse.xtext.common.Terminals

and

// automatically generated by Xtext
grammar org.xtext.example.mydsl.MyDsl8 with org.eclipse.xtext.common.Terminals

so name is the same


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Multiple Xtext files and Same Ecore [message #1852106 is a reply to message #1852082] Fri, 29 April 2022 11:41 Go to previous messageGo to next message
Antonio Garmendia is currently offline Antonio GarmendiaFriend
Messages: 93
Registered: May 2014
Member
Hi,

Thank you a lot! I thought that you mean the name on the mwe2 file. Sorry for this.

The thing is that I changed this, and now I see in the log the language is generated. However, the second language with file extension = mydsl9 is not working. It is very weird because when I create a file with this extension the Eclipse does not give me the option to put the "Xtext nature", so I have to put this manually. Any idea why this might be?

If you will like to take a look, please find attached a minimal example. The plugins folder has the Xtext grammar and the Ecore, and the runtime has an example project.

Thanks again!

Kind regards,
Antonio



Re: Multiple Xtext files and Same Ecore [message #1852117 is a reply to message #1852106] Fri, 29 April 2022 18:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Be very very careful about copying Xtext examples. The magic Xtext index remembers things and you can have the magic behaviour that you starting executing new/my.mwe2 which finds an internal name to look up and so can continue by executing old/my.mwe2.
I couldn't believe this once I discovered it, but it explained a lot and now I always do whatever I can to avoid the Xtext index.

Bottom line, when copying, change absolutely everything, and close and at least temporarily delete the original to ensure that it cannot be helpfully / very confusingly re-used.

Regards

Ed Willink
Re: Multiple Xtext files and Same Ecore [message #1852121 is a reply to message #1852117] Sat, 30 April 2022 05:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
it looks like you did not merge plugin.xml_gen to plugin.xml

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Multiple Xtext files and Same Ecore [message #1852124 is a reply to message #1852121] Sat, 30 April 2022 13:03 Go to previous message
Antonio Garmendia is currently offline Antonio GarmendiaFriend
Messages: 93
Registered: May 2014
Member
Hi,

Thank you both! Indeed @Cristian I did not merge the plugin.xml_gen to plugin.xml. After doing this it works perfectly.

Thanks again!

Kind regards,
Antonio
Previous Topic:NullPointerException in Xtext IDE project after removing generate model statement from grammar
Next Topic:Xtext 2.27.0.M2 is out
Goto Forum:
  


Current Time: Fri Mar 29 02:34:46 GMT 2024

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

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

Back to the top