Skip to main content


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 07:56 Go to next message
Ankit Agarwal is currently offline Ankit AgarwalFriend
Messages: 35
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 17:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to Type [message #1016140 is a reply to message #1015200] Tue, 05 March 2013 08:17 Go to previous messageGo to next message
Ankit Agarwal is currently offline Ankit AgarwalFriend
Messages: 35
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 19:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
if it is in the workspace why do you write import "D:/Calculator.myfile"

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to Type [message #1016884 is a reply to message #1016273] Fri, 08 March 2013 04:07 Go to previous message
Ankit Agarwal is currently offline Ankit AgarwalFriend
Messages: 35
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: Fri, 08 March 2013 04: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: Fri Apr 19 12:50:07 GMT 2024

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

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

Back to the top