|
|
Re: Scoping of path expressions [message #1020479 is a reply to message #1019451] |
Mon, 18 March 2013 09:14 |
Marco Naddeo Messages: 62 Registered: November 2012 |
Member |
|
|
Hi
here is a fragment of my grammar:
BaseExpression:
( this?='this' |
superExpr=SuperExpression |
true?='true' |
false?='false' |
float=FLOAT_LITERAL |
integer=INTEGER_LITERAL |
byte=BYTE_LITERAL |
string=STRING_LITERAL |
null?='null' |
variable=[Variable] |
'(' expr=Expression ')' |
newObject=ObjectCreation
) (suffix=BaseExpressionSuffix)?
;
BaseExpressionSuffix:
{FieldSelectSuffix} '.' mixinName=[MixinDeclaration] '.' fieldName=[FieldDeclaration] (suffix=BaseExpressionSuffix)? |
{MethodCallSuffix} '.' mixinName=[MixinDeclaration] '.' methodName=[MethodDeclaration] list=ActualParameters (suffix=BaseExpressionSuffix)?
;
So I have to scope something like this:
msg.HelloWorld.getMessage().String.print();
I try to explain my problem with an example. If I'm writing in the editor the following code:
msg.HelloWorld.getMessage().
then, on dot scoping and in particular my method
IScope scope_BaseExpressionSuffix_mixinName(final EObject context, EReference ref)
is called on context ".HelloWorld.getMessage()" which is a MethodCallSuffix; so in the scoping method I have to filter possible mixins after the dot basing on the return type of the method is called in this MethodCallSuffix.
But when I have finished writing in the editor the complete expression, that is:
msg.HelloWorld.getMessage().String.print();
now scoping for the second MixinDeclaration reference mixinName in this expression is called on context ".String.print()" which is a MethodCallSuffix; so in this case I have to filter possibile mixins for the reference basing on the return type of previous MethodCallSuffix (or, in a similar manner, on the type of the field selected in a previous hypothetical FieldSelectSuffix).
How can I get this? My idea is to test if the reference I'm scoping is in the context element or in its parent, but I don't know if and how I can test this: if I well understood, the ref parameter of type EReference in the scoping method cannot help me, since it coincides with the metadata representing the reference, and not with the actual reference that I'm scoping.
|
|
|
Powered by
FUDForum. Page generated in 0.03033 seconds