Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » uncertain reference to entity(uncertain reference to entity)
uncertain reference to entity [message #808269] Mon, 27 February 2012 10:49 Go to next message
Michal S is currently offline Michal S
Messages: 73
Registered: July 2011
Member
Hello,
I am wondering, how would be possible to solve following issue:

Lets have grammar:
Variable: name=MYID '=' value=INT;
MYID: ID;
RefToDefinedOrUndefinedVariable: name=ID '=' value=[Variable]|MYID;


I understand, that this is not valid as "Decision can match input such as "RULE_ID" using multiple alternatives".
My task is, whether it is somehow possible to "reference if available"?
UseCase: there are some variables not defined in model (they are defined in runtime environment, where generated code will be used).

Temporarily, I solved it as "... value=MYID" and completion is done using Dynamic Template Proposals. Unfortunately, this is very dirty solution (i.e. there is no real reference).

Thank you
Michal



Re: uncertain reference to entity [message #808925 is a reply to message #808269] Tue, 28 February 2012 04:45 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte Boersma
Messages: 429
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
If the referrable items which are defined in the runtime environment are fixed, then you could use implicit imports: see e.g. http://blogs.itemis.de/stundzig/archives/795. It boils down to always having an extra, invisible model Resource which defines these extra variables.

Another, more tedious solution, is to validate just the "... value=MYID", to create a hyper link provider so the value can behave like a link where appropriate and custom content assist to provide the user with the relevant items.


Re: uncertain reference to entity [message #809764 is a reply to message #808925] Wed, 29 February 2012 03:29 Go to previous messageGo to next message
Michal S is currently offline Michal S
Messages: 73
Registered: July 2011
Member
Hello Meinte,
thank you for your answer.
Unfortunately, Link, which you have provided, is not valid.
I will try to go ahead with hyperlinking (I have never worked with that before), I hope, I will make it working...
Regards,
Michal
Re: uncertain reference to entity [message #809902 is a reply to message #809764] Wed, 29 February 2012 07:24 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte Boersma
Messages: 429
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
The link without extra .: http://blogs.itemis.de/stundzig/archives/795


Re: uncertain reference to entity [message #809922 is a reply to message #809902] Wed, 29 February 2012 07:47 Go to previous messageGo to next message
Michal S is currently offline Michal S
Messages: 73
Registered: July 2011
Member
Hello Meinte,
I haven't seen the dot behind, sorry about it.
Anyway, I think, hyperlinking is more appropriate concept for this purpose. I have googled for some example of using it ( http://www.eclipse.org/Xtext/documentation/2_1_0/180-hyperlinking.php ), but I was not successful.
Could anybody provide some simple example, how to creat hyperlink e.g. in this simple case:
MyDsl: contents+= Entity*;
Entity: Entity1|Entity2;
Entity1: 'Entity1' name=MYID;
Entity2: 'Entity2' name=MYID refToEntity1=MYID;
MYID: ID;

I guess, it can be done somehow using createHyperlinksByOffset or createHyperlinksTo methods, but I have no clue how.
Thank you & Best regards,
Michal
Re: uncertain reference to entity [message #810053 is a reply to message #809922] Wed, 29 February 2012 11:11 Go to previous message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2427
Registered: July 2009
Senior Member
I do my special linked "after model linked" and associate information in
adapters (for various purposes). At the other end, simply override the
default implementation (of whatever it is you are after) and make it
also look in the special adapter.

You can look at such an implementation in cloudsmith/geppetto at github.
I use this for "Show Declaration" (among other things).

- henrik

On 2012-29-02 13:48, Michal S wrote:
> Hello Meinte,
> I haven't seen the dot behind, sorry about it.
> Anyway, I think, hyperlinking is more appropriate concept for this
> purpose. I have googled for some example of using it (
> http://www.eclipse.org/Xtext/documentation/2_1_0/180-hyperlinking.php ),
> but I was not successful.
> Could anybody provide some simple example, how to creat hyperlink e.g.
> in this simple case:
>
> MyDsl: contents+= Entity*;
> Entity: Entity1|Entity2;
> Entity1: 'Entity1' name=MYID;
> Entity2: 'Entity2' name=MYID refToEntity1=MYID;
> MYID: ID;
>
> I guess, it can be done somehow using createHyperlinksByOffset or
> createHyperlinksTo methods, but I have no clue how.
> Thank you & Best regards,
> Michal
Previous Topic:Collect attributes from parser rules
Next Topic:Validation / Type checking / attributes
Goto Forum:
  


Current Time: Tue May 21 10:44:33 EDT 2013

Powered by FUDForum. Page generated in 0.01788 seconds