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

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: Analyze for @deprecated all invocable elements 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 DefaultSemanticHigh lighting {
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
47 // return new RGB(184, 115, 51); //copper 110 // return new RGB(184, 115, 51); //copper
48 // return new RGB(0xd7, 0x96, 0x7d); //taupe 111 // return new RGB(0xd7, 0x96, 0x7d); //taupe
49 return new RGB(0x67, 0x4C, 0x47); //dark taupe 112 return new RGB(0x67, 0x4C, 0x47); //dark taupe
50 } 113 }
51 114
52 @Override 115 @Override
53 public String getDisplayName() { 116 public String getDisplayName() {
54 return DartEditorMessages.SemanticHighlighting_dynamicType; 117 return DartEditorMessages.SemanticHighlighting_dynamicType;
55 } 118 }
56 119
57 @Override 120 @Override
58 public String getPreferenceKey() { 121 public String getPreferenceKey() {
59 return DYNAMIC_TYPE; 122 return DYNAMIC_TYPE;
60 } 123 }
61
62 @Override
63 public boolean isBoldByDefault() {
64 return false;
65 }
66
67 @Override
68 public boolean isEnabledByDefault() {
69 return false;
70 }
71
72 @Override
73 public boolean isItalicByDefault() {
74 return false;
75 }
76
77 @Override
78 public boolean isUnderlineByDefault() {
79 return false;
80 }
81 } 124 }
82 125
83 /** 126 /**
84 * Semantic highlighting for fields. 127 * Semantic highlighting for fields.
85 */ 128 */
86 private static class FieldHighlighting extends SemanticHighlighting { 129 private static class FieldHighlighting extends DefaultSemanticHighlighting {
87 130
88 @Override 131 @Override
89 public boolean consumes(SemanticToken token) { 132 public boolean consumes(SemanticToken token) {
90 DartIdentifier node = token.getNode(); 133 DartIdentifier node = token.getNode();
91 NodeElement element = node.getElement(); 134 NodeElement element = node.getElement();
92 if (element == null || element.isDynamic()) { 135 if (element == null || element.isDynamic()) {
93 return false; 136 return false;
94 } 137 }
95 if (element instanceof FieldElement) { 138 if (element instanceof FieldElement) {
96 FieldElement field = (FieldElement) element; 139 FieldElement field = (FieldElement) element;
(...skipping 11 matching lines...) Expand all
108 151
109 @Override 152 @Override
110 public String getDisplayName() { 153 public String getDisplayName() {
111 return DartEditorMessages.SemanticHighlighting_field; 154 return DartEditorMessages.SemanticHighlighting_field;
112 } 155 }
113 156
114 @Override 157 @Override
115 public String getPreferenceKey() { 158 public String getPreferenceKey() {
116 return FIELD; 159 return FIELD;
117 } 160 }
118
119 @Override
120 public boolean isBoldByDefault() {
121 return false;
122 }
123
124 @Override
125 public boolean isEnabledByDefault() {
126 return false;
127 }
128
129 @Override
130 public boolean isItalicByDefault() {
131 return false;
132 }
133
134 @Override
135 public boolean isUnderlineByDefault() {
136 return false;
137 }
138 } 161 }
139 162
140 /** 163 /**
141 * Semantic highlighting for static fields. 164 * Semantic highlighting for static fields.
142 */ 165 */
143 private static class StaticFieldHighlighting extends FieldHighlighting { 166 private static class StaticFieldHighlighting extends DefaultSemanticHighlighti ng {
144 @Override 167 @Override
145 public boolean consumes(SemanticToken token) { 168 public boolean consumes(SemanticToken token) {
146 DartIdentifier node = token.getNode(); 169 DartIdentifier node = token.getNode();
147 NodeElement element = node.getElement(); 170 NodeElement element = node.getElement();
148 if (element == null || element.isDynamic()) { 171 if (element == null || element.isDynamic()) {
149 return false; 172 return false;
150 } 173 }
151 if (element instanceof FieldElement) { 174 if (element instanceof FieldElement) {
152 return ((FieldElement) element).isStatic(); 175 return ((FieldElement) element).isStatic();
153 } 176 }
(...skipping 11 matching lines...) Expand all
165 } 188 }
166 189
167 @Override 190 @Override
168 public boolean isItalicByDefault() { 191 public boolean isItalicByDefault() {
169 return true; 192 return true;
170 } 193 }
171 194
172 } 195 }
173 196
174 /** 197 /**
198 * A named preference part that controls the highlighting of deprecated elemen ts.
199 */
200 public static final String DEPRECATED_ELEMENT = "deprecated"; //$NON-NLS-1$
201
202 /**
175 * A named preference part that controls the highlighting of static final fiel ds. 203 * A named preference part that controls the highlighting of static final fiel ds.
176 */ 204 */
177 public static final String STATIC_FINAL_FIELD = "staticFinalField"; //$NON-NLS -1$ 205 public static final String STATIC_FINAL_FIELD = "staticFinalField"; //$NON-NLS -1$
178 206
179 /** 207 /**
180 * A named preference part that controls the highlighting of static fields. 208 * A named preference part that controls the highlighting of static fields.
181 */ 209 */
182 public static final String STATIC_FIELD = "staticField"; //$NON-NLS-1$ 210 public static final String STATIC_FIELD = "staticField"; //$NON-NLS-1$
183 211
184 /** 212 /**
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX; 383 + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
356 } 384 }
357 385
358 /** 386 /**
359 * @return The semantic highlightings, the order defines the precedence of mat ches, the first 387 * @return The semantic highlightings, the order defines the precedence of mat ches, the first
360 * match wins. 388 * match wins.
361 */ 389 */
362 public static SemanticHighlighting[] getSemanticHighlightings() { 390 public static SemanticHighlighting[] getSemanticHighlightings() {
363 if (SEMANTIC_HIGHTLIGHTINGS == null) { 391 if (SEMANTIC_HIGHTLIGHTINGS == null) {
364 SEMANTIC_HIGHTLIGHTINGS = new SemanticHighlighting[] { 392 SEMANTIC_HIGHTLIGHTINGS = new SemanticHighlighting[] {
365 new StaticFieldHighlighting(), new FieldHighlighting(), new DynamicTyp eHighlighting()}; 393 new DeprecatedElementHighlighting(), new StaticFieldHighlighting(),
394 new FieldHighlighting(), new DynamicTypeHighlighting()};
366 } 395 }
367 return SEMANTIC_HIGHTLIGHTINGS; 396 return SEMANTIC_HIGHTLIGHTINGS;
368 } 397 }
369 398
370 /** 399 /**
371 * A named preference that controls if the given semantic highlighting has the text attribute 400 * A named preference that controls if the given semantic highlighting has the text attribute
372 * strikethrough. 401 * strikethrough.
373 * 402 *
374 * @param semanticHighlighting the semantic highlighting 403 * @param semanticHighlighting the semantic highlighting
375 * @return the strikethrough preference key 404 * @return the strikethrough preference key
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 /** 496 /**
468 * Do not instantiate 497 * Do not instantiate
469 */ 498 */
470 private SemanticHighlightings() { 499 private SemanticHighlightings() {
471 } 500 }
472 501
473 public RGB getDefaultDefaultTextColor() { 502 public RGB getDefaultDefaultTextColor() {
474 return new RGB(13, 100, 0); 503 return new RGB(13, 100, 0);
475 } 504 }
476 } 505 }
OLDNEW
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditorMessages.properties ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698