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

Unified Diff: pkg/analyzer/lib/src/generated/element_resolver.dart

Issue 1162013007: associate @deprecated with enum element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/analyzer/lib/src/generated/element_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index 291ac5b3a1c5dd35763499be54d0cc46053d0aad..743415c8ffe10255ec9b703c0fcf2282a8aceaf0 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -200,13 +200,12 @@ class ElementResolver extends SimpleAstVisitor<Object> {
@override
Object visitClassDeclaration(ClassDeclaration node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
-
@override
Brian Wilkerson 2015/06/04 23:10:11 Re-insert the blank line between members? (Is this
Object visitClassTypeAlias(ClassTypeAlias node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@@ -332,7 +331,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
}
}
- _setMetadata(constructorElement, node);
+ setMetadata(constructorElement, node);
}
return null;
}
@@ -388,13 +387,13 @@ class ElementResolver extends SimpleAstVisitor<Object> {
@override
Object visitDeclaredIdentifier(DeclaredIdentifier node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@override
Object visitEnumDeclaration(EnumDeclaration node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@@ -406,7 +405,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
// TODO(brianwilkerson) Figure out whether the element can ever be
// something other than an ExportElement
_resolveCombinators(exportElement.exportedLibrary, node.combinators);
- _setMetadata(exportElement, node);
+ setMetadata(exportElement, node);
}
return null;
}
@@ -419,7 +418,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
@override
Object visitFunctionDeclaration(FunctionDeclaration node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@@ -442,7 +441,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
@override
Object visitFunctionTypeAlias(FunctionTypeAlias node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@@ -471,7 +470,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
if (library != null) {
_resolveCombinators(library, node.combinators);
}
- _setMetadata(importElement, node);
+ setMetadata(importElement, node);
}
return null;
}
@@ -554,13 +553,13 @@ class ElementResolver extends SimpleAstVisitor<Object> {
@override
Object visitLibraryDirective(LibraryDirective node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@override
Object visitMethodDeclaration(MethodDeclaration node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@@ -741,13 +740,13 @@ class ElementResolver extends SimpleAstVisitor<Object> {
@override
Object visitPartDirective(PartDirective node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@override
Object visitPartOfDirective(PartOfDirective node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@@ -1087,36 +1086,17 @@ class ElementResolver extends SimpleAstVisitor<Object> {
@override
Object visitTypeParameter(TypeParameter node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
@override
Object visitVariableDeclaration(VariableDeclaration node) {
- _setMetadata(node.element, node);
+ setMetadata(node.element, node);
return null;
}
/**
- * Generate annotation elements for each of the annotations in the
- * [annotationList] and add them to the given list of [annotations].
- */
- void _addAnnotations(List<ElementAnnotationImpl> annotationList,
- NodeList<Annotation> annotations) {
- int annotationCount = annotations.length;
- for (int i = 0; i < annotationCount; i++) {
- Annotation annotation = annotations[i];
- Element resolvedElement = annotation.element;
- if (resolvedElement != null) {
- ElementAnnotationImpl elementAnnotation =
- new ElementAnnotationImpl(resolvedElement);
- annotation.elementAnnotation = elementAnnotation;
- annotationList.add(elementAnnotation);
- }
- }
- }
-
- /**
* Given that we have found code to invoke the given [element], return the
* error code that should be reported, or `null` if no error should be
* reported. The [target] is the target of the invocation, or `null` if there
@@ -1355,6 +1335,22 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
/**
+ * Return the best type of the given [expression] that is to be used for
+ * type analysis.
+ */
+ DartType _getBestType(Expression expression) {
+ DartType bestType = _resolveTypeParameter(expression.bestType);
+ if (bestType is FunctionType) {
+ //
+ // All function types are subtypes of 'Function', which is itself a
+ // subclass of 'Object'.
+ //
+ bestType = _resolver.typeProvider.functionType;
+ }
+ return bestType;
+ }
+
+ /**
* Assuming that the given [expression] is a prefix for a deferred import,
* return the library that is being imported.
*/
@@ -1392,22 +1388,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
/**
- * Return the best type of the given [expression] that is to be used for
- * type analysis.
- */
- DartType _getBestType(Expression expression) {
- DartType bestType = _resolveTypeParameter(expression.bestType);
- if (bestType is FunctionType) {
- //
- // All function types are subtypes of 'Function', which is itself a
- // subclass of 'Object'.
- //
- bestType = _resolver.typeProvider.functionType;
- }
- return bestType;
- }
-
- /**
* Return the propagated type of the given [expression] that is to be used for
* type analysis.
*/
@@ -2621,35 +2601,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
* [element] to which that node has been resolved, create the annotations in
* the element model representing the annotations on the node.
*/
- void _setMetadata(Element element, AnnotatedNode node) {
- if (element is! ElementImpl) {
- return;
- }
- List<ElementAnnotationImpl> annotationList =
- new List<ElementAnnotationImpl>();
- _addAnnotations(annotationList, node.metadata);
- if (node is VariableDeclaration && node.parent is VariableDeclarationList) {
- VariableDeclarationList list = node.parent as VariableDeclarationList;
- _addAnnotations(annotationList, list.metadata);
- if (list.parent is FieldDeclaration) {
- FieldDeclaration fieldDeclaration = list.parent as FieldDeclaration;
- _addAnnotations(annotationList, fieldDeclaration.metadata);
- } else if (list.parent is TopLevelVariableDeclaration) {
- TopLevelVariableDeclaration variableDeclaration =
- list.parent as TopLevelVariableDeclaration;
- _addAnnotations(annotationList, variableDeclaration.metadata);
- }
- }
- if (!annotationList.isEmpty) {
- (element as ElementImpl).metadata = annotationList;
- }
- }
-
- /**
- * Given a [node] that can have annotations associated with it and the
- * [element] to which that node has been resolved, create the annotations in
- * the element model representing the annotations on the node.
- */
void _setMetadataForParameter(Element element, NormalFormalParameter node) {
if (element is! ElementImpl) {
return;
@@ -2691,6 +2642,54 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
/**
+ * Given a [node] that can have annotations associated with it and the
+ * [element] to which that node has been resolved, create the annotations in
+ * the element model representing the annotations on the node.
+ */
+ static void setMetadata(Element element, AnnotatedNode node) {
+ if (element is! ElementImpl) {
+ return;
+ }
+ List<ElementAnnotationImpl> annotationList =
+ new List<ElementAnnotationImpl>();
Brian Wilkerson 2015/06/04 23:10:11 Why not "<ElementAnnotationImpl>[]"?
danrubel 2015/06/17 15:06:32 Done.
+ _addAnnotations(annotationList, node.metadata);
+ if (node is VariableDeclaration && node.parent is VariableDeclarationList) {
+ VariableDeclarationList list = node.parent as VariableDeclarationList;
+ _addAnnotations(annotationList, list.metadata);
+ if (list.parent is FieldDeclaration) {
+ FieldDeclaration fieldDeclaration = list.parent as FieldDeclaration;
+ _addAnnotations(annotationList, fieldDeclaration.metadata);
+ } else if (list.parent is TopLevelVariableDeclaration) {
+ TopLevelVariableDeclaration variableDeclaration =
+ list.parent as TopLevelVariableDeclaration;
+ _addAnnotations(annotationList, variableDeclaration.metadata);
+ }
+ }
+ if (!annotationList.isEmpty) {
+ (element as ElementImpl).metadata = annotationList;
+ }
+ }
+
+ /**
+ * Generate annotation elements for each of the annotations in the
+ * [annotationList] and add them to the given list of [annotations].
+ */
+ static void _addAnnotations(List<ElementAnnotationImpl> annotationList,
+ NodeList<Annotation> annotations) {
+ int annotationCount = annotations.length;
+ for (int i = 0; i < annotationCount; i++) {
+ Annotation annotation = annotations[i];
+ Element resolvedElement = annotation.element;
+ if (resolvedElement != null) {
+ ElementAnnotationImpl elementAnnotation =
+ new ElementAnnotationImpl(resolvedElement);
+ annotation.elementAnnotation = elementAnnotation;
+ annotationList.add(elementAnnotation);
+ }
+ }
+ }
+
+ /**
* Return `true` if the given [identifier] is the return type of a constructor
* declaration.
*/
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | pkg/analyzer/test/generated/element_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698