I want to write an eclipse plugin for my computer science lecturer. It's a custom editor with an xml based file format.
I've implemented syntax highlighting and other stuff. But I stuck when it comes to the usage of annotations/marker to show invalid content.
This is how it looks like, if the content is valid:
image-upload.de/image/aPcsaa/6c799a671c.png
This is how it looks like, if the content is invalid:
image-upload.de/image/4TdooQ/04d662f397.png
NOTE: would like to use direct images here, but I'm not allowed to... (thanks to this great restriction)
As you can see, invalid attributes will get marked, but the problem is, the whole formatting seems to be lost between these annotations.
I use org.eclipse.jface.text.reconciler.Reconciler
for delayed parsing of the content to create the document model. The model is used to format the text and display annotations. All this happens in the void void process(DirtyRegion dirtyRegion)
method of the .
For text formatting I use <ITextViewer>.changeTextPresentation(textAttributes, false)
and for annotation handling I use
IAnnotationModel annotationModel = <ISourceViewer>.getAnnotationModel();
IAnnotationModelExtension annotationModelExtension = (IAnnotationModelExtension) annotationModel;
annotationModelExtension.replaceAnnotations(oldAnnotations, newAnnotations);
Since the does not use the swt thread I have to use this construct to avoid exceptions:
<ITextViewer>.getTextWidget().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
<ITextViewer>.changeTextPresentation(textAttributes, false);
updateAnnotations(nodes);
}
});
By the way and are meant as the same viewer object.
As annotation type I've testet: org.eclipse.ui.workbench.texteditor.spelling
and some others, also custom types, but all with the same result.
I'm not quite sure, what I'm doing wrong, could it be because it is all in a single call?
I hope someone can help me with this problem.
Thank you in advance.
[Updated on: Sun, 14 April 2013 10:24] by Moderator