"Couldn't resolve reference" problem with programmatically created object [message #1348016] |
Sun, 11 May 2014 11:04 |
Fabian G. Messages: 60 Registered: May 2010 Location: Christchurch (NZ) |
Member |
|
|
Hi,
At some points, I have to create objects from a program (grammar has a kind of Type-Object with property inheritance). The ProposalProvider retrieves correctly my object, but I get a "couldn't resolve reference error". Any hint ?
for info, if useful, here is the idea behind what I have in my grammar:
Type :
'type' name=ID 'properties {'
properties+=Property
'}';
Property :
name=ID;
// object must inherit from the properties of its type
Object :
'object' name=ID type=[Type|FQN]';';
SomeRule :
'somerule' prop=[ConcreteProperty|FQN]';';
// the ConcreteProperty is the object I manually create from code (exists in the metamodel), which inherits from Property and augmented with a feature 'inObject' -> Object
// such that I may be able to do something like in the following concrete model snippet
type MyType properties {
aProperty
}
object myObject MyType;
somerule myObject.aProperty;
// the proposal provider gives the right stuff, but it is marked as error with "couldn't resolve reference"
I also tried to just add the object in the feature (so having the 'inObject' feature in the Property EObject and creating the link myself) instead of creating a new one, the result was the same: correctly proposed, but marked as error.
Any clue? Or someone can point me to the class that is responsible for these checks so that I can debug it?
Thanks in advance,
Fabian
[Updated on: Sun, 11 May 2014 11:19] Report message to a moderator
|
|
|
|
|
|
Re: "Couldn't resolve reference" problem with programmatically created object [message #1348021 is a reply to message #1348020] |
Sun, 11 May 2014 13:07 |
Fabian G. Messages: 60 Registered: May 2010 Location: Christchurch (NZ) |
Member |
|
|
I customized an ImportedNamespaceAwareLocalScopeProvider that filters on the elements from my model and from explicitly imported models (instead of having the whole workspace available).
I overrided the getGlobalScope method like this:
@Override
protected IScope getGlobalScope(Resource context, EReference reference) {
return super.getGlobalScope(context, reference,
makeFilterForAccessibleObjects(context.getContents().get(0)));
}
the makeFilter method looks like the following :
private Predicate<IEObjectDescription> makeFilterForAccessibleObjects(final EObject context) {
return new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
/* some code to only accept elements from the model and imported models */
}
};
}
I also override the getImplicitImports() to add built-in libraries and getImportedNamespaceResolvers() to handle the explicit imports. This class is there for a very long time.
Maybe you gave me an hint, actually, the error is raised at the saving, and without underlining the line (but pointing it from the Problems view).
[Updated on: Sun, 11 May 2014 13:10] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02473 seconds