IXtextDocument.modify consumes all preceding white space [message #892793] |
Fri, 29 June 2012 13:31  |
Eclipse User |
|
|
|
Hi all!
I've finally made use of IXextDocument.modify( IUnitOfWork.Void<XtextResource> ). Works wonderfully! Except for one thing.
public class SaveUnitOfWork extends IUnitOfWork.Void<XtextResource> {
...
public void process(XtextResource resource) throws Exception {
...
}
...
}
When I make changes to the XtextResource's underlying EMF model, the change is reflected in the editor (yay!). However, any whitespace preceding the EObject I modify gets removed. I've tried to update my DSL's implementation of AbstractDeclarativeFormatter to fix this, but it doesn't seem to have any affect on the removal of preceding whitespace.
Does this sound familiar to anyone who has used IXtextDocument.modify(...)?
|
|
|
|
|
Re: IXtextDocument.modify consumes all preceding white space [message #893388 is a reply to message #893057] |
Tue, 03 July 2012 15:28  |
Eclipse User |
|
|
|
Hi,
internally there is the semantic model and the node model. Usually you are interested in the semantic model as it holds the typed model elements with its features. In that model information about hidden terminals (white spaces, comments etc.) is lost.
The node model contains the entire textual model file in a structured form, so that serialising the model again will result something that looks like what you started out with (in particular after changes in the model not caused by simple typing, like refactorings or application of quick fixes).
The semantic and the node model have a tight connection and the contract is that hidden terminals (e.g. white spaces) are associated with the semantic model element immediately following them.
So if you have the greetings example
the line break and space after foo! are already "part" of the second greeting.
Alex
[Updated on: Tue, 03 July 2012 15:29] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03205 seconds