package collabode.hilite;

import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingManager;
import org.eclipse.jdt.internal.ui.text.JavaColorManager;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.ui.PlatformUI;

import collabode.JavaPadDocument;

/**
 * Wrapper for {@link SemanticHighlightingManager} to operate on a {@link JavaPadDocument}.
 * Also acts as a messenger to pass along reconcile events.
 */
@SuppressWarnings("restriction")
public class PadSemanticHighlighter {
    static final JavaColorManager COLORS = new JavaColorManager(false);
    
    private final PadCompilationUnitEditor editor;
    private final PadJavaSourceViewer viewer;
    
    public PadSemanticHighlighter(final JavaPadDocument doc) {
        editor = new PadCompilationUnitEditor();
        viewer = new PadJavaSourceViewer(doc);
        
        JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(doc, IJavaPartitions.JAVA_PARTITIONING);
        
        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
            public void run() {
                editor.config.getPresentationReconciler(viewer).install(viewer); // standard highlighting
                new SemanticHighlightingManager().install(editor, viewer, COLORS, PreferenceConstants.getPreferenceStore());
            }
        });
        
        doc.addReconcileListener(editor);
    }
}

@@ -682,175 +682,211 @@
    p
-rivate final PadCompilationUnitEditor editor;%0A    private final PadJavaSourceViewer viewer;
+ublic PadSemanticHighlighter(final JavaPadDocument doc) %7B%0A        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() %7B
 %0A    
-%0A
+ 
     
+   
 public 
-PadSemanticHighlighter(final JavaPadDocument doc) %7B%0A       
+void run() %7B%0A                PadCompilationUnitEditor
  edi
@@ -931,16 +931,44 @@
         
+  
+      PadJavaSourceViewer 
 viewer =
@@ -998,33 +998,49 @@
 r(doc);%0A        
-%0A
+        %0A        
         JavaPlug
@@ -1152,25 +1152,24 @@
         
-%0A
         
 Platform
@@ -1164,104 +1164,8 @@
     
-PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() %7B%0A            public void run() %7B
 %0A   
@@ -1408,21 +1408,12 @@
     
-%7D%0A        %7D);
+    
 %0A   
@@ -1409,33 +1409,32 @@
        %0A        
-%0A
         doc.addR
@@ -1459,16 +1459,42 @@
 ditor);%0A
+            %7D%0A        %7D);%0A
     %7D%0A%7D%0A

Put all syntax highlighting setup on the UI thread