Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Path Expression Issue(Can't get Path Expression to Work)
Path Expression Issue [message #1833453] Tue, 13 October 2020 15:36 Go to next message
Benny Katchy is currently offline Benny KatchyFriend
Messages: 2
Registered: October 2020
Junior Member
I am working on a grammar that involves navigating an object graph in my custom expression language. The issue is that i keep getting this error in my scope provider
org.eclipse.xtext.linking.lazy.LazyLinkingResource$CyclicLinkingException: Cyclic resolution of lazy links : Tail.property->Tail.property in resource 'platform:/resource/model.mydsl/model/models.mydsl'. I will appreciate any help I can get, i have been on this for two weeks could get much help from Google. Below is the relevant code snippets


class Address
properties
description

class Party
properties
name : String
lastName : String
address: Address
phone: String
def contact : String = "Address: " + this.address.description // this fails
def fullName : String = this.name + " " + this.lastName // this works

Here the relevant snippet of my grammar
NavigationExpr returns Expr:
PrimaryExpr(=>
({Selection.operand=current} feature=Tail)*
)
;

Datatype:
'datatype' name=ID // for basic types like String, Integer etc
;

Class:
'class' .... // for reference type like Address etc
;

Type: Datatype | Class

Property:
name=ID ':' type=[Type | ID]
;

Tail:
'.' property=[Property | FQN] (tail=Tail)?;

Here is a snippet from my ScopeProvider
if (ref == MyDSLPackage.Literals.TAIL__PROPERTY){
val property = (ctx as Tail).property
return property.getScopeForClass
}







Re: Path Expression Issue [message #1833461 is a reply to message #1833453] Tue, 13 October 2020 19:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
did you try to adapt https://dietrich-it.de/xtext/2013/05/18/xtext-and-dot/path-expressions/

if (ref == MyDSLPackage.Literals.TAIL__PROPERTY){
val property = (ctx as Tail).property
return property.getScopeForClass
}

makes no sense. why do you read the property if you try to scope the property?
dont you want to look at {Selection.operand


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Path Expression Issue [message #1833464 is a reply to message #1833461] Tue, 13 October 2020 22:59 Go to previous messageGo to next message
Benny Katchy is currently offline Benny KatchyFriend
Messages: 2
Registered: October 2020
Junior Member
Hi Christian,
thanks for your prompt response . I have gone through your example, I see a lot similarities in what you did and in my own use case, I just can't get my scope provider called, I don't know if its the signature. Here is the relevant snippets

Type:
Datatype | Class
;

Property:
name=ID ':' type=Type
;

Selection returns Expr:
ClassRef (=>({Selection.ref=current} "." tail=[Property])*)
;

AttributeRef returns Expr:
PrimaryExpr (=>
({ClassRef.ref=current} class=[Class])
)
;

def IScope scope_Selection_tail(Selection exp, EReference ref) // not called
def IScope scope_ClassRef_class(ClassRef exp, EReference ref) // called instead
Re: Path Expression Issue [message #1833468 is a reply to message #1833464] Wed, 14 October 2020 06:30 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
scope_ methods only work if your scope provider inherits from
AbstractDeclarativeScopeProvider

if not you have to if else on the parameters of getScope e.g.

	override getScope(EObject context, EReference reference) {
		if (context instanceof DotExpression) {
			return scope_dotexpression_tail(context, reference)
		}
		super.getScope(context, reference)
	}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Separating New Wizards and File Templates
Next Topic:refresh dependecies before importing the project on eclipse
Goto Forum:
  


Current Time: Fri Apr 26 02:47:55 GMT 2024

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

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

Back to the top