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

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: address comments 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 98635d306cb1ba19fcdf896d3b39215e62e79312..7df8d66e686d28351a148fcbe94d4a51c4bff5f8 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
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;
}
@@ -746,13 +745,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;
}
@@ -1096,36 +1095,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
@@ -2640,35 +2620,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;
@@ -2710,6 +2661,53 @@ 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 = <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;
+ }
+ }
+
+ /**
+ * 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698