Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Adding invalid references in Xtext(Adding invalid references in Xtext)
icon5.gif  Adding invalid references in Xtext [message #1258463] Thu, 27 February 2014 12:10 Go to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi all,
My grammar snippet is:

Model:
entities+=Entity;

SomeObj:
("refers" "[" ((importedEntities+=[Entity|ID] ) ("," (importedEntities+=[Entity|ID]))*)? "]")?
;


As you can see, I am adding references of Entity in SomeObj. I want to add reference even if that Entity is not present for me.

So that after importing it will give me an error saying "Couldn't resolve ........".
Then I will proceed with my next work.

To add the invalid references, How my grammar should be changed and what else I need to take care?


Thanks in advance Smile


Arshad
Re: Adding invalid references in Xtext [message #1258468 is a reply to message #1258463] Thu, 27 February 2014 12:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i am not quite sure on your usecase. of course you could simply prevent creating the errors but i dont know if this is what you want
of course then you wont get errors for typos etc ....


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding invalid references in Xtext [message #1258502 is a reply to message #1258468] Thu, 27 February 2014 13:00 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,
Like in my use case I read SomeObj from a excel file and then add it to resource. Even these reference names are present in that excel file.
So blindly I want add the references.
Later I will create an Entity for that or it will be already available in some DSL.


Regards,
Arshad


Arshad
Re: Adding invalid references in Xtext [message #1258525 is a reply to message #1258502] Thu, 27 February 2014 13:21 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi Arshad,

not quite sure what you are about.

Out of the box, you can have invalid reference in your DSL file.
The editor will show you an error flag indicating the broken reference.

If you save the DSL withe errors flagges, the generator will not be started.
But you can take the necessary actions afterwards.

Re: Adding invalid references in Xtext [message #1258543 is a reply to message #1258525] Thu, 27 February 2014 13:44 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Uli, Christian,
I am actually importing this data into my DSL, so while importing only i want to import invalid references too.

I will explain it with an example.
Say I have in my DSL 2 entities Entity1 and Entity2.
Now I will right click on the editor and select "Import SomeObj" option which is a Handler for me.

Now SomeObj is read from an excel file and say that it is referencing 4 entities Entity1 , Entity2 , Entity3 , Entity4.

So in my editor already 2 valid references are existing and I will refer to it.
But still I want to create references (INVALID) for Entity3 and Entity4. So that they appear in the editor, with an error.


Arshad
Re: Adding invalid references in Xtext [message #1258602 is a reply to message #1258543] Thu, 27 February 2014 14:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

why dont you import all entities first?
or dont use references at alll until you have everything imported?
or is importing a permanent usecase?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding invalid references in Xtext [message #1259075 is a reply to message #1258543] Fri, 28 February 2014 02:29 Go to previous messageGo to next message
Xi Lin is currently offline Xi LinFriend
Messages: 21
Registered: January 2014
Junior Member
Hi,

If you really want to do so, i think you can do it in the ScopeProvider.
icon5.gif  Re: Adding invalid references in Xtext [message #1259191 is a reply to message #1258602] Fri, 28 February 2014 05:36 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,
As I explained in my previous message taking example of Entity1,Entity2,Entity3,Entity4.
Suppose I have two model files a.model and b.model. a.model and b.model has same namespace. Say b.model has Entity3 and Entity4.

And when I import data in a.model I get references to all the entities Entity1,Entity2,Entity3,Entity4.

Entity1,Entity2 are already present in a.model but not Entity3,Entity4.

SO, Entity3,Entity4 are invalid references for me when serializing it.

But once the data is imported, all references will become valid as Entity3,Entity4 are already present in b.model under the same namespace.

Regards,
Arshad


Arshad
icon5.gif  Re: Adding invalid references in Xtext [message #1259192 is a reply to message #1259075] Fri, 28 February 2014 05:37 Go to previous message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Xi,
Is it only the scope provider?
Can you please provide me some implementation idea?

Regards,
Arshad


Arshad
Previous Topic:Comments broke Indentation in formatted code
Next Topic:Abstract Syntax Tree (AST)
Goto Forum:
  


Current Time: Fri Mar 29 09:50:55 GMT 2024

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

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

Back to the top