scala-ide/scala-ide — pull request #309 by dotta (2013-02-11 15:29:30+00:00)
Title:  Faster and slicker semantic highlighting

* The initial implementation of semantic highglighting exposed several race
conditions. In a nutshell, the issue was that the UI Thread and the semantic
reconciler Job could be stepping on each other and determine an incorrect
sequence of positions to be stored in the document's model. The issue was that
the semantic reconciler was allowed to update the positions stored in the
document model *outside of the UI Thread*. And, what is worse, the stored
positions could have been wrong (i.e., not based on a valid editor's state)!
Why? Because every time the semantic reconciler kicks-in, the freshly computed
positions are invalid if the user started typing before the semantic
reconcilation run was over. The solution is to confine access to the
highlighted positions to the UI Thread. Please, read the
``scala.tools.eclipse.semantichighlighting.PositionsTracker``'s ScalaDoc for
more details.

* An additional fact is that I'm no longer using the document's model to store
the highlighted positions. This is not needed, and it really doesn't provide
any benefit (rather, it can be costly, since the document synchronizes access
to the underlying position's map when adding/removing positions). And I should
also point out that is really easy to add the missing logic for storing the
positions in the document's model, if in the future it turns out we need/want
to do so.

* Cache highlighting styles instead of creating the during
``TextPresentationEditorHighlighter.ApplyHighlightingTextPresentationChanges.applyTextPresentation``.
This optimization has major consequence on the user's experience. I should also
point out that ``ScalaSyntaxClass`` and ``SymbolTypes`` are quite messy and
should be improved. However, I think this should be tackled in a different PR
(this is somewhat related to Re #1001489).

* Disabling semantic highlighting in the preferences now refreshes currently
opened editors. Fixes #1001507

* Changing semantic highlighting style's preferences now refreshes the
currently opened editors. Fixes #1001508

* Created a ``UiThread`` trait needed for testing code that needs to be run
within the UI Thread.