How to find the closest reference? [message #707916] |
Tue, 02 August 2011 04:09  |
Eclipse User |
|
|
|
Hi all, I am currently working on building an IDE for ATS (www.ats-lang.org). In ATS, the same name can be used for many times. For clarity of the problem, the sample grammar goes as follows:
=================================
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
greetings+=Greeting*;
Greeting:
name=ID '=' INT
| name=ID '=' mcontent=[Greeting | ID]
; =================================
I also commented out the
=================================
composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" =================================
in the mwe2 file.
The corresponding source code would be like this
=================================
=================================
When I Ctrl-Click on "z", it refers to the first "x", which is not what I want. Is it possible to make it jump to the second "x" which is the closest one to "z". Or is it possible to show another dialogue so that the programmer can choose? Either way is fine, any suggestion about how to do this based on Xtext is highly appreciated. Thanks a lot.
|
|
|
|
Re: How to find the closest reference? [message #708514 is a reply to message #708110] |
Tue, 02 August 2011 18:28  |
Eclipse User |
|
|
|
Thank you very much for your advice. I am now reading the ImportedNamespaceAwareLocalSpaceProvider. I think the easy way is to imitate it and then write my own CustomImportedNamespaceAwareLocalSpaceProvider. I am still a newbie to Xtext. Please correct if I am wrong. In the function
============================
protected IScope getLocalElementsScope(IScope parent, final EObject context,
final EReference reference) { =============================
I see the code
=============================
ISelectable allDescriptions = getAllDescriptions(context.eResource()); =============================
Does this "allDescriptions" contain all the nodes to create the scope?
|
|
|
Powered by
FUDForum. Page generated in 0.04664 seconds