Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » viewing AST updates in DSL editor
viewing AST updates in DSL editor [message #1321796] Tue, 29 April 2014 14:02 Go to next message
Davy Maes is currently offline Davy MaesFriend
Messages: 6
Registered: April 2014
Junior Member
I have created a DSL which allows me to create instances of myProperty and allow me to create a myDependency between two myProperty instances. Each myProperty has an attribute 'value' of type float. For more info, see 'my language description below'.

What I want to do:
if I create a dependency between two myProperties in the DSL, then I want the editor to calculate the value of the target myProperty.

What I currently do is:
I hook in using the validator (probably not the best place, I know), that is a write a validation rule in which I update the setValue operation on the applicable myProperty. The problem is that the value of that myProperty is not updated in my DSL file. Is there any way to get this done?


my language description is as follows:
Model returns Model:
{Model}
'Model'
'{'
('properties' '{' properties+=myProperty ( "," properties+=myProperty)* '}' )?
('dependencies' '{' dependencies+=myDependency ( "," dependencies+=myDependency)* '}' )?
'}';


myProperty returns myProperty:
'myProperty'
'{'
'value' value=EFloat
'}';

myDependency returns myDependency:
'myDependency'
'{'
'source' source=[myProperty|EString]
'target' target=[myProperty|EString]
'}';

EFloat returns ecore::EFloat:
'-'? INT? '.' INT (('E'|'e') '-'? INT)?;

EString returns ecore::EString:
STRING | ID;
Re: viewing AST updates in DSL editor [message #1321915 is a reply to message #1321796] Tue, 29 April 2014 15:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi what about iderivedstatecomputer

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: viewing AST updates in DSL editor [message #1323237 is a reply to message #1321915] Wed, 30 April 2014 06:47 Go to previous messageGo to next message
Davy Maes is currently offline Davy MaesFriend
Messages: 6
Registered: April 2014
Junior Member
hello Christian,

thanks for the quick reply.
If I understand it correctly, iderivedstatecomputer is only a (better) alternative for plugging in my computation.
(I looked for instance at http://www.eclipse.org/forums/index.php/mv/msg/468114/1031550/#msg_1031550)

The main problem I face is that my model.dsl is not updated on the fly. In contrast with the work shown at http://www.eclipse.org/forums/index.php/mv/msg/468114/1031550/#msg_1031550, I want not to generate new files, but I want to update my existing model.dsl

In the short example below, dependency1 specifies that the value of property2 should be the same as the value of property1. So I want to 'compute' the value for property2 and I want that my model.mydsl is updated such that it afterwards shows:
property2=2.0

Example model of a model created with my DSL:
Model myModel{
properties {
property1=2.0,
property2=4.0
}
dependencies{
dependency1(source property1, target property2)
}
}
Re: viewing AST updates in DSL editor [message #1323354 is a reply to message #1323237] Wed, 30 April 2014 08:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i am still no sure what you are doing. can you please elaborate why you do this calculation
(and dont do a derived property)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: viewing AST updates in DSL editor [message #1327450 is a reply to message #1323354] Fri, 02 May 2014 06:54 Go to previous messageGo to next message
Davy Maes is currently offline Davy MaesFriend
Messages: 6
Registered: April 2014
Junior Member
I don't define derived property in my domain model, because the fact that the value of a property (instance of myProperty) is derived depends on the modeled dependency (instance of myDependency) which is defined in the DSL.

I guess that you have other possibilities to specify this in a domain model, however, the main point is that I want to show the user the calculated value of the derivation. Refer to UML tools where you are able to calculate property values and show it to the user in the same UML model and UML editor.
Re: viewing AST updates in DSL editor [message #1327596 is a reply to message #1327450] Fri, 02 May 2014 08:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i dont know any good point to hook in for that

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: viewing AST updates in DSL editor [message #1327668 is a reply to message #1327596] Fri, 02 May 2014 09:18 Go to previous messageGo to next message
Davy Maes is currently offline Davy MaesFriend
Messages: 6
Registered: April 2014
Junior Member
If I look at the current xtext features, in case of a rename (refactor), also the references are updated in the .dsl files itself. This seems to be something similar to what I need...
Re: viewing AST updates in DSL editor [message #1327802 is a reply to message #1327668] Fri, 02 May 2014 10:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

the question is to find a propert hook,
the transformation and serialilization is not the problem. i dont know if it works to hook into http://www.eclipse.org/forums/index.php/t/282129/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[xtend] . vs ::
Next Topic:Automatic handling of TODO comments
Goto Forum:
  


Current Time: Thu Apr 18 08:28:16 GMT 2024

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

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

Back to the top