35
35
import org .eclipse .jface .util .PropertyChangeEvent ;
36
36
import org .eclipse .swt .SWT ;
37
37
import org .eclipse .swt .widgets .Shell ;
38
+ import org .eclipse .textmate4e .ui .text .TMPresentationReconciler ;
38
39
import org .eclipse .ui .texteditor .ITextEditor ;
39
40
import org .eclipse .wst .jsdt .internal .ui .JavaScriptPlugin ;
40
41
import org .eclipse .wst .jsdt .internal .ui .text .AbstractJavaScanner ;
57
58
import ts .eclipse .ide .ui .implementation .TypeScriptImplementationDialog ;
58
59
import ts .eclipse .ide .ui .outline .TypeScriptElementProvider ;
59
60
import ts .eclipse .ide .ui .outline .TypeScriptQuickOutlineDialog ;
61
+ import ts .eclipse .ide .ui .preferences .TypeScriptUIPreferenceConstants ;
60
62
import ts .eclipse .ide .ui .utils .EditorUtils ;
61
63
import ts .resources .ITypeScriptFile ;
62
64
@@ -78,11 +80,14 @@ public class TypeScriptSourceViewerConfiguration extends JavaScriptSourceViewerC
78
80
*/
79
81
private AbstractJavaScanner jsxScanner ;
80
82
83
+ private IPreferenceStore preferenceStore ;
84
+
81
85
public TypeScriptSourceViewerConfiguration (IColorManager colorManager , IPreferenceStore preferenceStore ,
82
86
ITextEditor editor , String partitioning ) {
83
87
super (colorManager , preferenceStore , editor , partitioning );
84
88
fCodeScanner = new TypeScriptCodeScanner (colorManager , preferenceStore );
85
89
jsxScanner = new JSXScanner (colorManager , preferenceStore );
90
+ this .preferenceStore = preferenceStore ;
86
91
87
92
}
88
93
@@ -335,14 +340,17 @@ else if (IJavaScriptPartitions.JAVA_CHARACTER.equals(contentType)
335
340
336
341
@ Override
337
342
public IPresentationReconciler getPresentationReconciler (ISourceViewer sourceViewer ) {
343
+ if (preferenceStore .getBoolean (TypeScriptUIPreferenceConstants .USE_TEXMATE_FOR_SYNTAX_COLORING )) {
344
+ // Advanced Syntax coloration with TextMate
345
+ return new TMPresentationReconciler ();
346
+ }
347
+ // Use classic Eclipse ITokenScaner.
338
348
PresentationReconciler reconciler = (PresentationReconciler ) super .getPresentationReconciler (sourceViewer );
339
-
340
349
DefaultDamagerRepairer dr = new DefaultDamagerRepairer (getJSXScanner ());
341
350
reconciler .setDamager (dr , IJSXPartitions .JSX );
342
351
reconciler .setRepairer (dr , IJSXPartitions .JSX );
343
352
344
353
return reconciler ;
345
-
346
354
}
347
355
348
356
/**
@@ -366,7 +374,8 @@ protected RuleBasedScanner getJSXScanner() {
366
374
367
375
public boolean affectsTextPresentation (final PropertyChangeEvent event ) {
368
376
return super .affectsTextPresentation (event ) || fCodeScanner .affectsBehavior (event )
369
- || jsxScanner .affectsBehavior (event );
377
+ || jsxScanner .affectsBehavior (event )
378
+ || TypeScriptUIPreferenceConstants .USE_TEXMATE_FOR_SYNTAX_COLORING .equals (event .getProperty ());
370
379
}
371
380
372
381
@ Override
0 commit comments