Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightings.java |
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightings.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightings.java |
index 2fbeda887bf41d05337eaa6243908bd15dea475f..0e03e5a88e0e34d53fdb3cb67429da73b2672ce1 100644 |
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightings.java |
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightings.java |
@@ -26,64 +26,107 @@ import org.eclipse.jface.util.PropertyChangeEvent; |
import org.eclipse.swt.graphics.RGB; |
/** |
- * Semantic highlightings |
+ * Semantic highlightings. |
*/ |
public class SemanticHighlightings { |
/** |
- * Semantic highlighting for variables with dynamic types. |
+ * Abstract {@link SemanticHighlighting} with empty methods by default. |
*/ |
- private static final class DynamicTypeHighlighting extends SemanticHighlighting { |
+ private static abstract class DefaultSemanticHighlighting extends SemanticHighlighting { |
@Override |
- public boolean consumes(SemanticToken token) { |
- DartIdentifier node = token.getNode(); |
- return DynamicTypesFinder.isDynamic(node); |
+ public RGB getDefaultDefaultTextColor() { |
+ return new RGB(0, 0, 0); |
} |
@Override |
- public RGB getDefaultDefaultTextColor() { |
-// return new RGB(237, 145, 33); //carrot |
-// return new RGB(184, 115, 51); //copper |
-// return new RGB(0xd7, 0x96, 0x7d); //taupe |
- return new RGB(0x67, 0x4C, 0x47); //dark taupe |
+ public boolean isBoldByDefault() { |
+ return false; |
} |
@Override |
- public String getDisplayName() { |
- return DartEditorMessages.SemanticHighlighting_dynamicType; |
+ public boolean isEnabledByDefault() { |
+ return false; |
} |
@Override |
- public String getPreferenceKey() { |
- return DYNAMIC_TYPE; |
+ public boolean isItalicByDefault() { |
+ return false; |
} |
@Override |
- public boolean isBoldByDefault() { |
+ public boolean isStrikethroughByDefault() { |
return false; |
} |
@Override |
- public boolean isEnabledByDefault() { |
+ public boolean isUnderlineByDefault() { |
return false; |
} |
+ } |
+ /** |
+ * Semantic highlighting deprecated elements. |
+ */ |
+ private static final class DeprecatedElementHighlighting extends DefaultSemanticHighlighting { |
@Override |
- public boolean isItalicByDefault() { |
- return false; |
+ public boolean consumes(SemanticToken token) { |
+ DartIdentifier node = token.getNode(); |
+ NodeElement element = node.getElement(); |
+ return element != null && element.getMetadata().isDeprecated(); |
} |
@Override |
- public boolean isUnderlineByDefault() { |
- return false; |
+ public String getDisplayName() { |
+ return DartEditorMessages.SemanticHighlighting_deprecatedElement; |
+ } |
+ |
+ @Override |
+ public String getPreferenceKey() { |
+ return DEPRECATED_ELEMENT; |
+ } |
+ |
+ @Override |
+ public boolean isStrikethroughByDefault() { |
+ return true; |
+ } |
+ } |
+ |
+ /** |
+ * Semantic highlighting for variables with dynamic types. |
+ */ |
+ private static final class DynamicTypeHighlighting extends DefaultSemanticHighlighting { |
+ |
+ @Override |
+ public boolean consumes(SemanticToken token) { |
+ DartIdentifier node = token.getNode(); |
+ return DynamicTypesFinder.isDynamic(node); |
+ } |
+ |
+ @Override |
+ public RGB getDefaultDefaultTextColor() { |
+// return new RGB(237, 145, 33); //carrot |
+// return new RGB(184, 115, 51); //copper |
+// return new RGB(0xd7, 0x96, 0x7d); //taupe |
+ return new RGB(0x67, 0x4C, 0x47); //dark taupe |
+ } |
+ |
+ @Override |
+ public String getDisplayName() { |
+ return DartEditorMessages.SemanticHighlighting_dynamicType; |
+ } |
+ |
+ @Override |
+ public String getPreferenceKey() { |
+ return DYNAMIC_TYPE; |
} |
} |
/** |
* Semantic highlighting for fields. |
*/ |
- private static class FieldHighlighting extends SemanticHighlighting { |
+ private static class FieldHighlighting extends DefaultSemanticHighlighting { |
@Override |
public boolean consumes(SemanticToken token) { |
@@ -115,32 +158,12 @@ public class SemanticHighlightings { |
public String getPreferenceKey() { |
return FIELD; |
} |
- |
- @Override |
- public boolean isBoldByDefault() { |
- return false; |
- } |
- |
- @Override |
- public boolean isEnabledByDefault() { |
- return false; |
- } |
- |
- @Override |
- public boolean isItalicByDefault() { |
- return false; |
- } |
- |
- @Override |
- public boolean isUnderlineByDefault() { |
- return false; |
- } |
} |
/** |
* Semantic highlighting for static fields. |
*/ |
- private static class StaticFieldHighlighting extends FieldHighlighting { |
+ private static class StaticFieldHighlighting extends DefaultSemanticHighlighting { |
@Override |
public boolean consumes(SemanticToken token) { |
DartIdentifier node = token.getNode(); |
@@ -172,6 +195,11 @@ public class SemanticHighlightings { |
} |
/** |
+ * A named preference part that controls the highlighting of deprecated elements. |
+ */ |
+ public static final String DEPRECATED_ELEMENT = "deprecated"; //$NON-NLS-1$ |
+ |
+ /** |
* A named preference part that controls the highlighting of static final fields. |
*/ |
public static final String STATIC_FINAL_FIELD = "staticFinalField"; //$NON-NLS-1$ |
@@ -362,7 +390,8 @@ public class SemanticHighlightings { |
public static SemanticHighlighting[] getSemanticHighlightings() { |
if (SEMANTIC_HIGHTLIGHTINGS == null) { |
SEMANTIC_HIGHTLIGHTINGS = new SemanticHighlighting[] { |
- new StaticFieldHighlighting(), new FieldHighlighting(), new DynamicTypeHighlighting()}; |
+ new DeprecatedElementHighlighting(), new StaticFieldHighlighting(), |
+ new FieldHighlighting(), new DynamicTypeHighlighting()}; |
} |
return SEMANTIC_HIGHTLIGHTINGS; |
} |