Skip to content

Commit b4f3bfa

Browse files
author
angelozerr
committed
Syntax color for TypeScript keywords + ES7 decorator. Fix
#76
1 parent 573f251 commit b4f3bfa

File tree

5 files changed

+638
-1
lines changed

5 files changed

+638
-1
lines changed

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/src/ts/eclipse/ide/jsdt/internal/ui/ITypeScriptThemeConstants.java

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public interface ITypeScriptThemeConstants {
2222

2323
String ID_PREFIX = JSDTTypeScriptUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
2424

25+
/**
26+
* A theme constant that holds the color used to render JSX tag border
27+
* constants.
28+
*/
29+
public final String EDITOR_TYPESCRIPT_DECORATOR_COLOR = ID_PREFIX
30+
+ PreferenceConstants.EDITOR_TYPESCRIPT_DECORATOR_COLOR;
31+
2532
/**
2633
* A theme constant that holds the color used to render JSX tag border
2734
* constants.
@@ -47,4 +54,5 @@ public interface ITypeScriptThemeConstants {
4754
*/
4855
public final String EDITOR_JSX_TAG_ATTRIBUTE_VALUE_COLOR = ID_PREFIX
4956
+ PreferenceConstants.EDITOR_JSX_TAG_ATTRIBUTE_VALUE_COLOR;
57+
5058
}

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

+28-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import ts.eclipse.ide.jsdt.internal.ui.editor.contentassist.TypeScriptCompletionProcessor;
5151
import ts.eclipse.ide.jsdt.internal.ui.editor.contentassist.TypeScriptJavadocCompletionProcessor;
5252
import ts.eclipse.ide.jsdt.internal.ui.editor.format.TypeScriptContentFormatter;
53+
import ts.eclipse.ide.jsdt.internal.ui.text.TypeScriptCodeScanner;
5354
import ts.eclipse.ide.jsdt.internal.ui.text.jsx.IJSXPartitions;
5455
import ts.eclipse.ide.jsdt.internal.ui.text.jsx.JSXScanner;
5556
import ts.eclipse.ide.jsdt.ui.actions.ITypeScriptEditorActionDefinitionIds;
@@ -64,6 +65,12 @@
6465
*/
6566
public class TypeScriptSourceViewerConfiguration extends JavaScriptSourceViewerConfiguration {
6667

68+
/**
69+
* The TypeScript source code scanner.
70+
*
71+
*/
72+
private AbstractJavaScanner fCodeScanner;
73+
6774
/**
6875
* The JSX source scanner.
6976
*
@@ -73,6 +80,7 @@ public class TypeScriptSourceViewerConfiguration extends JavaScriptSourceViewerC
7380
public TypeScriptSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore,
7481
ITextEditor editor, String partitioning) {
7582
super(colorManager, preferenceStore, editor, partitioning);
83+
fCodeScanner = new TypeScriptCodeScanner(colorManager, preferenceStore);
7684
jsxScanner = new JSXScanner(colorManager, preferenceStore);
7785

7886
}
@@ -336,17 +344,36 @@ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceVie
336344

337345
}
338346

347+
/**
348+
* Returns the TypeScript source code scanner for this configuration.
349+
*
350+
* @return the TypeScript source code scanner
351+
*/
352+
@Override
353+
protected RuleBasedScanner getCodeScanner() {
354+
return fCodeScanner;
355+
}
356+
357+
/**
358+
* Returns the JSX source code scanner for this configuration.
359+
*
360+
* @return the JSX source code scanner
361+
*/
339362
protected RuleBasedScanner getJSXScanner() {
340363
return jsxScanner;
341364
}
342365

343366
public boolean affectsTextPresentation(final PropertyChangeEvent event) {
344-
return super.affectsTextPresentation(event) || jsxScanner.affectsBehavior(event);
367+
return super.affectsTextPresentation(event) || fCodeScanner.affectsBehavior(event)
368+
|| jsxScanner.affectsBehavior(event);
345369
}
346370

347371
@Override
348372
public void handlePropertyChangeEvent(final PropertyChangeEvent event) {
349373
super.handlePropertyChangeEvent(event);
374+
if (fCodeScanner.affectsBehavior(event)) {
375+
fCodeScanner.adaptToPreferenceChange(event);
376+
}
350377
if (jsxScanner.affectsBehavior(event)) {
351378
jsxScanner.adaptToPreferenceChange(event);
352379
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package ts.eclipse.ide.jsdt.internal.ui.text;
2+
3+
public interface ITypeScriptColorConstants {
4+
5+
public static final String DECORATOR = "decorator"; //$NON-NLS-1$
6+
}

0 commit comments

Comments
 (0)