Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Obtain a Resource of a model source file (to compile imports in code generation)
icon5.gif  Obtain a Resource of a model source file (to compile imports in code generation) [message #1093853] Sat, 24 August 2013 19:47 Go to next message
Shelby Moore III is currently offline Shelby Moore IIIFriend
Messages: 42
Registered: August 2013
Member
The 15 minute tutorial explains how IGenerator::doGenerate is called on each model source file.

But a model source file may have dependencies (e.g. imports) from other model source files. So the code generation may need to get access to the Ecore model for each of those other files.

How to create a call which inputs a model source file and outputs an Ecore Resource?

I found the following links which may be relevant?

http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/

http://www.eclipse.org/forums/index.php/t/489925/

http://zarnekow.blogspot.com/2010/06/how-to-deploy-xtext-standalone.html
Re: Obtain a Resource of a model source file (to compile imports in code generation) [message #1093885 is a reply to message #1093853] Sat, 24 August 2013 20:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi i am Not sure what you try Todo. What is the Thing you want to achive. Of you reference Object from Other Files simply follow the references. The loading of the Other Files will Happen transparently. Never the less you can explicitely load resouces into a resouceset (this is Std. EMF API)

So without any specific example it is Hard to Tell how to proceed


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Obtain a Resource of a model source file (to compile imports in code generation) [message #1094055 is a reply to message #1093885] Sun, 25 August 2013 03:41 Go to previous messageGo to next message
Shelby Moore III is currently offline Shelby Moore IIIFriend
Messages: 42
Registered: August 2013
Member
Christian Dietrich wrote on Sat, 24 August 2013 16:58
Of you reference Object from Other Files simply follow the references. The loading of the Other Files will Happen transparently.


That would be wonderful. Please look at my example below and explain to me how to enable that functionality.

Currently my grammar for imports is as follows.

Import:
   'IMPORT' (path+=ID '.')* path+=OID;

terminal ID:
   (('a'..'z')('a'..'z'|'A'..'Z'|'0'..'9')* | '`' !'`'+ '`');

terminal OID:  // OOP type name
   ('A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9')* | '`' !'`'+ '`';


How can Xtext be told to follow that path for the file that contains a (Interface | Mixin | Class | Object) which has the matching type name?

Then where does the reference go? The grammar above asks only for an EString (i.e. the path+=OID) and does not ask for a path+=(Interface | Mixin | Class | Object) as that wouldn't make sense to put the declaration for those at the tail end of the IMPORT statement.
Re: Obtain a Resource of a model source file (to compile imports in code generation) [message #1094143 is a reply to message #1094055] Sun, 25 August 2013 07:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

Im am Not talking about a construct that is called import and Could although be named Whatever.
Dont you have any cross refs in your grammar?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Obtain a Resource of a model source file (to compile imports in code generation) [message #1095939 is a reply to message #1094143] Tue, 27 August 2013 18:58 Go to previous message
Shelby Moore III is currently offline Shelby Moore IIIFriend
Messages: 42
Registered: August 2013
Member
Thank you very much. I found it much easier to read the documentation at following links, than the documentation at the main Xtext site (even it is same English text).

Getting Started -> Creating a DSL -> Adding a Namespace Concept

Also this overview.
.

[Updated on: Tue, 27 August 2013 19:01]

Report message to a moderator

Previous Topic:End-to-end DSL unit testing?
Next Topic:How to get scope for jvm type or pojo
Goto Forum:
  


Current Time: Thu Apr 25 17:49:44 GMT 2024

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

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

Back to the top