Skip to content

Commit 4956492

Browse files
committed
Integrates textmate.java. See
#114
1 parent 5da4a9b commit 4956492

19 files changed

+7079
-11
lines changed

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/META-INF/MANIFEST.MF

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Require-Bundle: org.eclipse.core.runtime,
3333
org.eclipse.core.filesystem,
3434
org.eclipse.ui.forms,
3535
org.eclipse.ltk.core.refactoring,
36-
org.eclipse.ltk.ui.refactoring
36+
org.eclipse.ltk.ui.refactoring,
37+
org.eclipse.textmate4e.ui
3738
Bundle-ActivationPolicy: lazy
3839
Bundle-Activator: ts.eclipse.ide.jsdt.internal.ui.JSDTTypeScriptUIPlugin
3940
Import-Package: com.eclipsesource.json;version="[0.9.4,0.9.5)"

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/build.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ bin.includes = META-INF/,\
66
plugin.xml,\
77
icons/,\
88
css/,\
9-
templates/
9+
templates/,\
10+
syntaxes/

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/plugin.xml

+23
Original file line numberDiff line numberDiff line change
@@ -677,4 +677,27 @@
677677
</include>
678678
</extension>
679679

680+
<extension
681+
point="org.eclipse.textmate4e.core.grammars">
682+
<grammar
683+
scopeName="source.ts"
684+
path="./syntaxes/TypeScript.tmLanguage.json" >
685+
</grammar>
686+
<grammar
687+
scopeName="source.tsx"
688+
path="./syntaxes/TypeScriptReact.tmLanguage.json" >
689+
</grammar>
690+
<scopeNameContentTypeBinding
691+
contentTypeId="ts.eclipse.ide.core.tsSource"
692+
scopeName="source.ts">
693+
</scopeNameContentTypeBinding>
694+
<scopeNameContentTypeBinding
695+
contentTypeId="ts.eclipse.ide.core.tsxSource"
696+
scopeName="source.tsx">
697+
</scopeNameContentTypeBinding>
698+
<scopeNameContentTypeBinding
699+
contentTypeId="ts.eclipse.ide.core.jsxSource"
700+
scopeName="source.tsx">
701+
</scopeNameContentTypeBinding>
702+
</extension>
680703
</plugin>

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/src/ts/eclipse/ide/jsdt/internal/ui/editor/JavaScriptLightWeightEditor.java

+5
Original file line numberDiff line numberDiff line change
@@ -603,4 +603,9 @@ protected void setPreferenceStore(IPreferenceStore store) {
603603
if (getSourceViewer() instanceof JavaSourceViewer)
604604
((JavaSourceViewer)getSourceViewer()).setPreferenceStore(store);
605605
}
606+
607+
@Override
608+
protected boolean affectsTextPresentation(PropertyChangeEvent event) {
609+
return ((JavaScriptSourceViewerConfiguration)getSourceViewerConfiguration()).affectsTextPresentation(event) || super.affectsTextPresentation(event);
610+
}
606611
}

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/src/ts/eclipse/ide/jsdt/internal/ui/editor/TypeScriptSourceViewerConfiguration.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.eclipse.jface.util.PropertyChangeEvent;
3636
import org.eclipse.swt.SWT;
3737
import org.eclipse.swt.widgets.Shell;
38+
import org.eclipse.textmate4e.ui.text.TMPresentationReconciler;
3839
import org.eclipse.ui.texteditor.ITextEditor;
3940
import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
4041
import org.eclipse.wst.jsdt.internal.ui.text.AbstractJavaScanner;
@@ -57,6 +58,7 @@
5758
import ts.eclipse.ide.ui.implementation.TypeScriptImplementationDialog;
5859
import ts.eclipse.ide.ui.outline.TypeScriptElementProvider;
5960
import ts.eclipse.ide.ui.outline.TypeScriptQuickOutlineDialog;
61+
import ts.eclipse.ide.ui.preferences.TypeScriptUIPreferenceConstants;
6062
import ts.eclipse.ide.ui.utils.EditorUtils;
6163
import ts.resources.ITypeScriptFile;
6264

@@ -78,11 +80,14 @@ public class TypeScriptSourceViewerConfiguration extends JavaScriptSourceViewerC
7880
*/
7981
private AbstractJavaScanner jsxScanner;
8082

83+
private IPreferenceStore preferenceStore;
84+
8185
public TypeScriptSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore,
8286
ITextEditor editor, String partitioning) {
8387
super(colorManager, preferenceStore, editor, partitioning);
8488
fCodeScanner = new TypeScriptCodeScanner(colorManager, preferenceStore);
8589
jsxScanner = new JSXScanner(colorManager, preferenceStore);
90+
this.preferenceStore = preferenceStore;
8691

8792
}
8893

@@ -335,14 +340,17 @@ else if (IJavaScriptPartitions.JAVA_CHARACTER.equals(contentType)
335340

336341
@Override
337342
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.
338348
PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);
339-
340349
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getJSXScanner());
341350
reconciler.setDamager(dr, IJSXPartitions.JSX);
342351
reconciler.setRepairer(dr, IJSXPartitions.JSX);
343352

344353
return reconciler;
345-
346354
}
347355

348356
/**
@@ -366,7 +374,8 @@ protected RuleBasedScanner getJSXScanner() {
366374

367375
public boolean affectsTextPresentation(final PropertyChangeEvent event) {
368376
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());
370379
}
371380

372381
@Override

0 commit comments

Comments
 (0)