Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Preserving single and mult-line comments from separate editor when an EObject is deleted
Preserving single and mult-line comments from separate editor when an EObject is deleted [message #659975] Wed, 16 March 2011 13:07 Go to next message
drew frantz is currently offline drew frantzFriend
Messages: 340
Registered: July 2009
Senior Member
Our grammar defines C++ style single and multiline comments // , /* */ .
While performing certain operations on the emf items in our non-text based
editor (deleting the EMF EObject), the comments associated with the deleted
EObject also gets removed as well. I guess what I am looking for is a way to
extract these from the current node associated with the EObject, and them
and place them back at a node near the one that is removed.

1) Step 1 extract the comment(s) for a given EMF element
2) Step 2 find a node near the one being deleted
3) Step 3 place the extracted comments on the nearest node.


/* This gets removed if I delete myFoo, maybe this is a comment for the
entire file that I want to keep */
create myFoo; // this also gets removed

create myBar;

create myFooBar;
Re: Preserving single and mult-line comments from separate editor when an EObject is deleted [message #659983 is a reply to message #659975] Wed, 16 March 2011 13:45 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
As you're already talking about the node model, I guess you figured out
how to extract the comment (it's a leaf node with isHidden()==true)

You should not modify the node model, this should always be oly the
parser's task. Better remember the offset of the comment and restore
them at the same position after the serializer has done its work.


Am 16.03.11 14:07, schrieb Drew:
> Our grammar defines C++ style single and multiline comments // , /* */ .
> While performing certain operations on the emf items in our non-text
> based editor (deleting the EMF EObject), the comments associated with
> the deleted EObject also gets removed as well. I guess what I am looking
> for is a way to extract these from the current node associated with the
> EObject, and them and place them back at a node near the one that is
> removed.
>
> 1) Step 1 extract the comment(s) for a given EMF element
> 2) Step 2 find a node near the one being deleted
> 3) Step 3 place the extracted comments on the nearest node.
>
>
> /* This gets removed if I delete myFoo, maybe this is a comment for the
> entire file that I want to keep */
> create myFoo; // this also gets removed
>
> create myBar;
>
> create myFooBar;


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Mapping a grammar rule to possible resulting EClasses
Next Topic:Problem with programmatically triggering validation
Goto Forum:
  


Current Time: Fri Apr 26 22:09:27 GMT 2024

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

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

Back to the top