| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 _walk(new ElementWalker.forExecutable(element, _enclosingUnit), () { | 332 _walk(new ElementWalker.forExecutable(element, _enclosingUnit), () { |
| 333 super.visitMethodDeclaration(node); | 333 super.visitMethodDeclaration(node); |
| 334 }); | 334 }); |
| 335 _resolveMetadata(node, node.metadata, element); | 335 _resolveMetadata(node, node.metadata, element); |
| 336 return null; | 336 return null; |
| 337 } | 337 } |
| 338 | 338 |
| 339 @override | 339 @override |
| 340 Object visitPartDirective(PartDirective node) { | 340 Object visitPartDirective(PartDirective node) { |
| 341 super.visitPartDirective(node); | 341 super.visitPartDirective(node); |
| 342 _resolveAnnotations( | 342 List<ElementAnnotation> annotations = |
| 343 node, node.metadata, _enclosingUnit.getAnnotations(node.offset)); | 343 _enclosingUnit.getAnnotations(node.offset); |
| 344 if (annotations.isEmpty && node.metadata.isNotEmpty) { |
| 345 int index = (node.parent as CompilationUnit) |
| 346 .directives |
| 347 .where((directive) => directive is PartDirective) |
| 348 .toList() |
| 349 .indexOf(node); |
| 350 annotations = _walker.element.library.parts[index].metadata; |
| 351 } |
| 352 _resolveAnnotations(node, node.metadata, annotations); |
| 344 return null; | 353 return null; |
| 345 } | 354 } |
| 346 | 355 |
| 347 @override | 356 @override |
| 348 Object visitPartOfDirective(PartOfDirective node) { | 357 Object visitPartOfDirective(PartOfDirective node) { |
| 349 node.element = _enclosingUnit.library; | 358 node.element = _enclosingUnit.library; |
| 350 return super.visitPartOfDirective(node); | 359 return super.visitPartOfDirective(node); |
| 351 } | 360 } |
| 352 | 361 |
| 353 @override | 362 @override |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 class _ElementMismatchException extends AnalysisException { | 731 class _ElementMismatchException extends AnalysisException { |
| 723 /** | 732 /** |
| 724 * Creates an exception to refer to the given [compilationUnit], [element], | 733 * Creates an exception to refer to the given [compilationUnit], [element], |
| 725 * and [cause]. | 734 * and [cause]. |
| 726 */ | 735 */ |
| 727 _ElementMismatchException( | 736 _ElementMismatchException( |
| 728 CompilationUnitElement compilationUnit, Element element, | 737 CompilationUnitElement compilationUnit, Element element, |
| 729 [CaughtException cause = null]) | 738 [CaughtException cause = null]) |
| 730 : super('Element mismatch in $compilationUnit at $element', cause); | 739 : super('Element mismatch in $compilationUnit at $element', cause); |
| 731 } | 740 } |
| OLD | NEW |