Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightings.java

Issue 10703046: Issue 3753. Support for @deprecated annotation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
11 * or implied. See the License for the specific language governing permissions a nd limitations under 11 * or implied. See the License for the specific language governing permissions a nd limitations under
12 * the License. 12 * the License.
13 */ 13 */
14 package com.google.dart.tools.ui.internal.text.editor; 14 package com.google.dart.tools.ui.internal.text.editor;
15 15
16 import com.google.dart.compiler.ast.DartIdentifier; 16 import com.google.dart.compiler.ast.DartIdentifier;
17 import com.google.dart.compiler.ast.Modifiers; 17 import com.google.dart.compiler.ast.Modifiers;
18 import com.google.dart.compiler.resolver.FieldElement; 18 import com.google.dart.compiler.resolver.FieldElement;
19 import com.google.dart.compiler.resolver.NodeElement; 19 import com.google.dart.compiler.resolver.NodeElement;
20 import com.google.dart.tools.core.utilities.ast.DynamicTypesFinder; 20 import com.google.dart.tools.core.utilities.ast.DynamicTypesFinder;
21 import com.google.dart.tools.ui.PreferenceConstants; 21 import com.google.dart.tools.ui.PreferenceConstants;
22 22
23 import org.eclipse.jface.preference.IPreferenceStore; 23 import org.eclipse.jface.preference.IPreferenceStore;
24 import org.eclipse.jface.preference.PreferenceConverter; 24 import org.eclipse.jface.preference.PreferenceConverter;
25 import org.eclipse.jface.util.PropertyChangeEvent; 25 import org.eclipse.jface.util.PropertyChangeEvent;
26 import org.eclipse.swt.graphics.RGB; 26 import org.eclipse.swt.graphics.RGB;
27 27
28 /** 28 /**
29 * Semantic highlightings 29 * Semantic highlightings.
30 */ 30 */
31 public class SemanticHighlightings { 31 public class SemanticHighlightings {
32 32
33 /** 33 /**
34 * Abstract {@link SemanticHighlighting} with empty methods by default.
35 */
36 private static abstract class DefaultSemanticHighlighting extends SemanticHigh lighting {
37
38 @Override
39 public RGB getDefaultDefaultTextColor() {
40 return new RGB(0, 0, 0);
41 }
42
43 @Override
44 public boolean isBoldByDefault() {
45 return false;
46 }
47
48 @Override
49 public boolean isEnabledByDefault() {
50 return false;
51 }
52
53 @Override
54 public boolean isItalicByDefault() {
55 return false;
56 }
57
58 @Override
59 public boolean isStrikethroughByDefault() {
60 return false;
61 }
62
63 @Override
64 public boolean isUnderlineByDefault() {
65 return false;
66 }
67 }
68
69 /**
70 * Semantic highlighting deprecated elements.
71 */
72 private static final class DeprecatedElementHighlighting extends DefaultSemant icHighlighting {
73 @Override
74 public boolean consumes(SemanticToken token) {
75 DartIdentifier node = token.getNode();
76 NodeElement element = node.getElement();
77 return element != null && element.getMetadata().isDeprecated();
78 }
79
80 @Override
81 public String getDisplayName() {
82 return DartEditorMessages.SemanticHighlighting_deprecatedElement;
83 }
84
85 @Override
86 public String getPreferenceKey() {
87 return DEPRECATED_ELEMENT;
88 }
89
90 @Override
91 public boolean isStrikethroughByDefault() {
92 return true;
93 }
94 }
95
96 /**
34 * Semantic highlighting for variables with dynamic types. 97 * Semantic highlighting for variables with dynamic types.
35 */ 98 */
36 private static final class DynamicTypeHighlighting extends SemanticHighlightin g { 99 private static final class DynamicTypeHighlighting extends SemanticHighlightin g {
Brian Wilkerson 2012/06/29 16:17:49 Should this subclass DefaultSemanticHighlighting?
scheglov 2012/06/29 20:11:57 Done.
37 100
38 @Override 101 @Override
39 public boolean consumes(SemanticToken token) { 102 public boolean consumes(SemanticToken token) {
40 DartIdentifier node = token.getNode(); 103 DartIdentifier node = token.getNode();
41 return DynamicTypesFinder.isDynamic(node); 104 return DynamicTypesFinder.isDynamic(node);
42 } 105 }
43 106
44 @Override 107 @Override
45 public RGB getDefaultDefaultTextColor() { 108 public RGB getDefaultDefaultTextColor() {
46 // return new RGB(237, 145, 33); //carrot 109 // return new RGB(237, 145, 33); //carrot
(...skipping 29 matching lines...) Expand all
76 139
77 @Override 140 @Override
78 public boolean isUnderlineByDefault() { 141 public boolean isUnderlineByDefault() {
79 return false; 142 return false;
80 } 143 }
81 } 144 }
82 145
83 /** 146 /**
84 * Semantic highlighting for fields. 147 * Semantic highlighting for fields.
85 */ 148 */
86 private static class FieldHighlighting extends SemanticHighlighting { 149 private static class FieldHighlighting extends SemanticHighlighting {
Brian Wilkerson 2012/06/29 16:17:49 Should this subclass DefaultSemanticHighlighting?
scheglov 2012/06/29 20:11:57 Done.
87 150
88 @Override 151 @Override
89 public boolean consumes(SemanticToken token) { 152 public boolean consumes(SemanticToken token) {
90 DartIdentifier node = token.getNode(); 153 DartIdentifier node = token.getNode();
91 NodeElement element = node.getElement(); 154 NodeElement element = node.getElement();
92 if (element == null || element.isDynamic()) { 155 if (element == null || element.isDynamic()) {
93 return false; 156 return false;
94 } 157 }
95 if (element instanceof FieldElement) { 158 if (element instanceof FieldElement) {
96 FieldElement field = (FieldElement) element; 159 FieldElement field = (FieldElement) element;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 196
134 @Override 197 @Override
135 public boolean isUnderlineByDefault() { 198 public boolean isUnderlineByDefault() {
136 return false; 199 return false;
137 } 200 }
138 } 201 }
139 202
140 /** 203 /**
141 * Semantic highlighting for static fields. 204 * Semantic highlighting for static fields.
142 */ 205 */
143 private static class StaticFieldHighlighting extends FieldHighlighting { 206 private static class StaticFieldHighlighting extends FieldHighlighting {
Brian Wilkerson 2012/06/29 16:17:49 Should this subclass DefaultSemanticHighlighting?
scheglov 2012/06/29 20:11:57 Done.
144 @Override 207 @Override
145 public boolean consumes(SemanticToken token) { 208 public boolean consumes(SemanticToken token) {
146 DartIdentifier node = token.getNode(); 209 DartIdentifier node = token.getNode();
147 NodeElement element = node.getElement(); 210 NodeElement element = node.getElement();
148 if (element == null || element.isDynamic()) { 211 if (element == null || element.isDynamic()) {
149 return false; 212 return false;
150 } 213 }
151 if (element instanceof FieldElement) { 214 if (element instanceof FieldElement) {
152 return ((FieldElement) element).isStatic(); 215 return ((FieldElement) element).isStatic();
153 } 216 }
(...skipping 11 matching lines...) Expand all
165 } 228 }
166 229
167 @Override 230 @Override
168 public boolean isItalicByDefault() { 231 public boolean isItalicByDefault() {
169 return true; 232 return true;
170 } 233 }
171 234
172 } 235 }
173 236
174 /** 237 /**
238 * A named preference part that controls the highlighting of deprecated elemen ts.
239 */
240 public static final String DEPRECATED_ELEMENT = "deprecated"; //$NON-NLS-1$
241
242 /**
175 * A named preference part that controls the highlighting of static final fiel ds. 243 * A named preference part that controls the highlighting of static final fiel ds.
176 */ 244 */
177 public static final String STATIC_FINAL_FIELD = "staticFinalField"; //$NON-NLS -1$ 245 public static final String STATIC_FINAL_FIELD = "staticFinalField"; //$NON-NLS -1$
178 246
179 /** 247 /**
180 * A named preference part that controls the highlighting of static fields. 248 * A named preference part that controls the highlighting of static fields.
181 */ 249 */
182 public static final String STATIC_FIELD = "staticField"; //$NON-NLS-1$ 250 public static final String STATIC_FIELD = "staticField"; //$NON-NLS-1$
183 251
184 /** 252 /**
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX; 423 + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
356 } 424 }
357 425
358 /** 426 /**
359 * @return The semantic highlightings, the order defines the precedence of mat ches, the first 427 * @return The semantic highlightings, the order defines the precedence of mat ches, the first
360 * match wins. 428 * match wins.
361 */ 429 */
362 public static SemanticHighlighting[] getSemanticHighlightings() { 430 public static SemanticHighlighting[] getSemanticHighlightings() {
363 if (SEMANTIC_HIGHTLIGHTINGS == null) { 431 if (SEMANTIC_HIGHTLIGHTINGS == null) {
364 SEMANTIC_HIGHTLIGHTINGS = new SemanticHighlighting[] { 432 SEMANTIC_HIGHTLIGHTINGS = new SemanticHighlighting[] {
365 new StaticFieldHighlighting(), new FieldHighlighting(), new DynamicTyp eHighlighting()}; 433 new DeprecatedElementHighlighting(), new StaticFieldHighlighting(),
434 new FieldHighlighting(), new DynamicTypeHighlighting()};
366 } 435 }
367 return SEMANTIC_HIGHTLIGHTINGS; 436 return SEMANTIC_HIGHTLIGHTINGS;
368 } 437 }
369 438
370 /** 439 /**
371 * A named preference that controls if the given semantic highlighting has the text attribute 440 * A named preference that controls if the given semantic highlighting has the text attribute
372 * strikethrough. 441 * strikethrough.
373 * 442 *
374 * @param semanticHighlighting the semantic highlighting 443 * @param semanticHighlighting the semantic highlighting
375 * @return the strikethrough preference key 444 * @return the strikethrough preference key
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 /** 536 /**
468 * Do not instantiate 537 * Do not instantiate
469 */ 538 */
470 private SemanticHighlightings() { 539 private SemanticHighlightings() {
471 } 540 }
472 541
473 public RGB getDefaultDefaultTextColor() { 542 public RGB getDefaultDefaultTextColor() {
474 return new RGB(13, 100, 0); 543 return new RGB(13, 100, 0);
475 } 544 }
476 } 545 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698