Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext] Processing Xtext Model
[Xtext] Processing Xtext Model [message #666875] Sat, 23 April 2011 18:40 Go to next message
Muhammad  is currently offline Muhammad Friend
Messages: 13
Registered: March 2011
Junior Member
Hi,
I am using Xtext with eclipse 3.5.

I get following info message in console when I run Workflow file (MWE2) in DSL project. How can I configure meta models using JavaBeans as default. Secondly in which file I have to write code to "process xtext model"?

3 [main] INFO org.eclipse.xpand2.Generator - No meta models configured, using JavaBeans as default.

80 [main] INFO org.eclipse.xpand2.Generator - No meta models configured, using JavaBeans as default.

80 [main] INFO org.eclipse.xpand2.Generator - No meta models configured, using JavaBeans as default.

Thanks
Re: [Xtext] Processing Xtext Model [message #666881 is a reply to message #666875] Sat, 23 April 2011 19:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13604
Registered: July 2009
Senior Member
Hi,

the JavaBeansMetamodel message is just a warning. if you want to explicitely configure it

	component = org.eclipse.xpand2.Generator {
		metaModel = org.eclipse.xtend.type.impl.java.JavaBeansMetaModel {}
		expand = "templates::Template::main FOREACH greetings"
		outlet = {
			path = targetDir
		}
		fileEncoding = fileEncoding
	}


your second question
Quote:

Secondly in which file I have to write code to "process xtext model"?



i do not understand.

~Christian



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext] Processing Xtext Model [message #666894 is a reply to message #666881] Sat, 23 April 2011 21:18 Go to previous messageGo to next message
Muhammad  is currently offline Muhammad Friend
Messages: 13
Registered: March 2011
Junior Member
Thanks for your reply. I am very much new to DSL perticularly with Xtext and related. I was reading xtext tutorial on:
http://www.eclipse.org/Xtext/documentation/latest/xtext.html #getting-started.

And, under the heading "Processing Xtext Models" I found code e.g.

new DomainmodelStandaloneSetup().createInjectorAndDoEMFRegistrat ion();

ResourceSet rs = new ResourceSetImpl();
Resource resource = rs.getResource(URI.createURI("./mymodel.dmodel"), true);
EObject eobject = resource.getContents().get(0);

So where I should write this piece of code in Xtext project I mean in which file (Sorry for being funny in asking such thing Embarrassed )
Re: [Xtext] Processing Xtext Model [message #666895 is a reply to message #666894] Sat, 23 April 2011 21:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13604
Registered: July 2009
Senior Member
Hi,

simply create a Plain Java Class Wink e.g. in your DSLs runtime project.or somewhere else with your runtime project on classpath.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext] Processing Xtext Model [message #666896 is a reply to message #666895] Sat, 23 April 2011 21:50 Go to previous messageGo to next message
Muhammad  is currently offline Muhammad Friend
Messages: 13
Registered: March 2011
Junior Member
Thanks for the quick replies Smile
Re: [Xtext] Processing Xtext Model [message #666914 is a reply to message #666875] Sun, 24 April 2011 11:10 Go to previous messageGo to next message
Timotei D is currently offline Timotei DFriend
Messages: 89
Registered: March 2010
Member
Christian,

Is it possible to process the models from existing files? Let's say, I have a project, and I want to get the AST/Parse tree from an existing file. That piece of code uses models, but I'm not sure how to link the models with the files.

Or, besides that, it would be better to have a Xtext builder and use that to gain access to each parsed file?

Thanks.
Re: [Xtext] Processing Xtext Model [message #666916 is a reply to message #666914] Sun, 24 April 2011 11:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13604
Registered: July 2009
Senior Member
Hi,

i do not understand your distinction between models and files. could you please explain?

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext] Processing Xtext Model [message #666958 is a reply to message #666875] Mon, 25 April 2011 06:03 Go to previous messageGo to next message
Timotei D is currently offline Timotei DFriend
Messages: 89
Registered: March 2010
Member
Hi!
Well, for example, within Eclipse' framework, using the API, I can get, let's say, a file from a project:
project.getFile("myfile").

But that returns an IFile instance. How can I convert it to a model so I can use that code:

ResourceSet rs = new ResourceSetImpl();
Resource resource = rs.getResource(URI.createURI("./mymodel.dmodel"), true);
EObject eobject = resource.getContents().get(0);


Or maybe, I should have a .dmodel file somewhere for that file?

Thanks,
Timo
Re: [Xtext] Processing Xtext Model [message #666967 is a reply to message #666958] Mon, 25 April 2011 07:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13604
Registered: July 2009
Senior Member
Hi,

if the file is an instance of your dsl it should have the corresponding extension. to get an URI from an IFile see
http://wiki.eclipse.org/index.php/EMF/FAQ#How_do_I_map_betwe en_an_EMF_Resource_and_an_Eclipse_IFile.3F

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext] Processing Xtext Model [message #666968 is a reply to message #666875] Mon, 25 April 2011 07:57 Go to previous messageGo to next message
Timotei D is currently offline Timotei DFriend
Messages: 89
Registered: March 2010
Member
Thank you!

I'll look into it.
Re: [Xtext] Processing Xtext Model [message #685379 is a reply to message #666895] Fri, 17 June 2011 11:59 Go to previous messageGo to next message
Vladimir  is currently offline Vladimir Friend
Messages: 7
Registered: June 2011
Junior Member
Hi!

I am new to eclipse forum and registered here specially to ask this question, so please bear with my newby questions.

I defined the grammar of my DSL and was able to generate an editor and a code generator as showed here blog.efftinge.de/2011/06/five-simple-steps-to-fowlers-dsl-with(.html)
Now am trying to do processing on a living model (DSL runtime project). Its probably the same question:
Quote:
So where I should write this piece of code in Xtext project I mean in which file (Sorry for being funny in asking such thing Embarrassed )

This approach:
Quote:
simply create a Plain Java Class Wink e.g. in your DSLs runtime project.or somewhere else with your runtime project on classpath.

doesnt work for me.
I assume, that i first have to include needed plugins in the build path of the DSL runtime project. Is that right?
Or do i have to implement this processor somewhere in my Xtext prject, where I define the grammar of my DSL?

Thank you for your replies

Vladimir
Re: [Xtext] Processing Xtext Model [message #685381 is a reply to message #685379] Fri, 17 June 2011 12:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13604
Registered: July 2009
Senior Member
Hi,

runtime project means here: the project where you define the dsl and not the one you model within Wink so if you want to read dsl files programatically you need the runtime project and some other deps on the path.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext] Processing Xtext Model [message #692570 is a reply to message #685381] Mon, 04 July 2011 18:56 Go to previous messageGo to next message
Timotei D is currently offline Timotei DFriend
Messages: 89
Registered: March 2010
Member
Hi there!

I've managed to get an instance of the Root of my grammar, from a specific file, using this code:

URI uri = URI.createPlatformResourceURI( file.getFullPath( ).toString( ), true );
ResourceSet resSet = new ResourceSetImpl( );
Resource res = resSet.getResource( uri, true );
EObject obj = res.getContents( ).get( 0 );
System.out.println( obj);


However, the first time I use that code, the eclipse freezes like 2-3 seconds. Just first time in a session. Afterwards goes just fine, instantly.

Is there a reason behind it? Or it's the same reason the editor takes a while first time, to init and all that stuff?

Thanks,
Timo
Re: [Xtext] Processing Xtext Model [message #692609 is a reply to message #692570] Mon, 04 July 2011 20:38 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi Timo,

it's the same reason. The activator takes a moment to start.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 04.07.11 20:56, forums-noreply@eclipse.org wrote:
> Hi there!
>
> I've managed to get an instance of the Root of my grammar, from a
> specific file, using this code:
>
>
> URI uri = URI.createPlatformResourceURI( file.getFullPath( ).toString(
> ), true );
> ResourceSet resSet = new ResourceSetImpl( );
> Resource res = resSet.getResource( uri, true );
> EObject obj = res.getContents( ).get( 0 );
> System.out.println( obj);
>
>
> However, the first time I use that code, the eclipse freezes like 2-3
> seconds. Just first time in a session. Afterwards goes just fine,
> instantly.
>
> Is there a reason behind it? Or it's the same reason the editor takes a
> while first time, to init and all that stuff?
>
> Thanks,
> Timo
Previous Topic:appending text programmatically.
Next Topic:Xpand - surplus white space
Goto Forum:
  


Current Time: Wed Sep 23 09:56:00 GMT 2020

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

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

Back to the top