Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross reference with dot in a name
Cross reference with dot in a name [message #1759620] Thu, 13 April 2017 22:29 Go to next message
wces wces is currently offline wces wcesFriend
Messages: 1
Registered: April 2017
Junior Member
I have a grammar in which variable names can have dots in them.
But when I try to use cross reference for it. It is not able to find it when there is a dot in var name.
xtext seems to be treating these dots specially. How can I force xtext stop treating the dots specially.

VarDecl:
'VAR' name=VarID ';'
;

VarID:
ID ('.' ID)*
;
Assign:
left=[VarDecl|VarID] '=' right=ID


Works:
VAR varName;
varName = x

Doesn't work: (cannot find var.name)
VAR var.name;
var.name = x
Re: Cross reference with dot in a name [message #1759794 is a reply to message #1759620] Tue, 18 April 2017 06:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

i cannot reproduce this.
can you please share everything needed to reproduce it. e.g. did you customizations to scoping, nameproviders etc.
do you have other stuff in the grammar that could interfer etc.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross reference with dot in a name [message #1759803 is a reply to message #1759794] Tue, 18 April 2017 15:26 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi,

the "qualified name" is based on hierarchy of objects, each on has his simple name (just the delivered ID, no dots).
The dots come into place where you want to refer to an object inside a higher level object:
classA.variableB

which are defined as
class A { variable B}

HIH, Uli
Re: Cross reference with dot in a name [message #1801919 is a reply to message #1759803] Tue, 29 January 2019 14:23 Go to previous messageGo to next message
David Paz is currently offline David PazFriend
Messages: 9
Registered: November 2013
Junior Member
Hi,

i have this same issue. I will post details here to not open another thread, please just tell me if i should open another.

My intention, same as the author, is only to have dots "." in the name no import or package representation. Only being able to parse name with dots and resolve them in cross references.

My grammar is like:

Name:
    ID ('.' ID)*
;

Email:
    Name '@' Name
;

Customer:
	'customer' name = Name	'email'	email = Email
;

Application:
    'application' name = ID 'administrator' admin = [Customer]


I don't have any customization in place, so no custom ScopeProvider or NameProvider.

I can declare customers like stated in before rules
customer test.user email test.user@test.com

But as soon as i try to use them in a cross reference:
application AppTest administrator test.user

i receive the error:
Couldn't resolve reference to Customer 'test'.


Any hint will be welcome,

Thanks in advance,
David
Re: Cross reference with dot in a name [message #1801935 is a reply to message #1801919] Tue, 29 January 2019 15:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i dont understand

the solution applied would be

admin = [Customer|Name]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross reference with dot in a name [message #1801943 is a reply to message #1801935] Tue, 29 January 2019 17:30 Go to previous messageGo to next message
David Paz is currently offline David PazFriend
Messages: 9
Registered: November 2013
Junior Member
Hi Christian,

thanks! That solved the issue.
Now I find my self wondering why is needed both alternatives :-)

Thanks again,
David
Re: Cross reference with dot in a name [message #1801949 is a reply to message #1801943] Tue, 29 January 2019 18:01 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
admin = [Customer] is short for admin = [Customer|ID] which means: reference to customer, parse ID
ID does not allow .



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Customize the inserted value from auto-complete from the proposed
Next Topic:Xbase DSL Editor is extremely slow
Goto Forum:
  


Current Time: Tue Apr 16 20:48:58 GMT 2024

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

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

Back to the top