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

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

Issue 1739553003: Move errors for bad imports and exports to the directive (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error.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 82d37611e32e8f9b7ad47ea59aa24d2b784b1057..39311d18b5e289c2d9b1724e44cb292965feb92c 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -180,10 +180,16 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
node.element = exportElement;
exports.add(exportElement);
if (exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) {
+ int offset = node.offset;
+ int length = node.length;
+ if (uriLiteral != null) {
+ offset = uriLiteral.offset;
+ length = uriLiteral.length;
+ }
errors.add(new AnalysisError(
- exportedSource,
- uriLiteral.offset,
- uriLiteral.length,
+ libraryElement.source,
+ offset,
+ length,
CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
[uriLiteral.toSource()]));
}
@@ -234,11 +240,17 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
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(importedSource, uriLiteral.offset,
- uriLiteral.length, errorCode, [uriLiteral.toSource()]));
+ errors.add(new AnalysisError(libraryElement.source, offset, length,
+ errorCode, [uriLiteral.toSource()]));
}
}
}
@@ -1065,7 +1077,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
Object visitSwitchCase(SwitchCase node) {
for (Label label in node.labels) {
SimpleIdentifier labelName = label.label;
- LabelElementImpl element = new LabelElementImpl.forNode(labelName, false, true);
+ LabelElementImpl element =
+ new LabelElementImpl.forNode(labelName, false, true);
_currentHolder.addLabel(element);
labelName.staticElement = element;
}
@@ -1076,7 +1089,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
Object visitSwitchDefault(SwitchDefault node) {
for (Label label in node.labels) {
SimpleIdentifier labelName = label.label;
- LabelElementImpl element = new LabelElementImpl.forNode(labelName, false, true);
+ LabelElementImpl element =
+ new LabelElementImpl.forNode(labelName, false, true);
_currentHolder.addLabel(element);
labelName.staticElement = element;
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698