| cross references to function definitions with same names but different signatures [message #907974]
||Tue, 04 September 2012 13:51
| Tobias Mayer
Registered: August 2012
my question is about cross references to function definitions with same names but different signatures.
Here is a little language to better describe my concern:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl ""
'int' name = ID
'void' name = ID
'(' (argDefList = ArgumentDefinitionList)? ')'
'RefFunction' el = [FunctionDefinition|FunctionDefinitionFormat]
List += ArgumentDefinition ( ',' List += ArgumentDefinition)*
TypeQualifier id = ID
ID '(' (ParameterFormat)? ')'
ID (',' ID)*
. The following code shows a word of this language:
void Funcb(int a, int b)
void Funcb(int a)
. The goal is to extend the code to:
1. void Funcb(int a, int b)
2. void Funcb(int a)
3. int x
4. int y
5. RefFunction Funcb(x,y)
6. RefFunction Funcb(y)
. The editor shell link the name in line 5 to the function definition in line 1 and the name in line 6 to the function definition in line 2. The arguments of a RefFunction shell also be linked to their variable definitions.
First of all, I want to decribe my current idea:
I have extended the DefaultDeclarativeQualifiedNameProvider with the Method "protected QualifiedName qualifiedName(FunctionDefinition funcDef)". The method adds an open and a close bracket at the end of the name of a function. If there are parameters, the datatypes of the parameters are listed between the brackets seperated by commas.
For both functions in the example above the provided qualified names are:
I have also extended the class DefaultLinkingService by overriding the method "List<EObject> getLinkedObjects(EObject context, EReference ref, INode node)". This method is called to solve the cross reference.
The idea is to compare the cross reference string (Funcb(x,y) and Funcb(x)) with the signatures of the function definitions delivered by my qualified name provider. If there is a match, the corresponding EObject to a signature is returned.
With this approach the editor nearly behaves as desired. When I press "F3" the cursor jumps to the right Functiondefinition, too. This also happens when the cursor is on the argument "x" in the RefFunction "RefFunction Funcb(x,y)".
What do I have to do that also the arguments are linked to their variable definitions?
Is there a better way?
Powered by FUDForum
. Page generated in 0.01506 seconds