OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.declaration_resolver; | 5 library analyzer.src.generated.declaration_resolver; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 Object visitLabeledStatement(LabeledStatement node) { | 248 Object visitLabeledStatement(LabeledStatement node) { |
249 bool onSwitchStatement = node.statement is SwitchStatement; | 249 bool onSwitchStatement = node.statement is SwitchStatement; |
250 _walker.elementBuilder | 250 _walker.elementBuilder |
251 .buildLabelElements(node.labels, onSwitchStatement, false); | 251 .buildLabelElements(node.labels, onSwitchStatement, false); |
252 return super.visitLabeledStatement(node); | 252 return super.visitLabeledStatement(node); |
253 } | 253 } |
254 | 254 |
255 @override | 255 @override |
256 Object visitLibraryDirective(LibraryDirective node) { | 256 Object visitLibraryDirective(LibraryDirective node) { |
257 super.visitLibraryDirective(node); | 257 super.visitLibraryDirective(node); |
258 _resolveAnnotations( | 258 List<ElementAnnotation> annotations = |
259 node, node.metadata, _enclosingUnit.getAnnotations(node.offset)); | 259 _enclosingUnit.getAnnotations(node.offset); |
| 260 if (annotations.isEmpty && node.metadata.isNotEmpty) { |
| 261 annotations = _walker.element.library.metadata; |
| 262 } |
| 263 _resolveAnnotations(node, node.metadata, annotations); |
260 return null; | 264 return null; |
261 } | 265 } |
262 | 266 |
263 @override | 267 @override |
264 Object visitMethodDeclaration(MethodDeclaration node) { | 268 Object visitMethodDeclaration(MethodDeclaration node) { |
265 Token property = node.propertyKeyword; | 269 Token property = node.propertyKeyword; |
266 SimpleIdentifier methodName = node.name; | 270 SimpleIdentifier methodName = node.name; |
267 String nameOfMethod = methodName.name; | 271 String nameOfMethod = methodName.name; |
268 ExecutableElement element; | 272 ExecutableElement element; |
269 if (property == null) { | 273 if (property == null) { |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 class _ElementMismatchException extends AnalysisException { | 660 class _ElementMismatchException extends AnalysisException { |
657 /** | 661 /** |
658 * Creates an exception to refer to the given [compilationUnit], [element], | 662 * Creates an exception to refer to the given [compilationUnit], [element], |
659 * and [cause]. | 663 * and [cause]. |
660 */ | 664 */ |
661 _ElementMismatchException( | 665 _ElementMismatchException( |
662 CompilationUnitElement compilationUnit, Element element, | 666 CompilationUnitElement compilationUnit, Element element, |
663 [CaughtException cause = null]) | 667 [CaughtException cause = null]) |
664 : super('Element mismatch in $compilationUnit at $element', cause); | 668 : super('Element mismatch in $compilationUnit at $element', cause); |
665 } | 669 } |
OLD | NEW |