Local Scope and Shadowing [message #705343] |
Fri, 29 July 2011 18:55 |
Rafael Angarita Messages: 94 Registered: November 2010 |
Member |
|
|
Hello, I've been reading other posts and blogs about local scoping but I don't getting, I think I am missing something.
Here is my example:
Model:
A |
R
;
A:
'A' name=ID
;
R:
'R' name=ID
objectReference=ObjectReference
innerObject=InnerObject
;
InnerObject:
'innerObject' name=STRING
;
ObjectReference:
object=[ecore::EObject]
;
My scope provider, where I filter objects by they file extension:
public IScope scope_ObjectReference_object(EObject i, EReference r) {
return new org.eclipse.xtext.scoping.impl.FilteringScope(delegateGetScope(i, r),new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
return input!=null && input.getEObjectURI()!=null && input.getEObjectURI().fileExtension()!=null &&
(input.getEObjectURI().fileExtension().equals("a")
);
};
});
}
Now, I want to write this code:
file: R.r
R myr
mya
innerObject 'mya'
file: mya.a
, but as expected, innerObject 'mya' shadows the object in mya.a, so I get "Couldn't resolve reference to EObject 'mya'".
How should I do this?
Thank you very much for your help and advices.
PD: I noted the filtering does not work since the local object "mya" shadows the global object before the call to the scope_ObjectReference_object method.
[Updated on: Fri, 29 July 2011 18:59] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03989 seconds