Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Could not resolve reference to Type (Type: DataType | Class)
Could not resolve reference to Type (Type: DataType | Class) [message #759299] Mon, 28 November 2011 10:03 Go to next message
lin.lin is currently offline lin.linFriend
Messages: 17
Registered: September 2011
Junior Member
The intention is to let the class varialbe can be an datatype or a class
, but grammar simply not working.

grammar
--
Type:
{Type}
datatype=DataType | class=Class
;

DataType:
'datatype' name = ID

Class:
'class' name = ID
('extends' superType = [Class | QualifiedName ])?


Variable:
(modifiers += Modifier)*
type = [Type | ID] // [DataType | ID] is OK, this one problem.
name = ID

...


model
--
datatype Integer

class CCCINCAPABILITIES
{
Integer usClass // Error: Couldn't resolve reference to Type 'Integer'.
Boolean bVandalCheck
}

Could you please give a hint about the correct form of the grammar?


~peter lin



Re: Could not resolve reference to Type (Type: DataType | Class) [message #759320 is a reply to message #759299] Mon, 28 November 2011 11:20 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
This should work (untested!):
grammar
--
Type:
DataType | Class
;

DataType:
'datatype' name = ID 

Class:
'class' name = ID
('extends' superType = [Class | QualifiedName ])?


Variable:
(modifiers += Modifier)*
type = [Type | ID]
name = ID

The problem with your grammar is that your original type 'Type' doesn't expose a name of its own because it composes either a DataType or a Class. Because 'Type' doesn't expose a name, it can't be resolved as the target of a cross-reference. By making 'Type' the super type of both DataType and Class, both of which expose a name (=ID), linking works as intended.


Re: Could not resolve reference to Type (Type: DataType | Class) [message #759532 is a reply to message #759299] Tue, 29 November 2011 02:26 Go to previous messageGo to next message
lin.lin is currently offline lin.linFriend
Messages: 17
Registered: September 2011
Junior Member
It does the trick. Whether it is called "Feature Normalization"?

Here below is a taken from the documentation:

"6.3.4. Feature Normalization
In the next step the generator examines all generated EClass and lifts up similar features
to super types if there is more than one subtype and the feature is defined in every
subtypes. This does even work for multiple super types."

If yes, could you share why this "lifts up" will not work with "assignment".

thanks a lot.

Re: Could not resolve reference to Type (Type: DataType | Class) [message #759564 is a reply to message #759532] Tue, 29 November 2011 08:34 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Feature Normalization only "lifts up" common features (i.e., assignments with the same name, type and cardinality) from sub types to (the most generic) super type. In your original grammar, the type 'Type' didn't have any sub or super types since it composed DataType and Class.

Re: Could not resolve reference to Type (Type: DataType | Class) [message #784273 is a reply to message #759299] Fri, 27 January 2012 09:24 Go to previous messageGo to next message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Hi!

I have a similar problem like lin.lin. Here is his grammar again:

------------------
Type:
{Type}
datatype=DataType | class=Class
;

DataType:
'datatype' name = ID

Class:
'class' name = ID
('extends' superType = [Class | QualifiedName ])?


Variable:
(modifiers += Modifier)*
type = [Type | ID] // [DataType | ID] is OK, this one problem.
name = ID

--------------------


I do want to leave the feature "datatype" in the type "Type" (in order to do local scoping). Is it still possible to reference somehow by [Type | ID]? If yes, what do I have to do?

Thank you,
Alex.
Re: Could not resolve reference to Type (Type: DataType | Class) [message #784562 is a reply to message #784273] Fri, 27 January 2012 17:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you can use an IQualifiedNameProvider to give your Type its DataTypes name

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Could not resolve reference to Type (Type: DataType | Class) [message #786416 is a reply to message #784562] Mon, 30 January 2012 11:53 Go to previous message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Thank you!

Now I better understand the qualified names concept.
Previous Topic:Parse and assign comments at end of line
Next Topic:[xtend2] access static member in another package
Goto Forum:
  


Current Time: Thu Apr 25 13:09:46 GMT 2024

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

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

Back to the top