Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » changing semantic model at runtime(way to add EObject's at runtime)
changing semantic model at runtime [message #690233] Wed, 29 June 2011 08:38 Go to next message
amazuzu  is currently offline amazuzu Friend
Messages: 17
Registered: May 2011
Junior Member
Imagine we have a Statemachine ECore model.

This semantic model defined in one (for simplicity) file foo.statemachine

How do I can add some predefined states, events or commands at runtime (e.g from some xml or directly in Java code) so that I could see them in content assist along with existing entities.



Re: changing semantic model at runtime [message #690237 is a reply to message #690233] Wed, 29 June 2011 08:47 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

the scenario is not quite clear (in any case search for Xtext default imports). Do you want every state machine to actually *contain* predefined states or do you want to be able to refer to them (cross reference although they are defined in a completely different state machine)?
Do you want to have templates so that you can easily create a predefined state (see documentation on code templates and the somewhat outdated blog entry).
For general code completion also see the documentation and search for xtext content assist.

In other words, be more precise about what you actually want to achieve.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: changing semantic model at runtime [message #690245 is a reply to message #690237] Wed, 29 June 2011 09:11 Go to previous messageGo to next message
amazuzu  is currently offline amazuzu Friend
Messages: 17
Registered: May 2011
Junior Member
Thanks for immediate response

I try to explain in other words.
I have two files foo.statemachine and bar.statemachine.
Now in content assist I see entities from both files that's ok.
But how I could add at runtime all entities from e.g foo.xml (contains all entities from foo.statemachine but in xml format)
so that I could see them in content assist (note, now I haven't foo.statemachine)

sorry, may be I can't properly explain.

Yes, I wanna see them in every *.statemachine and I don't need any template.


[Updated on: Wed, 29 June 2011 10:03]

Report message to a moderator

Re: changing semantic model at runtime [message #690277 is a reply to message #690245] Wed, 29 June 2011 10:00 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
This still does not explain the use case. When you talk about a state being visible in content assist, I assume you mean the content assist for a cross reference. A cross reference goes to a particular type and I assume that you use a type specific to the .statemachine-language. So even if you adapt content assist to show all entities from foo.xml, the reference could not be resolved.
The question remains, should all statemachines conain a "copy" of the elements from foo.xml or should they all refer to the same instance of a foo.statemachine.

In the second case, use the library-Approach: transform foo.xml into a foo.statemachine, which can then be referred to out of the box. In the first one, a possibility might be to add states to the current model before linking. In order to do that you can bind your own Linker implementation (e.g. by extending and binding the LazyLinker) and override the beforeModelLinked method (adding states here).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: changing semantic model at runtime [message #690298 is a reply to message #690277] Wed, 29 June 2011 10:27 Go to previous message
amazuzu  is currently offline amazuzu Friend
Messages: 17
Registered: May 2011
Junior Member
Thanks. seems that is what I need.

About use case.
Currently I implementing Flex automation testing tool based on Eclipse RCP, XText.

And I try to allow user to see Flex classes and their members/getters in xtext editor.

meta.xml (containes Flex classes metadata and will be loaded after e.g 10 second after xtext editor launch)
<class name="org.foo.bar.Field">
<property name="center" type="org.foo.bar.Point" />
<property name="color" type="int" />
</class>


DSL (in xtext editor):
var fieldCenter = (@Field as org.foo.bar.Field).center;

here user state than TextInput named "Field" is an instance of class org.foo.bar.Field
I wan't to show both color and center properties in content assist after user press "." or Ctrl-Space after "."

var fieldCenter = (@Field as org.foo.bar.Field).[SHOW HERE 'COLOR' and 'CENTER']

Thanks
Previous Topic:Need some pointers setting up an xtext interpreter
Next Topic:Problems with Scoping
Goto Forum:
  


Current Time: Fri Mar 29 08:20:24 GMT 2024

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

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

Back to the top