Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » "Couldn't resolve reference" problem with programmatically created object
"Couldn't resolve reference" problem with programmatically created object [message #1348016] Sun, 11 May 2014 11:04 Go to next message
Fabian G. is currently offline Fabian G.Friend
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 #1348018 is a reply to message #1348016] Sun, 11 May 2014 11:53 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 248
Registered: June 2013
Senior Member
I don't see any specification for your "FQN".
The proposal is ok because it lists Type instances, but afterwards it can not start the FQN.

I'm not an expert, but if I see examples for full qualified names, ther is always an entry for that in the grammar.
Re: "Couldn't resolve reference" problem with programmatically created object [message #1348019 is a reply to message #1348018] Sun, 11 May 2014 12:16 Go to previous messageGo to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
did't provide it, sorry, it's just the usual fully qualified name rule

FQN:
  ID ('.' ID)*;
Re: "Couldn't resolve reference" problem with programmatically created object [message #1348020 is a reply to message #1348019] Sun, 11 May 2014 12:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13317
Registered: July 2009
Senior Member
Hi,

scoping in proposal provider (with a partialy build model) and on saving in the editor (with a complete model) may differ in the context object
that goes into the scoping method. so do you have any customizations there


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: "Couldn't resolve reference" problem with programmatically created object [message #1348021 is a reply to message #1348020] Sun, 11 May 2014 13:07 Go to previous messageGo to next message
Fabian G. is currently offline Fabian G.Friend
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

Re: "Couldn't resolve reference" problem with programmatically created object [message #1348022 is a reply to message #1348021] Sun, 11 May 2014 13:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13317
Registered: July 2009
Senior Member
Hi,

just from the information i have i have no idea


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: "Couldn't resolve reference" problem with programmatically created object [message #1348031 is a reply to message #1348022] Sun, 11 May 2014 19:34 Go to previous messageGo to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
Do you know where these validations (the thing that produce the error message "couldn't resolve reference" error) are performed so that I can debug there and see what's happening?
Re: "Couldn't resolve reference" problem with programmatically created object [message #1348391 is a reply to message #1348031] Sun, 11 May 2014 20:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13317
Registered: July 2009
Senior Member
Hi,

it is done in the linker (org.eclipse.xtext.linking.lazy.LazyLinker)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: "Couldn't resolve reference" problem with programmatically created object [message #1349094 is a reply to message #1348391] Mon, 12 May 2014 04:11 Go to previous message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
I'll have a look and post back if I found the solution. Thanks
Previous Topic:Auto-selection of text at proposal?
Next Topic:SonarQube and Xtend
Goto Forum:
  


Current Time: Sat Jan 25 09:41:10 GMT 2020

Powered by FUDForum. Page generated in 0.02760 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top