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

Unified Diff: pkg/analyzer/lib/src/dart/element/builder.dart

Issue 1768713002: Fixes to associating existing elements with an AST (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Clean up 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/dart/element/builder.dart
diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart
index 23869eeb038f1cda63b70ed0e6b781b32a0c395b..07211f1f663580b4ed6f45194f92395a49751ace 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -204,11 +204,6 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
Object visitImportDirective(ImportDirective node) {
// Remove previous element. (It will remain null if the target is missing.)
node.element = null;
-
- String uriContent = node.uriContent;
- if (DartUriResolver.isDartExtUri(uriContent)) {
- libraryElement.hasExtUri = true;
- }
Source importedSource = node.source;
if (importedSource != null && context.exists(importedSource)) {
// The imported source will be null if the URI in the import
@@ -225,7 +220,7 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
importElement.uriOffset = uriLiteral.offset;
importElement.uriEnd = uriLiteral.end;
}
- importElement.uri = uriContent;
+ importElement.uri = node.uriContent;
importElement.deferred = node.deferredKeyword != null;
importElement.combinators = _buildCombinators(node);
importElement.importedLibrary = importedLibrary;
@@ -312,7 +307,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
* The compilation unit element into which the elements being built will be
* stored.
*/
- final CompilationUnitElement compilationUnitElement;
+ final CompilationUnitElementImpl compilationUnitElement;
/**
* The element holder associated with the element that is currently being built.
@@ -339,9 +334,9 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
HashMap<String, FieldElement> _fieldMap;
/**
- * Initialize a newly created element builder to build the elements for a compilation unit.
- *
- * @param initialHolder the element holder associated with the compilation unit being built
+ * Initialize a newly created element builder to build the elements for a
+ * compilation unit. The [initialHolder] is the element holder to which the
+ * children of the visited compilation unit node will be added.
*/
ElementBuilder(ElementHolder initialHolder, this.compilationUnitElement) {
_currentHolder = initialHolder;
@@ -484,7 +479,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
@override
Object visitCompilationUnit(CompilationUnit node) {
if (compilationUnitElement is ElementImpl) {
- _setCodeRange(compilationUnitElement as ElementImpl, node);
+ _setCodeRange(compilationUnitElement, node);
}
return super.visitCompilationUnit(node);
}
@@ -633,7 +628,9 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
@override
Object visitExportDirective(ExportDirective node) {
- _createElementAnnotations(node.metadata);
+ List<ElementAnnotation> annotations =
+ _createElementAnnotations(node.metadata);
+ compilationUnitElement.setAnnotations(node.offset, annotations);
return super.visitExportDirective(node);
}
@@ -895,7 +892,9 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
@override
Object visitImportDirective(ImportDirective node) {
- _createElementAnnotations(node.metadata);
+ List<ElementAnnotation> annotations =
+ _createElementAnnotations(node.metadata);
+ compilationUnitElement.setAnnotations(node.offset, annotations);
return super.visitImportDirective(node);
}
@@ -915,7 +914,9 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
@override
Object visitLibraryDirective(LibraryDirective node) {
- _createElementAnnotations(node.metadata);
+ List<ElementAnnotation> annotations =
+ _createElementAnnotations(node.metadata);
+ compilationUnitElement.setAnnotations(node.offset, annotations);
return super.visitLibraryDirective(node);
}
@@ -1078,7 +1079,9 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
@override
Object visitPartDirective(PartDirective node) {
- _createElementAnnotations(node.metadata);
+ List<ElementAnnotation> annotations =
+ _createElementAnnotations(node.metadata);
+ compilationUnitElement.setAnnotations(node.offset, annotations);
return super.visitPartDirective(node);
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | pkg/analyzer/lib/src/dart/element/element.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698