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

Unified Diff: pkg/analysis_server/lib/src/computer/computer_highlights.dart

Issue 1236433003: Revert "Update Analysis Server highlight API and implementation." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/computer/computer_highlights.dart
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
index b894cd8dd3c3393a2b1d423282d26e23082185f7..0491336d3a78565f4190ac6118ecef43760da9e8 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
@@ -63,7 +63,7 @@ class DartUnitHighlightsComputer {
if (_addIdentifierRegion_constructor(node)) {
return;
}
- if (_addIdentifierRegion_dynamicLocal(node)) {
+ if (_addIdentifierRegion_dynamicType(node)) {
return;
}
if (_addIdentifierRegion_getterSetterDeclaration(node)) {
@@ -135,8 +135,13 @@ class DartUnitHighlightsComputer {
return _addRegion_node(node, HighlightRegionType.CONSTRUCTOR);
}
- bool _addIdentifierRegion_dynamicLocal(SimpleIdentifier node) {
- // no propagated type
+ bool _addIdentifierRegion_dynamicType(SimpleIdentifier node) {
+ // should be variable
+ Element element = node.staticElement;
+ if (element is! VariableElement) {
+ return false;
+ }
+ // has propagated type
if (node.propagatedType != null) {
return false;
}
@@ -146,20 +151,7 @@ class DartUnitHighlightsComputer {
return false;
}
// OK
- Element element = node.staticElement;
- if (element is LocalVariableElement) {
- HighlightRegionType type = node.inDeclarationContext()
- ? HighlightRegionType.DYNAMIC_LOCAL_VARIABLE_DECLARATION
- : HighlightRegionType.DYNAMIC_LOCAL_VARIABLE_REFERENCE;
- return _addRegion_node(node, type);
- }
- if (element is ParameterElement) {
- HighlightRegionType type = node.inDeclarationContext()
- ? HighlightRegionType.DYNAMIC_PARAMETER_DECLARATION
- : HighlightRegionType.DYNAMIC_PARAMETER_REFERENCE;
- return _addRegion_node(node, type);
- }
- return false;
+ return _addRegion_node(node, HighlightRegionType.DYNAMIC_TYPE);
}
bool _addIdentifierRegion_field(SimpleIdentifier node) {
@@ -167,6 +159,9 @@ class DartUnitHighlightsComputer {
if (element is FieldFormalParameterElement) {
element = (element as FieldFormalParameterElement).field;
}
+ if (element is PropertyAccessorElement) {
+ element = (element as PropertyAccessorElement).variable;
+ }
// prepare type
HighlightRegionType type;
if (element is FieldElement) {
@@ -174,33 +169,12 @@ class DartUnitHighlightsComputer {
if (enclosingElement is ClassElement && enclosingElement.isEnum) {
type = HighlightRegionType.ENUM_CONSTANT;
} else if (element.isStatic) {
- type = HighlightRegionType.STATIC_FIELD_DECLARATION;
+ type = HighlightRegionType.FIELD_STATIC;
} else {
- type = node.inDeclarationContext()
- ? HighlightRegionType.INSTANCE_FIELD_DECLARATION
- : HighlightRegionType.INSTANCE_FIELD_REFERENCE;
+ type = HighlightRegionType.FIELD;
}
} else if (element is TopLevelVariableElement) {
- type = HighlightRegionType.TOP_LEVEL_VARIABLE_DECLARATION;
- }
- if (element is PropertyAccessorElement) {
- PropertyAccessorElement accessor = element;
- Element enclosingElement = element.enclosingElement;
- if (accessor.variable is TopLevelVariableElement) {
- type = accessor.isGetter
- ? HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE
- : HighlightRegionType.TOP_LEVEL_SETTER_REFERENCE;
- } else if (enclosingElement is ClassElement && enclosingElement.isEnum) {
- type = HighlightRegionType.ENUM_CONSTANT;
- } else if (accessor.isStatic) {
- type = accessor.isGetter
- ? HighlightRegionType.STATIC_GETTER_REFERENCE
- : HighlightRegionType.STATIC_SETTER_REFERENCE;
- } else {
- type = accessor.isGetter
- ? HighlightRegionType.INSTANCE_GETTER_REFERENCE
- : HighlightRegionType.INSTANCE_SETTER_REFERENCE;
- }
+ type = HighlightRegionType.TOP_LEVEL_VARIABLE;
}
// add region
if (type != null) {
@@ -215,15 +189,10 @@ class DartUnitHighlightsComputer {
return false;
}
HighlightRegionType type;
- bool isTopLevel = element.enclosingElement is CompilationUnitElement;
if (node.inDeclarationContext()) {
- type = isTopLevel
- ? HighlightRegionType.TOP_LEVEL_FUNCTION_DECLARATION
- : HighlightRegionType.LOCAL_FUNCTION_DECLARATION;
+ type = HighlightRegionType.FUNCTION_DECLARATION;
} else {
- type = isTopLevel
- ? HighlightRegionType.TOP_LEVEL_FUNCTION_REFERENCE
- : HighlightRegionType.LOCAL_FUNCTION_REFERENCE;
+ type = HighlightRegionType.FUNCTION;
}
return _addRegion_node(node, type);
}
@@ -250,26 +219,11 @@ class DartUnitHighlightsComputer {
// getter or setter
PropertyAccessorElement propertyAccessorElement =
element as PropertyAccessorElement;
- bool isTopLevel = element.enclosingElement is CompilationUnitElement;
- HighlightRegionType type;
if (propertyAccessorElement.isGetter) {
- if (isTopLevel) {
- type = HighlightRegionType.TOP_LEVEL_GETTER_DECLARATION;
- } else if (propertyAccessorElement.isStatic) {
- type = HighlightRegionType.STATIC_GETTER_DECLARATION;
- } else {
- type = HighlightRegionType.INSTANCE_GETTER_DECLARATION;
- }
+ return _addRegion_node(node, HighlightRegionType.GETTER_DECLARATION);
} else {
- if (isTopLevel) {
- type = HighlightRegionType.TOP_LEVEL_SETTER_DECLARATION;
- } else if (propertyAccessorElement.isStatic) {
- type = HighlightRegionType.STATIC_SETTER_DECLARATION;
- } else {
- type = HighlightRegionType.INSTANCE_SETTER_DECLARATION;
- }
+ return _addRegion_node(node, HighlightRegionType.SETTER_DECLARATION);
}
- return _addRegion_node(node, type);
}
bool _addIdentifierRegion_importPrefix(SimpleIdentifier node) {
@@ -302,9 +256,12 @@ class DartUnitHighlightsComputer {
return false;
}
// OK
- HighlightRegionType type = node.inDeclarationContext()
- ? HighlightRegionType.LOCAL_VARIABLE_DECLARATION
- : HighlightRegionType.LOCAL_VARIABLE_REFERENCE;
+ HighlightRegionType type;
+ if (node.inDeclarationContext()) {
+ type = HighlightRegionType.LOCAL_VARIABLE_DECLARATION;
+ } else {
+ type = HighlightRegionType.LOCAL_VARIABLE;
+ }
return _addRegion_node(node, type);
}
@@ -319,15 +276,15 @@ class DartUnitHighlightsComputer {
HighlightRegionType type;
if (node.inDeclarationContext()) {
if (isStatic) {
- type = HighlightRegionType.STATIC_METHOD_DECLARATION;
+ type = HighlightRegionType.METHOD_DECLARATION_STATIC;
} else {
- type = HighlightRegionType.INSTANCE_METHOD_DECLARATION;
+ type = HighlightRegionType.METHOD_DECLARATION;
}
} else {
if (isStatic) {
- type = HighlightRegionType.STATIC_METHOD_REFERENCE;
+ type = HighlightRegionType.METHOD_STATIC;
} else {
- type = HighlightRegionType.INSTANCE_METHOD_REFERENCE;
+ type = HighlightRegionType.METHOD;
}
}
return _addRegion_node(node, type);
@@ -338,10 +295,7 @@ class DartUnitHighlightsComputer {
if (element is! ParameterElement) {
return false;
}
- HighlightRegionType type = node.inDeclarationContext()
- ? HighlightRegionType.PARAMETER_DECLARATION
- : HighlightRegionType.PARAMETER_REFERENCE;
- return _addRegion_node(node, type);
+ return _addRegion_node(node, HighlightRegionType.PARAMETER);
}
bool _addIdentifierRegion_typeParameter(SimpleIdentifier node) {
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/generated_protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698