Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext
Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #670321] Fri, 13 May 2011 14:05 Go to next message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
Hello

I created new DSL which is extension of an existing one. There is a link that I was following but I cannot send it now Razz The title of the post is Xtext 1.0.0 and UML (Xpand on top)
In my case I didn't use UML meta model but the metamodel generated by another Xtext (base) grammar. The editor is working just fine.
The new grammar looks as follows:
grammar org.xtext.example.libExt.LibExt with org.eclipse.xtext.common.Terminals

generate libExt "URI_of_new_DSL"

import "URI_of_base_DSL" as building

Model:
 	(imports+=Import)*
 	(bref+=BuildingRef)*	 
 ;
 
Import :
 'import' importURI=STRING;

BuildingRef:
	"REF" name=ID ref=[building::Building|ID];

One note here: As you can see, in the models that conform with this grammar I allow import of model created in the base DSL.

However I tried to make small template in the generator project, and there were no errors found. However, I got errors when running the workflow mwe2 file of the .generator project. I got something like :
Couldn't resolve reference to Building 'Tower'
Does anyone know something about proper configuring of mwe2 of generator project when having imported metamodel in the Xtext grammar? Some useful links or maybe tips how to do this?
Thanks in advance
Nikola.
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #670327 is a reply to message #670321] Fri, 13 May 2011 14:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

did you something like
register = org.xtext.example.mydsl.MyDslAStandaloneSetup {}
register = org.xtext.example.mydsl.MyDslBStandaloneSetup {}

in your generator projects workflow?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #670345 is a reply to message #670327] Fri, 13 May 2011 15:27 Go to previous messageGo to next message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
Hi Christian
I tried but again the same error appears. This is my workflow file:
module workflow.BdlGenerator

import org.eclipse.emf.mwe.utils.*


var targetDir = "src-gen"
var fileEncoding = "Cp1252"
var modelPath = "src/model"

Workflow {

	component = org.eclipse.xtext.mwe.Reader {
		// lookup all resources on the classpath
		//useJavaClassPath = false

		// or define search scope explicitly
		path = modelPath
		skipOnErrors = true
		
		// this class will be generated by the xtext generator
		register = org.xtext.example.mydsl.MyDslAStandaloneSetup {}
		register = org.xtext.example.mydsl.MyDslBStandaloneSetup {}

		
		load = {
			slot = "system"
			type = "BDL"
		}
	}

	component = org.eclipse.xpand2.Generator {
		metaModel = org.eclipse.xtend.typesystem.emf.EmfMetaModel {
			metaModelPackage = "org.xtext.example.mydsl.MyDslAPackage"
		}
		
		metaModel = org.eclipse.xtend.typesystem.emf.EmfMetaModel {
			metaModelPackage = "org.xtext.example.mydsl.MyDslBPackage"
		}
		
		expand = "templates::Template::main FOREACH greetings"
		
		outlet = {
			path = targetDir
		}
		fileEncoding = fileEncoding
	}
}



Also I put dependencies in MANIFEST.MF, but still the same error appears.

Nikola
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #670352 is a reply to message #670345] Fri, 13 May 2011 15:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

can you please post the complete error message?

and can you post example models?

btw

there is something wrong with your workflow Wink

you read BDL into the slot system but call the generator with greetings


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

[Updated on: Fri, 13 May 2011 15:46]

Report message to a moderator

Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #670354 is a reply to message #670345] Fri, 13 May 2011 15:50 Go to previous messageGo to next message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
Hi Christian
I solved the problem. The code that I've added is:
        bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
	 	platformUri=".."
	}

and now the workflow file looks like:
module workflow.BdlGenerator

import org.eclipse.emf.mwe.utils.*


var targetDir = "src-gen"
var fileEncoding = "Cp1252"
var modelPath = "src/model"

