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

Unified Diff: pkg/analyzer/lib/src/dart/element/builder.dart

Issue 1665683002: Revert "Create ElementAnnotation objects prior to resolution." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/dart/element/element.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/builder.dart
diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart
index dc56f61ae00523ee4aa405940629fab7c8a3a36c..df8f470bd3b63fc4e5ab07658bc6d494080ed499 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -62,8 +62,7 @@ class CompilationUnitBuilder {
* Instances of the class `DirectiveElementBuilder` build elements for top
* level library directives.
*/
-class DirectiveElementBuilder extends SimpleAstVisitor<Object>
- with _ElementBuilderMixin {
+class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
/**
* The analysis context within which directive elements are being built.
*/
@@ -187,7 +186,6 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object>
CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
[uriLiteral.toSource()]));
}
- setMetadata(exportElement, node);
}
}
return null;
@@ -240,30 +238,11 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object>
errors.add(new AnalysisError(importedSource, uriLiteral.offset,
uriLiteral.length, errorCode, [uriLiteral.toSource()]));
}
- setMetadata(importElement, node);
}
}
return null;
}
- @override
- Object visitLibraryDirective(LibraryDirective node) {
- setMetadata(node.element, node);
- return null;
- }
-
- @override
- Object visitPartDirective(PartDirective node) {
- setMetadata(node.element, node);
- return null;
- }
-
- @override
- Object visitPartOfDirective(PartOfDirective node) {
- setMetadata(node.element, node);
- return null;
- }
-
/**
* If the given [node] has a documentation comment, remember its content
* and range into the given [element].
@@ -296,8 +275,7 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object>
* Instances of the class `ElementBuilder` traverse an AST structure and build the element
* model representing the AST structure.
*/
-class ElementBuilder extends RecursiveAstVisitor<Object>
- with _ElementBuilderMixin {
+class ElementBuilder extends RecursiveAstVisitor<Object> {
/**
* The element holder associated with the element that is currently being built.
*/
@@ -422,7 +400,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
className.staticElement = element;
_fieldMap = null;
holder.validate();
- setMetadata(element, node);
return null;
}
@@ -457,7 +434,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
_currentHolder.addType(element);
className.staticElement = element;
holder.validate();
- setMetadata(element, node);
return null;
}
@@ -507,7 +483,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
element.nameEnd = constructorName.end;
}
holder.validate();
- setMetadata(element, node);
return null;
}
@@ -527,7 +502,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
}
_currentHolder.addLocalVariable(element);
variableName.staticElement = element;
- setMetadata(element, node);
return super.visitDeclaredIdentifier(node);
}
@@ -592,7 +566,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
enumElement.constructors = ConstructorElement.EMPTY_LIST;
_currentHolder.addEnum(enumElement);
enumName.staticElement = enumElement;
- setMetadata(enumElement, node);
return super.visitEnumDeclaration(node);
}
@@ -635,7 +608,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
element.parameters = holder.parameters;
element.typeParameters = holder.typeParameters;
holder.validate();
- _setMetadataForParameter(element, node);
return null;
}
@@ -686,7 +658,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
_currentHolder.addFunction(element);
expression.element = element;
functionName.staticElement = element;
- setMetadata(element, node);
} else {
SimpleIdentifier propertyNameNode = node.name;
if (propertyNameNode == null) {
@@ -728,7 +699,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
_currentHolder.addAccessor(getter);
expression.element = getter;
propertyNameNode.staticElement = getter;
- setMetadata(getter, node);
} else {
PropertyAccessorElementImpl setter =
new PropertyAccessorElementImpl.forNode(propertyNameNode);
@@ -757,7 +727,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
_currentHolder.addAccessor(setter);
expression.element = setter;
propertyNameNode.staticElement = setter;
- setMetadata(setter, node);
}
}
holder.validate();
@@ -831,7 +800,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
_currentHolder.addTypeAlias(element);
aliasName.staticElement = element;
holder.validate();
- setMetadata(element, node);
return null;
}
@@ -856,7 +824,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
element.parameters = holder.parameters;
element.typeParameters = holder.typeParameters;
holder.validate();
- _setMetadataForParameter(element, node);
return null;
}
@@ -918,7 +885,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
}
_currentHolder.addMethod(element);
methodName.staticElement = element;
- setMetadata(element, node);
} else {
SimpleIdentifier propertyNameNode = node.name;
String propertyName = propertyNameNode.name;
@@ -957,7 +923,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
}
_currentHolder.addAccessor(getter);
propertyNameNode.staticElement = getter;
- setMetadata(getter, node);
} else {
PropertyAccessorElementImpl setter =
new PropertyAccessorElementImpl.forNode(propertyNameNode);
@@ -986,7 +951,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
field.final2 = false;
_currentHolder.addAccessor(setter);
propertyNameNode.staticElement = setter;
- setMetadata(setter, node);
}
}
holder.validate();
@@ -1043,9 +1007,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
_currentHolder.addParameter(parameter);
parameterName.staticElement = parameter;
}
- super.visitSimpleFormalParameter(node);
- _setMetadataForParameter(node.element, node);
- return null;
+ return super.visitSimpleFormalParameter(node);
}
@override
@@ -1080,7 +1042,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
typeParameter.type = typeParameterType;
_currentHolder.addTypeParameter(typeParameter);
parameterName.staticElement = typeParameter;
- setMetadata(typeParameter, node);
return super.visitTypeParameter(node);
}
@@ -1189,7 +1150,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object>
element.setter = setter;
}
}
- setMetadata(element, node);
return null;
}
@@ -1354,75 +1314,6 @@ class _ElementBuilder_visitClassDeclaration extends UnifyingAstVisitor<Object> {
}
/**
- * Helper methods used by element builder classes.
- */
-class _ElementBuilderMixin {
- /**
- * 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 setMetadata(Element element, AnnotatedNode node) {
- if (element is! ElementImpl) {
- return;
- }
- List<ElementAnnotationImpl> annotationList = <ElementAnnotationImpl>[];
- _addAnnotations(annotationList, node.metadata, element);
- if (node is VariableDeclaration && node.parent is VariableDeclarationList) {
- VariableDeclarationList list = node.parent as VariableDeclarationList;
- _addAnnotations(annotationList, list.metadata, element);
- if (list.parent is FieldDeclaration) {
- FieldDeclaration fieldDeclaration = list.parent as FieldDeclaration;
- _addAnnotations(annotationList, fieldDeclaration.metadata, element);
- } else if (list.parent is TopLevelVariableDeclaration) {
- TopLevelVariableDeclaration variableDeclaration =
- list.parent as TopLevelVariableDeclaration;
- _addAnnotations(annotationList, variableDeclaration.metadata, element);
- }
- }
- 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;
- }
- List<ElementAnnotationImpl> annotationList =
- new List<ElementAnnotationImpl>();
- _addAnnotations(annotationList, node.metadata, element);
- 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].
- *
- * [annotatedElement] is the element to which the annotations are being
- * applied.
- */
- static void _addAnnotations(List<ElementAnnotationImpl> annotationList,
- NodeList<Annotation> annotations, Element annotatedElement) {
- int annotationCount = annotations.length;
- for (int i = 0; i < annotationCount; i++) {
- Annotation annotation = annotations[i];
- ElementAnnotationImpl elementAnnotation =
- new ElementAnnotationImpl(annotatedElement);
- annotation.elementAnnotation = elementAnnotation;
- annotationList.add(elementAnnotation);
- }
- }
-}
-
-/**
* Instances of the class [_NamespaceCombinatorBuilder] can be used to visit
* [Combinator] AST nodes and generate [NamespaceCombinator] elements.
*/
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698