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

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

Issue 2809523002: Issue 29288. Resynthesize Import/Export/PartElement for every directive. (Closed)
Patch Set: Created 3 years, 8 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) 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 super.visitEnumDeclaration(node); 154 super.visitEnumDeclaration(node);
155 }); 155 });
156 _resolveMetadata(node, node.metadata, element); 156 _resolveMetadata(node, node.metadata, element);
157 return null; 157 return null;
158 } 158 }
159 159
160 @override 160 @override
161 Object visitExportDirective(ExportDirective node) { 161 Object visitExportDirective(ExportDirective node) {
162 super.visitExportDirective(node); 162 super.visitExportDirective(node);
163 // var element = node.element as ExportElement;
164 // List<ElementAnnotation> annotations = element.metadata;
Brian Wilkerson 2017/04/09 16:01:24 Should we remove these line? (in all three places)
163 List<ElementAnnotation> annotations = 165 List<ElementAnnotation> annotations =
164 _enclosingUnit.getAnnotations(node.offset); 166 _enclosingUnit.getAnnotations(node.offset);
165 if (annotations.isEmpty && node.metadata.isNotEmpty) { 167 if (annotations.isEmpty && node.metadata.isNotEmpty) {
166 int index = (node.parent as CompilationUnit) 168 int index = (node.parent as CompilationUnit)
167 .directives 169 .directives
168 .where((directive) => directive is ExportDirective) 170 .where((directive) => directive is ExportDirective)
169 .toList() 171 .toList()
170 .indexOf(node); 172 .indexOf(node);
171 annotations = _walker.element.library.exports[index].metadata; 173 annotations = _walker.element.library.exports[index].metadata;
172 } 174 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 _walk(new ElementWalker.forGenericTypeAlias(element), () { 295 _walk(new ElementWalker.forGenericTypeAlias(element), () {
294 super.visitGenericTypeAlias(node); 296 super.visitGenericTypeAlias(node);
295 }); 297 });
296 _resolveMetadata(node, node.metadata, element); 298 _resolveMetadata(node, node.metadata, element);
297 return null; 299 return null;
298 } 300 }
299 301
300 @override 302 @override
301 Object visitImportDirective(ImportDirective node) { 303 Object visitImportDirective(ImportDirective node) {
302 super.visitImportDirective(node); 304 super.visitImportDirective(node);
305 // var element = node.element as ImportElement;
306 // List<ElementAnnotation> annotations = element.metadata;
303 List<ElementAnnotation> annotations = 307 List<ElementAnnotation> annotations =
304 _enclosingUnit.getAnnotations(node.offset); 308 _enclosingUnit.getAnnotations(node.offset);
305 if (annotations.isEmpty && node.metadata.isNotEmpty) { 309 if (annotations.isEmpty && node.metadata.isNotEmpty) {
306 int index = (node.parent as CompilationUnit) 310 int index = (node.parent as CompilationUnit)
307 .directives 311 .directives
308 .where((directive) => directive is ImportDirective) 312 .where((directive) => directive is ImportDirective)
309 .toList() 313 .toList()
310 .indexOf(node); 314 .indexOf(node);
311 annotations = _walker.element.library.imports[index].metadata; 315 annotations = _walker.element.library.imports[index].metadata;
312 } 316 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 _walk(new ElementWalker.forExecutable(element, _enclosingUnit), () { 364 _walk(new ElementWalker.forExecutable(element, _enclosingUnit), () {
361 super.visitMethodDeclaration(node); 365 super.visitMethodDeclaration(node);
362 }); 366 });
363 _resolveMetadata(node, node.metadata, element); 367 _resolveMetadata(node, node.metadata, element);
364 return null; 368 return null;
365 } 369 }
366 370
367 @override 371 @override
368 Object visitPartDirective(PartDirective node) { 372 Object visitPartDirective(PartDirective node) {
369 super.visitPartDirective(node); 373 super.visitPartDirective(node);
374 // var element = node.element as CompilationUnitElement;
375 // List<ElementAnnotation> annotations = element.metadata;
370 List<ElementAnnotation> annotations = 376 List<ElementAnnotation> annotations =
371 _enclosingUnit.getAnnotations(node.offset); 377 _enclosingUnit.getAnnotations(node.offset);
372 if (annotations.isEmpty && node.metadata.isNotEmpty) { 378 if (annotations.isEmpty && node.metadata.isNotEmpty) {
373 int index = (node.parent as CompilationUnit) 379 int index = (node.parent as CompilationUnit)
374 .directives 380 .directives
375 .where((directive) => directive is PartDirective) 381 .where((directive) => directive is PartDirective)
376 .toList() 382 .toList()
377 .indexOf(node); 383 .indexOf(node);
378 annotations = _walker.element.library.parts[index].metadata; 384 annotations = _walker.element.library.parts[index].metadata;
379 } 385 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 class _ElementMismatchException extends AnalysisException { 788 class _ElementMismatchException extends AnalysisException {
783 /** 789 /**
784 * Creates an exception to refer to the given [compilationUnit], [element], 790 * Creates an exception to refer to the given [compilationUnit], [element],
785 * and [cause]. 791 * and [cause].
786 */ 792 */
787 _ElementMismatchException( 793 _ElementMismatchException(
788 CompilationUnitElement compilationUnit, Element element, 794 CompilationUnitElement compilationUnit, Element element,
789 [CaughtException cause = null]) 795 [CaughtException cause = null])
790 : super('Element mismatch in $compilationUnit at $element', cause); 796 : super('Element mismatch in $compilationUnit at $element', cause);
791 } 797 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698