Race conditions in AnnotationModel? Error Annotations Lost in Reconciler

I have my own Eclipse editor, and I implemented "input report errors", but from time to time my squigglies errors (using JFace annotations) do not appear or do not delay after they are deleted.

I am using MonoReconciler with my implementation of IReconcilingStrategy . During the reconcile step, I call annotationModel.replaceAnnotations to remove old errors and add new ones. In most cases, this works great. Updates are lost from time to time, and I notice the following:

  • the red mark on the left ruler disappears, but the red underscores remain
  • on the next character I type, the underline disappears

I checked in the debugger the correct annotation calculations. The underscore disappears immediately after entering a character, and not after a 500 ms mediator delay. It looks like a lost UI update / redraw.

Somewhere there must be a race condition (the mediator is working in its own thread). What am I doing wrong? I could not find the documentation for this case.

Edit: To reproduce, browse the scala-worksheet and create a new one. A type

  object Test { val m = Map( 't' -> 1 ) } 

Now edit the arrow: delete > . The disadvantage is emphasized. Enter a space, it returns. Add it back, the underline still exists until you type another space.

I fixed it by calling invalidateTextPresentation on the SourceViewer substring, but it seems to me that this is not necessary. I would like to understand how to use editor annotations correctly.

PS. Lost updates can also be seen in this screencast .

+4
source share
1 answer

It is difficult to say from afar, usually in an eclipse, any changes that affect ui must be made in the ui thread (and eclipse will not always warn about this). Usually you use Display.getDefault (). AsyncExec (...) to execute something on the ui thread, but you probably already know that. It may happen that 2 changes in the queue cause a race.

(I implemented semantic highlighting, error highlighting, etc. several times for the company I work for, Sigasi. If you can point me to your implementation, I can understand what is going wrong.)

0
source

Source: https://habr.com/ru/post/1435207/


All Articles