Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Cannot be resolved
Cannot be resolved [message #1763493] Tue, 16 May 2017 13:11 Go to next message
Eclipse UserFriend
I have written below grammar. In my example model, I want to refer to join J3 after startPoint1 but it always gives me "cannot be resolved" error.

Grammar below:

grammar org.xtext.project.turn.Turn with org.eclipse.xtext.xbase.Xbase

generate turn "http://www.xtext.org/project/turn/Turn"

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

URNspec:
'URNModel' name=QualifiedName
(ucmspec=UCMspec)?;

URNmodelElement: Dependency | UCMmap | Responsibility;

IntentionalElement:
type=IntentionalElementType name=QualifiedName '{'
longName=STRING
('importance' (importance=ImportanceType | importanceQuantitative=QUALITATIVEVALUE))?
'}';

Dependency: 'dependsOn' dest=[IntentionalElement | QualifiedName] ('{'
'}')?;

enum IntentionalElementType: Softgoal | Goal | Task | Resource | Belief | Indicator;

enum ImportanceType: High | Medium | Low | None;

QUALITATIVEVALUE returns ecore::EInt: ('-'|'+')? INT;

UCMspec:{UCMspec} 'UCM''{'
ucmMaps+=UCMmap*
'}';

UCMmap: 'map' name=QualifiedName '{'
paths+=Path*
'}';

Path: 'start' name = QualifiedName
pathBody = PathBody;

PathBody: PathWithRegularEnd | PathWithReferencedEnd;

PathWithRegularEnd:{PathWithRegularEnd}
('->'pathNodes+=PathNode)* '->'
pathEnd=RegularEnd ;

PathWithReferencedEnd:{PathWithReferencedEnd}
('->'pathNodes+=PathNode )* '->'
referencedEnd=[ReferencedEnd | QualifiedName] ;

RegularEnd: EndPoint ;

EndPoint:
'end' name = QualifiedName ';';

PathNode: Responsibility | OrJoin ;

ReferencedEnd: OrJoin ;

Responsibility: 'X' name = QualifiedName ;

OrJoin: 'join' name = QualifiedName;

..................................................................................................................................................


Simple example model :

URNModel Example

UCM{
map TL {
start startPoint1 -> J3
start startPoint3 -> X check -> join J3 -> end fail;
}
}

I don't understand why it does not recognize J3.

[Updated on: Tue, 16 May 2017 13:22] by Moderator

Re: Cannot be resolved [message #1763497 is a reply to message #1763493] Tue, 16 May 2017 13:47 Go to previous messageGo to next message
Eclipse UserFriend
Because `J3`is a child of `startPoint3`, the qualified name used in scoping is `startPoint3.J3`.
If you want to make your example work, you need to either change the structure of the created AST (so that `join J3`is not a child of an element with a name), or you implement the `IQualifiedNameProvider`to return the simple name.

hth,
Sven
Re: Cannot be resolved [message #1763498 is a reply to message #1763493] Tue, 16 May 2017 13:48 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

where is J3 defined? is it the one defined in point3? if yes you need to adapt the naming behaviour

MyQNP.xtend (new)
import com.google.inject.Inject
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider
import org.eclipse.xtext.naming.IQualifiedNameConverter
import org.eclipse.xtext.naming.QualifiedName
import org.xtext.example.mydsl1.myDsl.OrJoin

class MyQNP extends DefaultDeclarativeQualifiedNameProvider {
	
	@Inject IQualifiedNameConverter qnc
	
	def QualifiedName qualifiedName(OrJoin join) {
		return qnc.toQualifiedName(join.name)
	}
	
}


MyDslRuntimeModule.xtend (existing)
class MyDslRuntimeModule extends AbstractMyDslRuntimeModule {
	
	override bindIQualifiedNameProvider() {
		MyQNP
	}
	
}
Re: Cannot be resolved [message #1763499 is a reply to message #1763497] Tue, 16 May 2017 13:51 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the reply.

But startpoint3.J3 doesn't work either. Gives the same 'cannot be resolved error'.
Re: Cannot be resolved [message #1763500 is a reply to message #1763499] Tue, 16 May 2017 14:17 Go to previous messageGo to next message
Eclipse UserFriend
if you want to use the qualified name it would be

start startPoint1 -> Example.TL.startPoint3.J3
Re: Cannot be resolved [message #1763519 is a reply to message #1763500] Tue, 16 May 2017 23:19 Go to previous messageGo to next message
Eclipse UserFriend
Hello Christian,

Thanks for your reply.
This worked for join. However, I changed my grammar slightly (to originally what i wanted to do) and now I want to reference to timer (getPIN) but it gives me the same error even after overriding the qualifiedName for Timer. I think I am doing something wrong with the way i have referenced (TimerInPath) in the grammar. Could you please help?

Attaching the grammar and below is my example model.

URNModel Example
UCM{


map TL {
start startPoint3 -> timer getPIN{
timeout -> join J1 -> end f;
regular -> X resp -> end s;
}
start startPoint -> getPIN

}
}
..................................................................................................................
Also, if there is any way to change the Qualified name to something which has the most outer node (here a map) and most internal node only (J3). For example, TL.J3 instead of Example.TL.startPoint.J3
I know we can override qualifiedName and return QualifiedName.create(outer node name, inner node name) but how to get the most outer node name? eContainer() only gives the direct parent and we cannot go up the hierarchy as we don't know the levels of the entire hierarchy.
  • Attachment: MyDsl.xtext
    (Size: 1.59KB, Downloaded 117 times)
Re: Cannot be resolved [message #1763521 is a reply to message #1763519] Wed, 17 May 2017 00:30 Go to previous messageGo to next message
Eclipse UserFriend
EcoreUtil2.getContainerOfType / using a while loop on eContainer
Re: Cannot be resolved [message #1763562 is a reply to message #1763521] Wed, 17 May 2017 09:02 Go to previous messageGo to next message
Eclipse UserFriend
Okay thanks for help. I used EcoreUtils2.
Could you also check on the timer reference part? I did everything similar to join but I feel somehow the Xtext way is wrong for making a reference.
Re: Cannot be resolved [message #1763565 is a reply to message #1763562] Wed, 17 May 2017 09:13 Go to previous messageGo to next message
Eclipse UserFriend
whats the issue with the timerref?
Re: Cannot be resolved [message #1763566 is a reply to message #1763565] Wed, 17 May 2017 09:14 Go to previous messageGo to next message
Eclipse UserFriend
In my example model, getPIN shows an error "getPIN cannot be resolved".
Its used in another path with a different startpoint.
Re: Cannot be resolved [message #1763573 is a reply to message #1763566] Wed, 17 May 2017 10:24 Go to previous messageGo to next message
Eclipse UserFriend
a timer is no ReferencedEnd =>

ReferencedEnd: OrJoin | TimerInPath | Timer;
Re: Cannot be resolved [message #1763582 is a reply to message #1763573] Wed, 17 May 2017 11:45 Go to previous messageGo to next message
Eclipse UserFriend
Yes, only a TImerInPath is.. which then refers to Timer by -

TimerInPath: '.trigger' refTimerEnd=[Timer| QualifiedName] ;

In other words, I need to refer to TImer via TimerInPath. For e.g.
when i refer to timer, it should be like in red below:

start startPoint -> .trigger getPIN




So i don't want to have a Timer in ReferencedEnd but only TimerInPath.
Re: Cannot be resolved [message #1763587 is a reply to message #1763582] Wed, 17 May 2017 12:22 Go to previous messageGo to next message
Eclipse UserFriend
dont get that

TimerInPath is used nowhere
Re: Cannot be resolved [message #1763588 is a reply to message #1763587] Wed, 17 May 2017 12:43 Go to previous messageGo to next message
Eclipse UserFriend
Okay. So TimerInPath is a kind of ReferencedEnd you see.

ReferencedEnd: OrJoin | TimerInPath ;

and is the last rule in my xtext. defined as:

TimerInPath: '.trigger' refTimerEnd=[Timer| QualifiedName] ;

where it makes a reference to Timer by refTimerEnd= [Timer| QualifiedName]


So I want to refer to timer (getPIN) in my example model which is:

URNModel Example

UCM{


map TL {
start startPoint3 -> timer getPIN{
timeout -> join J1 -> end f;
regular -> X resp -> end s;
}
start startPoint -> .trigger getPIN

}


}
Re: Cannot be resolved [message #1763589 is a reply to message #1763588] Wed, 17 May 2017 12:47 Go to previous messageGo to next message
Eclipse UserFriend
start startPoint -> .trigger getPIN is verboten in the grammar you posted

maybe you have a different grammar now.

but if you want to reference a reference you need something like

def QualifiedName qualifiedName(TimerInPath t) {
val name = NodeModelUtils.findNodesForFeature(t, MyDslPackage.Literals.TIMER_IN_PATH__REF_TIMER_END).head.text.trim
System.err.println(name)
return qnc.toQualifiedName(name)
}
Re: Cannot be resolved [message #1763596 is a reply to message #1763589] Wed, 17 May 2017 13:39 Go to previous messageGo to next message
Eclipse UserFriend
Thanks. I tried this but it never calls this overridden method when i change getPIN (i.e. the println statement is not printed). It does call this method when i pass in Timer instead of TimerInPath.

i.e def QualifiedName qualifiedName(Timer t) instead of
def QualifiedName qualifiedName(TimerInPath t) {

but then NodeModelUtils.findNodesForFeature(t, TurnPackage.Literals.TIMER_IN_PATH__REF_TIMER_END) will return me an empty list.
Re: Cannot be resolved [message #1763597 is a reply to message #1763596] Wed, 17 May 2017 13:41 Go to previous messageGo to next message
Eclipse UserFriend
Can you please give me the actuall grammar
Re: Cannot be resolved [message #1763600 is a reply to message #1763597] Wed, 17 May 2017 13:57 Go to previous messageGo to next message
Eclipse UserFriend
I have attached the grammar (MyDsl.xtext) and example model is below:

URNModel Example

UCM{
map TL {
start startPoint3 -> timer getPIN{
timeout -> join J1 -> end f;
regular -> X resp -> end s;
}
start startPoint -> .trigger getPIN
}
}

  • Attachment: MyDsl.xtext
    (Size: 1.59KB, Downloaded 150 times)
Re: Cannot be resolved [message #1763601 is a reply to message #1763600] Wed, 17 May 2017 14:03 Go to previous messageGo to next message
Eclipse UserFriend
TimerInPath is still uncalled in the grammar

[Updated on: Wed, 17 May 2017 14:04] by Moderator

Re: Cannot be resolved [message #1763602 is a reply to message #1763601] Wed, 17 May 2017 14:06 Go to previous messageGo to next message
Eclipse UserFriend
see the color (gray)
Re: Cannot be resolved [message #1763604 is a reply to message #1763602] Wed, 17 May 2017 14:07 Go to previous messageGo to next message
Eclipse UserFriend
Doesn't ReferencedEnd: OrJoin | TimerInPath ; mean that ReferencedEnd could be either an OrJoin or TimerInPath?

How can we call this then? I want this to be a ReferencedEnd.
Re: Cannot be resolved [message #1763605 is a reply to message #1763604] Wed, 17 May 2017 14:10 Go to previous message
Eclipse UserFriend
yes but ReferencedEnd is uncalled as well. you just reference it, but nowhere "contain" it
Previous Topic:Correct usage of 'import'/'include' of files
Next Topic:Building for Eclipse and LSP
Goto Forum:
  


Current Time: Thu Jul 03 09:01:12 EDT 2025

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

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

Back to the top