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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 super.visitEnumDeclaration(node); | 148 super.visitEnumDeclaration(node); |
149 }); | 149 }); |
150 _resolveMetadata(node, node.metadata, element); | 150 _resolveMetadata(node, node.metadata, element); |
151 return null; | 151 return null; |
152 } | 152 } |
153 | 153 |
154 @override | 154 @override |
155 Object visitExportDirective(ExportDirective node) { | 155 Object visitExportDirective(ExportDirective node) { |
156 super.visitExportDirective(node); | 156 super.visitExportDirective(node); |
157 _resolveAnnotations( | 157 List<ElementAnnotation> annotations = |
158 node, node.metadata, _enclosingUnit.getAnnotations(node.offset)); | 158 _enclosingUnit.getAnnotations(node.offset); |
| 159 if (annotations.isEmpty && node.metadata.isNotEmpty) { |
| 160 int index = (node.parent as CompilationUnit) |
| 161 .directives |
| 162 .where((directive) => directive is ExportDirective) |
| 163 .toList() |
| 164 .indexOf(node); |
| 165 annotations = _walker.element.library.exports[index].metadata; |
| 166 } |
| 167 _resolveAnnotations(node, node.metadata, annotations); |
159 return null; | 168 return null; |
160 } | 169 } |
161 | 170 |
162 @override | 171 @override |
163 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { | 172 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { |
164 if (_isBodyToCreateElementsFor(node)) { | 173 if (_isBodyToCreateElementsFor(node)) { |
165 _walker.consumeLocalElements(); | 174 _walker.consumeLocalElements(); |
166 node.accept(_walker.elementBuilder); | 175 node.accept(_walker.elementBuilder); |
167 return null; | 176 return null; |
168 } else { | 177 } else { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 _resolveMetadata(node, node.metadata, element); | 265 _resolveMetadata(node, node.metadata, element); |
257 return null; | 266 return null; |
258 } else { | 267 } else { |
259 return super.visitFunctionTypedFormalParameter(node); | 268 return super.visitFunctionTypedFormalParameter(node); |
260 } | 269 } |
261 } | 270 } |
262 | 271 |
263 @override | 272 @override |
264 Object visitImportDirective(ImportDirective node) { | 273 Object visitImportDirective(ImportDirective node) { |
265 super.visitImportDirective(node); | 274 super.visitImportDirective(node); |
266 _resolveAnnotations( | 275 List<ElementAnnotation> annotations = |
267 node, node.metadata, _enclosingUnit.getAnnotations(node.offset)); | 276 _enclosingUnit.getAnnotations(node.offset); |
| 277 if (annotations.isEmpty && node.metadata.isNotEmpty) { |
| 278 int index = (node.parent as CompilationUnit) |
| 279 .directives |
| 280 .where((directive) => directive is ImportDirective) |
| 281 .toList() |
| 282 .indexOf(node); |
| 283 annotations = _walker.element.library.imports[index].metadata; |
| 284 } |
| 285 _resolveAnnotations(node, node.metadata, annotations); |
268 return null; | 286 return null; |
269 } | 287 } |
270 | 288 |
271 @override | 289 @override |
272 Object visitLabeledStatement(LabeledStatement node) { | 290 Object visitLabeledStatement(LabeledStatement node) { |
273 bool onSwitchStatement = node.statement is SwitchStatement; | 291 bool onSwitchStatement = node.statement is SwitchStatement; |
274 _walker.elementBuilder | 292 _walker.elementBuilder |
275 .buildLabelElements(node.labels, onSwitchStatement, false); | 293 .buildLabelElements(node.labels, onSwitchStatement, false); |
276 return super.visitLabeledStatement(node); | 294 return super.visitLabeledStatement(node); |
277 } | 295 } |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 class _ElementMismatchException extends AnalysisException { | 715 class _ElementMismatchException extends AnalysisException { |
698 /** | 716 /** |
699 * Creates an exception to refer to the given [compilationUnit], [element], | 717 * Creates an exception to refer to the given [compilationUnit], [element], |
700 * and [cause]. | 718 * and [cause]. |
701 */ | 719 */ |
702 _ElementMismatchException( | 720 _ElementMismatchException( |
703 CompilationUnitElement compilationUnit, Element element, | 721 CompilationUnitElement compilationUnit, Element element, |
704 [CaughtException cause = null]) | 722 [CaughtException cause = null]) |
705 : super('Element mismatch in $compilationUnit at $element', cause); | 723 : super('Element mismatch in $compilationUnit at $element', cause); |
706 } | 724 } |
OLD | NEW |