Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping a feature call
Scoping a feature call [message #1759025] Wed, 05 April 2017 11:55 Go to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
Hello Christian,

I would like to introduce a new feature to my DSL, but I have tried tracing scoping for XBase but I don't know where the job is done yet.

In my grammar a Configurable is a collection of Property.
Assignments are defined :

Assignment returns xbase::XExpression:
	{Assignment} 'set' address=DotExpression ('@' attribute=[Attribute] ('.' key=ID)?)? op=('='|':=') expression=(XExpression|XBlockExpression|Measure) 
;
DotExpression returns Ref:
    PropertyRef ({DotExpression.ref=current}  op=("."|"?.") tail=[Property])*
;
PropertyRef returns Ref:
	{PropertyRef} property=[Property]
;


So ultimately, it resolves to a Property followed by other '.' and other Property
Scoping is done by looking at the surrounding container (Configurable) and getting their properties.

What I would like to do, is replace it with something like :

Assignment returns xbase::XExpression:
	{Assignment} 'set' (head=XFeatureCall '.')? address=DotExpression ('@' attribute=[Attribute] ('.' key=ID)?)? op=('='|':=') expression=(XExpression|XBlockExpression|Measure) 
;


I don't know if that is possible. The idea is that currently the context is implicitly the "this" for the Configurable being edited.
It gets the list of Property in "this", but it would convenient to get it from an "it" in a => lambda, or any direct call that returns a Configurable.

Examples

set callThatGetsAConfiguable.innerproperty = 294

aConfigurable => [
      set aPropertyOfAConfigurable= 'asdfasdf'
      set anotherProperty = 430.0
]


Any suggestion ? I don't even know where to start with that.

Thanks !
Re: Scoping a feature call [message #1759027 is a reply to message #1759025] Wed, 05 April 2017 12:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
what about turning set xxxx = yyyy into an xassignment rule/type and reuse the existing xbase stuff that already works out of the box?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Scoping a feature call [message #1759034 is a reply to message #1759027] Wed, 05 April 2017 12:36 Go to previous messageGo to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
Interesting... considering my RHS do you think I can coerce my existing rule into an XAssignement ? Because the rules for XAssignement value are different thatn what I need.

Re: Scoping a feature call [message #1759036 is a reply to message #1759034] Wed, 05 April 2017 12:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
i think so, but i cannot give you detailed advice on this. never customized that places

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Scoping a feature call [message #1759037 is a reply to message #1759036] Wed, 05 April 2017 13:05 Go to previous messageGo to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
I thought about the way I first explained it and it's slightly wrong. The feature call would result in getting an object of type Property. That would work pretty much everywhere. don't need to add a head reference.
I will try making it an XAssignment first. Keep you posted.
Re: Scoping a feature call [message #1759041 is a reply to message #1759037] Wed, 05 April 2017 13:45 Go to previous messageGo to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
I had some problems with the XAssignment, but this is getting close :

Assignment returns xbase::XExpression:
	{Assignment} 
	'set' address=[types::JvmIdentifiableElement] ('@' attribute=[modelDsl::Attribute] ('.' key=ID)?)? 
	op=('='|':=') 
	value=(XExpression|XBlockExpression|Measure) 
;


Now, it shows all the elements callable in the class, which is nice. But it won't show anything defined earlier in the XBlockExpression. like

{ 
      val p = someProperty
      // control space here gives all the variables/calls possible in the class PLUS the "p" val
      set  // control space here gives all the variables calls like above but no p
}


so clearly some scoping deal is going on. any way I can link them that you can think of ?

Thanks
Re: Scoping a feature call [message #1759042 is a reply to message #1759041] Wed, 05 April 2017 14:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
this has todo with type computation etc what xbase does.

=> if yiu would actually create xassignment code it would reuse the existing code

(you can have a look at xbasetypecomputer and xbasescopeprovider(featurescopes classes etc -> i cannot give you an exact line since i dont know)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Scoping a feature call [message #1759046 is a reply to message #1759025] Wed, 05 April 2017 14:36 Go to previous messageGo to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
I'll have a look. Thanks
Re: Scoping a feature call [message #1759070 is a reply to message #1759046] Wed, 05 April 2017 20:04 Go to previous message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
OK. Status report Wink

The XAssignment doesn't work at all, it assume a million things about the rule.
For once, I really properly understood the scoping. So this is how I did it:

Assignment returns xbase::XExpression:
	{Assignment} 
	'set' feature=[types::JvmIdentifiableElement|FeatureCallID] ('.' address=DotExpression)? ('@' attribute=[modelDsl::Attribute] ('.' key=ID)?)? 
	op=('='|':=') 
	value=(XExpression|XBlockExpression|Measure) 
;


So it's still just an XExpression. But in the scoping for Assignment__feature what I do is I create a FilteringScope on getScope(context, XbasePackage.Literals.XABSTRACT_FEATURE_CALL_FEATURE)

In the filter I can remove all features that are not Property references.

Thanks for your suggestions

Daniel

[Updated on: Wed, 05 April 2017 20:08]

Report message to a moderator

Previous Topic:Limiting cross-reference to a single file
Next Topic:UI locks up when XtextReconciler and Hover run concurrently
Goto Forum:
  


Current Time: Wed Dec 04 22:07:33 GMT 2024

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

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

Back to the top