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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1668483003: Create ElementAnnotation objects prior to resolution. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.resolver; 5 library analyzer.src.generated.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 7706 matching lines...) Expand 10 before | Expand all | Expand 10 after
7717 } 7717 }
7718 7718
7719 @override 7719 @override
7720 Object visitEnumDeclaration(EnumDeclaration node) { 7720 Object visitEnumDeclaration(EnumDeclaration node) {
7721 // 7721 //
7722 // Resolve the metadata in the library scope 7722 // Resolve the metadata in the library scope
7723 // and associate the annotations with the element. 7723 // and associate the annotations with the element.
7724 // 7724 //
7725 if (node.metadata != null) { 7725 if (node.metadata != null) {
7726 node.metadata.accept(this); 7726 node.metadata.accept(this);
7727 ElementResolver.setMetadata(node.element, node); 7727 ElementResolver.resolveMetadata(node);
7728 } 7728 }
7729 // 7729 //
7730 // Continue the enum resolution. 7730 // Continue the enum resolution.
7731 // 7731 //
7732 ClassElement outerType = enclosingClass; 7732 ClassElement outerType = enclosingClass;
7733 try { 7733 try {
7734 enclosingClass = node.element; 7734 enclosingClass = node.element;
7735 typeAnalyzer.thisType = 7735 typeAnalyzer.thisType =
7736 enclosingClass == null ? null : enclosingClass.type; 7736 enclosingClass == null ? null : enclosingClass.type;
7737 super.visitEnumDeclaration(node); 7737 super.visitEnumDeclaration(node);
(...skipping 3119 matching lines...) Expand 10 before | Expand all | Expand 10 after
10857 nameScope: nameScope) { 10857 nameScope: nameScope) {
10858 _dynamicType = typeProvider.dynamicType; 10858 _dynamicType = typeProvider.dynamicType;
10859 _undefinedType = typeProvider.undefinedType; 10859 _undefinedType = typeProvider.undefinedType;
10860 _strongMode = definingLibrary.context.analysisOptions.strongMode; 10860 _strongMode = definingLibrary.context.analysisOptions.strongMode;
10861 } 10861 }
10862 10862
10863 @override 10863 @override
10864 Object visitAnnotation(Annotation node) { 10864 Object visitAnnotation(Annotation node) {
10865 // 10865 //
10866 // Visit annotations, if the annotation is @proxy, on a class, and "proxy" 10866 // Visit annotations, if the annotation is @proxy, on a class, and "proxy"
10867 // resolves to the proxy annotation in dart.core, then create create the 10867 // resolves to the proxy annotation in dart.core, then resolve the
10868 // ElementAnnotationImpl and set it as the metadata on the enclosing class. 10868 // ElementAnnotation.
10869 // 10869 //
10870 // Element resolution is done in the ElementResolver, and this work will be 10870 // Element resolution is done in the ElementResolver, and this work will be
10871 // done in the general case for all annotations in the ElementResolver. 10871 // done in the general case for all annotations in the ElementResolver.
10872 // The reason we resolve this particular element early is so that 10872 // The reason we resolve this particular element early is so that
10873 // ClassElement.isProxy() returns the correct information during all 10873 // ClassElement.isProxy() returns the correct information during all
10874 // phases of the ElementResolver. 10874 // phases of the ElementResolver.
10875 // 10875 //
10876 super.visitAnnotation(node); 10876 super.visitAnnotation(node);
10877 Identifier identifier = node.name; 10877 Identifier identifier = node.name;
10878 if (identifier.name.endsWith(ElementAnnotationImpl.PROXY_VARIABLE_NAME) && 10878 if (identifier.name.endsWith(ElementAnnotationImpl.PROXY_VARIABLE_NAME) &&
10879 node.parent is ClassDeclaration) { 10879 node.parent is ClassDeclaration) {
10880 Element element = nameScope.lookup(identifier, definingLibrary); 10880 Element element = nameScope.lookup(identifier, definingLibrary);
10881 if (element != null && 10881 if (element != null &&
10882 element.library.isDartCore && 10882 element.library.isDartCore &&
10883 element is PropertyAccessorElement) { 10883 element is PropertyAccessorElement) {
10884 // This is the @proxy from dart.core 10884 // This is the @proxy from dart.core
10885 ClassDeclaration classDeclaration = node.parent as ClassDeclaration; 10885 ElementAnnotationImpl elementAnnotation = node.elementAnnotation;
10886 ElementAnnotationImpl elementAnnotation = 10886 elementAnnotation.element = element;
10887 new ElementAnnotationImpl(element);
10888 node.elementAnnotation = elementAnnotation;
10889 (classDeclaration.element as ClassElementImpl).metadata =
10890 <ElementAnnotationImpl>[elementAnnotation];
10891 } 10887 }
10892 } 10888 }
10893 return null; 10889 return null;
10894 } 10890 }
10895 10891
10896 @override 10892 @override
10897 Object visitCatchClause(CatchClause node) { 10893 Object visitCatchClause(CatchClause node) {
10898 super.visitCatchClause(node); 10894 super.visitCatchClause(node);
10899 SimpleIdentifier exception = node.exceptionParameter; 10895 SimpleIdentifier exception = node.exceptionParameter;
10900 if (exception != null) { 10896 if (exception != null) {
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
12506 nonFields.add(node); 12502 nonFields.add(node);
12507 return null; 12503 return null;
12508 } 12504 }
12509 12505
12510 @override 12506 @override
12511 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 12507 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
12512 12508
12513 @override 12509 @override
12514 Object visitWithClause(WithClause node) => null; 12510 Object visitWithClause(WithClause node) => null;
12515 } 12511 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698