Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Leveraging importURI mechanism to include imported objects in model
icon5.gif  Leveraging importURI mechanism to include imported objects in model [message #703806] Wed, 27 July 2011 23:52 Go to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 125
Registered: July 2009
Location: New York City, NY
Senior Member
Hi all,

I was wondering whether it is possible to leverage the importURI mechanism to actually include links to the referred element in the model. Right now, if my grammar contains a rule like
Include: 'include' importURI=STRING;
I do get URI validation via ImportUriValidator, and objects that were exported from the included file are brought into scope by the ImportUriGlobalScopeProvider. However, the included file is not directly linked into the object model.
I would like to do something like
Include: 'include' importURI=[ModelFile|STRING];
(or something like that) to actually produce a fully-linked object graph.
I understand that I could customize the ScopeProvider to achieve this, but it seems I lose some of the URI validation and resolution functionality that is provided by the standard importURI mechanism. What is the easiest way to achieve this sort of linking without rewriting or duplicating code that already exists elsewhere in Xtext?

Thanks,

Mirko

Re: Leveraging importURI mechanism to include imported objects in model [message #703977 is a reply to message #703806] Thu, 28 July 2011 06:26 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

importURI really is only used for making the other file X visible, not for actually referencing it. You could see the default import strategy as follows: If you reference an object from X, you get the object graph you want and if you don't need/have a reference to an actual object, then it is an import you don't need.

The question is, what do you need the import for? Should F3 be enabled in the import? Then adapt hyperlinking.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Leveraging importURI mechanism to include imported objects in model [message #704085 is a reply to message #703977] Thu, 28 July 2011 09:02 Go to previous message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 125
Registered: July 2009
Location: New York City, NY
Senior Member
Thanks for your comments, Alex!

We're talking more about something similar to #include in the C preprocessor here; I understand that this mechanism is very different from Java imports.
I'm really interested in obtaining a fully linked ECore model, not so much in editor features like F3. I need to traverse the complete object graph to collect certain information, and it seemed that importURI already provides the mechanism for locating the files, so I wanted to take this a step further, so that a linked model gets built at the same time. I was hoping importURI could somehow be leveraged for that.
I guess the custom scope provider is the way to go then, though it is pretty tricky because I need to process relative URIs like "../../folder/file.h" and I don't want to change the lexical structure of the language, if I can avoid it. If '..', '/', etc. are lexed as separate tokens, it is possible to create a scope provider that is populated from the file system or workspace, but it would mean that I cannot use the STRING rule from common.Terminals and have to use custom terminals that drill down into strings.
Anyway, I realize it was a long shot to hope for leveraging importURI for this. I'll try putting together a custom scope provider, possibly with custom lexing.

Thanks,

Mirko
Previous Topic:log4j Error
Next Topic:Error: The code of method ruleElement() is exceeding the 65535 bytes limit
Goto Forum:
  


Current Time: Thu Apr 25 00:19:20 GMT 2024

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

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

Back to the top