Workflow {

	bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
	 	platformUri=".."
	}

	component = org.eclipse.xtext.mwe.Reader {
		// lookup all resources on the classpath
		//useJavaClassPath = false

		// or define search scope explicitly
		path = modelPath
		skipOnErrors = true
		
		// this class will be generated by the xtext generator
		register = org.xtext.example.mydsl.MyDslAStandaloneSetup {}
		register = org.xtext.example.mydsl.MyDslBStandaloneSetup {}

		
		load = {
			slot = "system"
			type = "BDL"
		}
	}

	component = org.eclipse.xpand2.Generator {
		metaModel = org.eclipse.xtend.typesystem.emf.EmfMetaModel {
			metaModelPackage = "org.xtext.example.mydsl.MyDslAPackage"
		}
		
		metaModel = org.eclipse.xtend.typesystem.emf.EmfMetaModel {
			metaModelPackage = "org.xtext.example.mydsl.MyDslBPackage"
		}
		
		expand = "templates::Template::main FOREACH greetings"
		
		outlet = {
			path = targetDir
		}
		fileEncoding = fileEncoding
	}
}


Now I have problem with the generator. The error that appears is as follows
Could not find any exported element of type 'BDL' -> Slot 'system' is empty.
My question is what is a slot actually?

Nikola
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #670356 is a reply to message #670354] Fri, 13 May 2011 15:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

yes you have to add
	bean = StandaloneSetup {
		platformUri=".."
	}


if you use platform:/resource imports

a slot is just an entry in a map

load = {
			slot = "system"
			type = "BDL"
		}


stores all BDL to the map under the key system

and

templates::Template::main FOREACH greetings


call the min definition foreach of the entries of the slot greetings

and yes by default only stuff that has a name is exported/stored to the slot by this generator workflow.
(and stored to the slot)


~Christian


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

[Updated on: Fri, 13 May 2011 16:30]

Report message to a moderator

Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671042 is a reply to message #670356] Mon, 16 May 2011 15:39 Go to previous messageGo to next message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
Hi Christian
me again ... Very Happy
The problems with the generation of text with templates are resolved !
I'm creating standalone java application in which I would like to read a model and to parse it. It works OK, BUTTTT when it comes to reading the cross references, the type of the cross reference is ok, but the name (taken with getName()) of the referenced object from the imported referenced model is null.
What I do in the code is the following: I invoke setups of both the base language and the new one that uses the base language for cross references.
BaseStandaloneSetup.doSetup();
BdlStandaloneSetup.doSetup();

Any suggestions?
Nikola
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671044 is a reply to message #671042] Mon, 16 May 2011 15:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

can you give me some reproducable code?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671048 is a reply to message #671044] Mon, 16 May 2011 15:49 Go to previous messageGo to next message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
You want the java code of the script only or everything ? I can send you the java code ?? :-/
Nikola
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671051 is a reply to message #671048] Mon, 16 May 2011 15:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

no the two grammars
+ the language generator workflows
+ the generator workflow
+ 2 sample models incl folder structure

are fine Wink

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671052 is a reply to message #671051] Mon, 16 May 2011 15:56 Go to previous messageGo to next message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
Unfortunately I cannot send you Sad company secret
Maybe I have to reproduce the entire case with two dummy grammars and then ask you again...
Life it's not easy at all Very Happy
Thanks however
I'll write when I'll repeat the case.
Nikola
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671058 is a reply to message #671052] Mon, 16 May 2011 16:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

Of cource i am fine with dummy / sample dsls Wink

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671329 is a reply to message #671058] Tue, 17 May 2011 14:34 Go to previous messageGo to next message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
Hi Christian

I've reproduced the code. So, again I cannot access the referenced objects. BTW it works fine with xPand but I cannot figure out what is the problem when I want to use the parser in a standalone application.
That's why I made two grammars: libraryBuilding as a base one and libExt that is using libraryBuilding.
The standalone application is contained in the project parseLibExt.
So the output is
A
null

and it should be
A
Tower


I hope this all u need?

Thanks again
Nikola

  • Attachment: workspace.zip
    (Size: 343.68KB, Downloaded 178 times)
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671364 is a reply to message #671329] Tue, 17 May 2011 16:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you have to do the same as you do in the workflow Wink

new StandaloneSetup().setPlatformUri("..");


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Configuring mwe2 file of Xpand .generator project when having imported metamodel in Xtext [message #671535 is a reply to message #671364] Wed, 18 May 2011 08:55 Go to previous message
Nikola  is currently offline Nikola Friend
Messages: 13
Registered: May 2011
Junior Member
Thanks Christian, that solved my problem ! Very Happy
Now it will be easy to proceed with the rest of the work.
Thanks again !
Nikola
Previous Topic:White Spaces into keywords of Xtext grammar
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Apr 26 03:26:44 GMT 2024

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

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

Back to the top