Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cannot be resolved
Cannot be resolved [message #1763493] Tue, 16 May 2017 17:11 Go to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 17:22]

Report message to a moderator

Re: Cannot be resolved [message #1763497 is a reply to message #1763493] Tue, 16 May 2017 17:47 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

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 17:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
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
	}
	
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763499 is a reply to message #1763497] Tue, 16 May 2017 17:51 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 18:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
if you want to use the qualified name it would be

start startPoint1 -> Example.TL.startPoint3.J3


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763519 is a reply to message #1763500] Wed, 17 May 2017 03:19 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 105 times)
Re: Cannot be resolved [message #1763521 is a reply to message #1763519] Wed, 17 May 2017 04:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
EcoreUtil2.getContainerOfType / using a while loop on eContainer

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763562 is a reply to message #1763521] Wed, 17 May 2017 13:02 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 13:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
whats the issue with the timerref?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763566 is a reply to message #1763565] Wed, 17 May 2017 13:14 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 14:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
a timer is no ReferencedEnd =>

ReferencedEnd: OrJoin | TimerInPath | Timer;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763582 is a reply to message #1763573] Wed, 17 May 2017 15:45 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 16:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
dont get that

TimerInPath is used nowhere


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763588 is a reply to message #1763587] Wed, 17 May 2017 16:43 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 16:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
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)
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763596 is a reply to message #1763589] Wed, 17 May 2017 17:39 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 17:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Can you please give me the actuall grammar

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763600 is a reply to message #1763597] Wed, 17 May 2017 17:57 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 133 times)
Re: Cannot be resolved [message #1763601 is a reply to message #1763600] Wed, 17 May 2017 18:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
TimerInPath is still uncalled in the grammar

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 17 May 2017 18:04]

Report message to a moderator

Re: Cannot be resolved [message #1763602 is a reply to message #1763601] Wed, 17 May 2017 18:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
see the color (gray)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cannot be resolved [message #1763604 is a reply to message #1763602] Wed, 17 May 2017 18:07 Go to previous messageGo to next message
Ruchika Kumar is currently offline Ruchika KumarFriend
Messages: 50
Registered: January 2017
Member
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 18:10 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
yes but ReferencedEnd is uncalled as well. you just reference it, but nowhere "contain" it

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Correct usage of 'import'/'include' of files
Next Topic:Building for Eclipse and LSP
Goto Forum:
  


Current Time: Fri Sep 20 06:00:42 GMT 2024

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

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

Back to the top