Couldn't resolve reference to Type [message #1015008] |
Wed, 27 February 2013 02:56  |
Eclipse User |
|
|
|
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 #1016884 is a reply to message #1016273] |
Thu, 07 March 2013 23:07  |
Eclipse User |
|
|
|
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] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.09806 seconds