Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Couldn't resolve reference to Type
Couldn't resolve reference to Type [message #1015008] Wed, 27 February 2013 02:56 Go to next message
Ankit Agarwal is currently offline Ankit Agarwal
Messages: 33
Registered: March 2012
Member
Hi,

In my Xtext generated editor i import a file and then use some attributes of that file. But i am getting the error as Couldn't resolve reference to Type 'Calculator.add'. at the line where i use it.

I have a Editor whose contents are something like :

import "D:/Calculator.myfile"

map Calculator.add {
$int a = 10;
$int b = 20;
}

My workflow is like:
// scoping and exporting API
fragment = scoping.ImportURIScopingFragment {}
fragment = exporting.SimpleNamesFragment {}


Re: Couldn't resolve reference to Type [message #1015200 is a reply to message #1015008] Wed, 27 February 2013 12:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
Hi,

afaik the objects still have to be in the workspace so absolute imports wont work since the files will not be under the hood of the xtext builder
Re: Couldn't resolve reference to Type [message #1016140 is a reply to message #1015200] Tue, 05 March 2013 03:17 Go to previous messageGo to next message
Ankit Agarwal is currently offline Ankit Agarwal
Messages: 33
Registered: March 2012
Member
Hi,

The imported files are in the workspace. While import it does not give any error (I have a java Validation on that, if the file is not present, it gives an error on Editor import statement), but when i am trying to use some attribute of the imported file, it says that reference cannot be resolved.
Re: Couldn't resolve reference to Type [message #1016273 is a reply to message #1016140] Tue, 05 March 2013 14:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
if it is in the workspace why do you write import "D:/Calculator.myfile"
Re: Couldn't resolve reference to Type [message #1016884 is a reply to message #1016273] Thu, 07 March 2013 23:07 Go to previous message
Ankit Agarwal is currently offline Ankit Agarwal
Messages: 33
Registered: March 2012
Member
I tried with both the relative path as well as absolute path, but was getting the same error.
Anyways i got the problem fixed.

In DefaultLinkingService method getLinkedObjects, collected all scopes from imported files, then it looks for each string (In My case Calculator.add), converts it to QualifiedName and then matches if it exists in the scope. There was a catch here. while converting String to QualifiedName it created a new Object if it encounters a '.' in the String as mentioned in IQualifiedNameConverter. This only happened when a '.' was used as a separator or when an attribute or method was accessed by ClassName.MethodName or ClassName.Attribute. As it was a different object, so the object in the scope and this were never equal , hence the Type was not getting resolved.
To resolve this I had to bind a new QualifiedNameConverter that extended IQualifiedNameConverter.DefaultImpl in that class i had to override toQualifiedName method.
I dont know whether its correct or not but this got my problem fixed.

[Updated on: Thu, 07 March 2013 23:12]

Report message to a moderator

Previous Topic:Scope provider stops working with UPPER_CASE_ID terminal rule
Next Topic:Errors and Warnings while running workflow
Goto Forum:
  


Current Time: Thu Jul 31 21:50:39 EDT 2014

Powered by FUDForum. Page generated in 0.02456 seconds