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

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

Issue 2226613004: Suppress follow-on errors when a file is imported with either a prefix or a show clause (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cache URI existence in a modifier' Created 4 years, 4 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
« no previous file with comments | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6eaaedb6910bc133bddad43cea1e41ba51b3b927..00fae143f5d40f13ce25fa9aa17702dcdd27dd0f 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -154,6 +154,7 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
ImportElementImpl importElement = new ImportElementImpl(-1);
importElement.importedLibrary = importLibraryMap[coreLibrarySource];
importElement.synthetic = true;
+ importElement.uriExists = true;
imports.add(importElement);
}
//
@@ -183,6 +184,7 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
exportElement.uriEnd = uriLiteral.end;
}
exportElement.uri = node.uriContent;
+ exportElement.uriExists = exportedTime >= 0;
scheglov 2016/08/09 17:45:04 We have already checked "exportedTime != -1" above
Brian Wilkerson 2016/08/09 18:11:25 Good catch! The asymmetry was unintentional, so I
exportElement.combinators = _buildCombinators(node);
exportElement.exportedLibrary = exportedLibrary;
setElementDocumentationComment(exportElement, node);
@@ -213,53 +215,53 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
node.element = null;
Source importedSource = node.source;
int importedTime = sourceModificationTimeMap[importedSource] ?? -1;
- if (importedTime != -1) {
- // The imported source will be null if the URI in the import
- // directive was invalid.
- LibraryElement importedLibrary = importLibraryMap[importedSource];
- if (importedLibrary != null) {
- if (importedLibrary.isDartCore) {
- explicitlyImportsCore = true;
+ // The imported source will be null if the URI in the import
+ // directive was invalid.
+ LibraryElement importedLibrary = importLibraryMap[importedSource];
+ if (importedLibrary != null) {
+ if (importedLibrary.isDartCore) {
+ explicitlyImportsCore = true;
+ }
+ ImportElementImpl importElement = new ImportElementImpl(node.offset);
+ importElement.metadata = _getElementAnnotations(node.metadata);
+ StringLiteral uriLiteral = node.uri;
+ if (uriLiteral != null) {
+ importElement.uriOffset = uriLiteral.offset;
+ importElement.uriEnd = uriLiteral.end;
+ }
+ importElement.uri = node.uriContent;
+ importElement.uriExists = importedTime >= 0;
+ importElement.deferred = node.deferredKeyword != null;
+ importElement.combinators = _buildCombinators(node);
+ importElement.importedLibrary = importedLibrary;
+ setElementDocumentationComment(importElement, node);
+ SimpleIdentifier prefixNode = node.prefix;
+ if (prefixNode != null) {
+ importElement.prefixOffset = prefixNode.offset;
+ String prefixName = prefixNode.name;
+ PrefixElementImpl prefix = nameToPrefixMap[prefixName];
+ if (prefix == null) {
+ prefix = new PrefixElementImpl.forNode(prefixNode);
+ nameToPrefixMap[prefixName] = prefix;
}
- ImportElementImpl importElement = new ImportElementImpl(node.offset);
- importElement.metadata = _getElementAnnotations(node.metadata);
- StringLiteral uriLiteral = node.uri;
+ importElement.prefix = prefix;
+ prefixNode.staticElement = prefix;
+ }
+ node.element = importElement;
+ imports.add(importElement);
+ if (importedTime >= 0 &&
+ importSourceKindMap[importedSource] != SourceKind.LIBRARY) {
+ int offset = node.offset;
+ int length = node.length;
if (uriLiteral != null) {
- importElement.uriOffset = uriLiteral.offset;
- importElement.uriEnd = uriLiteral.end;
- }
- importElement.uri = node.uriContent;
- importElement.deferred = node.deferredKeyword != null;
- importElement.combinators = _buildCombinators(node);
- importElement.importedLibrary = importedLibrary;
- setElementDocumentationComment(importElement, node);
- SimpleIdentifier prefixNode = node.prefix;
- if (prefixNode != null) {
- importElement.prefixOffset = prefixNode.offset;
- String prefixName = prefixNode.name;
- PrefixElementImpl prefix = nameToPrefixMap[prefixName];
- if (prefix == null) {
- prefix = new PrefixElementImpl.forNode(prefixNode);
- nameToPrefixMap[prefixName] = prefix;
- }
- importElement.prefix = prefix;
- prefixNode.staticElement = prefix;
- }
- node.element = importElement;
- imports.add(importElement);
- if (importSourceKindMap[importedSource] != SourceKind.LIBRARY) {
- int offset = node.offset;
- int length = node.length;
- if (uriLiteral != null) {
- offset = uriLiteral.offset;
- length = uriLiteral.length;
- }
- ErrorCode errorCode = (importElement.isDeferred
- ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
- : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
- errors.add(new AnalysisError(libraryElement.source, offset, length,
- errorCode, [uriLiteral.toSource()]));
+ offset = uriLiteral.offset;
+ length = uriLiteral.length;
}
+ ErrorCode errorCode = importElement.isDeferred
+ ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
+ : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
+ errors.add(new AnalysisError(libraryElement.source, offset, length,
+ errorCode, [uriLiteral.toSource()]));
}
}
return null;
@@ -975,8 +977,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
} else {
SimpleIdentifier propertyNameNode = node.name;
String propertyName = propertyNameNode.name;
- FieldElementImpl field =
- _currentHolder.getField(propertyName, synthetic: true) as FieldElementImpl;
+ FieldElementImpl field = _currentHolder.getField(propertyName,
+ synthetic: true) as FieldElementImpl;
if (field == null) {
field = new FieldElementImpl(node.name.name, -1);
field.final2 = true;
« no previous file with comments | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698