Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext and object identity with reparsed parts(exotic use of xtext with editing teneo-stored _instances_ at run-time)
xtext and object identity with reparsed parts [message #1131424] Thu, 10 October 2013 13:57 Go to next message
Thomas Steinbach is currently offline Thomas SteinbachFriend
Messages: 13
Registered: March 2013
Junior Member
Hello,

the intended use of xtext differs in 2 subjects from other usecases:
1) the data isn't stored in files but in a database with teneo/hibernate (so object-identity is an issue)
2) xtext-editor is used at runtime, so you change your _instances_ of classes as you would with a graph-editor or a form-based userinterface (using trees, list and other controls)

Background:
The problem arises because editing the instances with graphical editors or form-based userinterfaces are cumbersome for huge changes and so the question "why don't you edit your instances the same way as you edit your code/classes" seems legitim.

But as posted in this message by Jan, XText doesn't preserve object identity of reparsed elements, and the problem starts.

So for the question where to go, there come up 2 aspects:
1) Load the data from the database manually, generate a text-representation and edit this with a xtext-editor, then estimate the delta to do the real changes. But this works only until you need semantics as in the code proposals, or will there not be a problem as I think?

2) How realistic and useful would it be to preserve object-identity?
Two examples for the input "myVar = age + 2"
- user types between "my" and "Var" -> this will be a renaming action of the variable, but the instance of the class variable will be the same just with a new value for the attribute "name"
- user types "* 7" at the end -> the original factor 2 of the sum will be replaced with "2*7"
- maybe a lot of pitfalls I don't see

- So will it be feasible to use xtext for editing instances stored in database?
- What workarounds would be possible?
For example: don't use xtext to edit the instance represented as a whole with text, but use xtext like a console to edit the instance piecewise.
- maybe there are other good variants of editing data (graph-based, form-based and via text, are the variants crossed my mind)

I am really thankful for any help and experience in this direction.

With best regards,
Tom

[Updated on: Thu, 10 October 2013 13:59]

Report message to a moderator

Re: xtext and object identity with reparsed parts [message #1149540 is a reply to message #1131424] Tue, 22 October 2013 06:30 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Comments inline.
Am 10/10/13 3:57 PM, schrieb Thomas Steinbach:
> the intended use of xtext differs in 2 subjects from other usecases:
> 1) the data isn't stored in files but in a database with teneo/hibernate
> (so object-identity is an issue)
> 2) xtext-editor is used at runtime, so you change your _instances_ of
> classes as you would with a graph-editor or a form-based userinterface
> (using trees, list and other controls)

I've seen people trying this before but never with success.

> Background:
> The problem arises because editing the instances with graphical editors
> or form-based userinterfaces are cumbersome for huge changes and so the
> question "why don't you edit your instances the same way as you edit
> your code/classes" seems legitim.

Yes, that can be more convenient at times :-)

> But as posted in this
> http://www.eclipse.org/forums/index.php/mv/msg/500067/1082895/#msg_1082895
> by Jan, XText doesn't preserve object identity of reparsed elements, and
> the problem starts.
>
> So for the question where to go, there come up 2 aspects:
> 1) Load the data from the database manually, generate a
> text-representation and edit this with a xtext-editor. But this works
> only until you need semantics as in the code proposals, or will there
> not be a problem as I think?

That should work. The real problems start when you want to merge the
changes back into the existing model.

>
> 2) How realistic and useful would it be to preserve object-identity?

Besides that it is technically very challenging I believe that it is
just wrong to treat everything as an entity. A lot of objects in a
parse tree are just value object. That is they don't have an identity as
they are just a value. Number literals and all kind of references fall
into this category.
The elements I'd consider having an identity usually have a name.

> Two examples for the input "myVar = age + 2"
> - user types between "my" and "Var" -> this will be a renaming action of
> the variable, but the instance of the class variable will be the same
> just with a new value for the attribute "name"
> - user types "* 7" at the end -> the original factor 2 of the sum will
> be replaced with "2*7"
> - maybe a lot of pitfalls I don't see

Yes.

>
> - So will it be feasible to use xtext for editing instances stored in
> database?

Some people tried to use EMFCompare to compare the old AST with the
edited one, and from that infer a good enough reconciling strategy.

But I'm not sure if it really is "good enough".

> - What workarounds would be possible? For example: don't use xtext to
> edit the instance represented as a whole with text, but use xtext like a
> console to edit the instance piecewise.
> - maybe there are other good variants of editing data (graph-based,
> form-based and via text, are the variants crossed my mind)

IMHO the best would be to store the data as text in the database and use
the parser to create an object model from that.

Sven

--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:Dependencies for new API
Next Topic:Code generation problem
Goto Forum:
  


Current Time: Tue Apr 16 14:23:48 GMT 2024

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

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

Back to the top