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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1012543002: Include the common library name used in 'part of' directives. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 5 years, 9 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/src/generated/error.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index 48bebc531b056bb427d09da180e29b6181af3575..44ae3c8ab15cbc06527638019c17a1ce128f2be6 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -519,6 +519,11 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
]);
/**
+ * The constant used as an unknown common library name in parts.
+ */
+ static const String _UNKNOWN_LIBRARY_NAME = 'unknown-library-name';
+
+ /**
* Initialize a newly created task to build a library element for the given
* [target] in the given [context].
*/
@@ -556,6 +561,7 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
// Update "part" directives.
//
LibraryIdentifier libraryNameNode = null;
+ String partsLibraryName = _UNKNOWN_LIBRARY_NAME;
bool hasHtmlImport = false;
bool hasPartDirective = false;
FunctionElement entryPoint =
@@ -593,10 +599,11 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
partUri.length, CompileTimeErrorCode.PART_OF_NON_PART,
[partUri.toSource()]));
} else if (libraryNameNode == null) {
- // TODO(brianwilkerson) Collect the names declared by the part.
- // If they are all the same then we can use that name as the
- // inferred name of the library and present it in a quick-fix.
- // partLibraryNames.add(partLibraryName);
+ if (partsLibraryName == _UNKNOWN_LIBRARY_NAME) {
+ partsLibraryName = partLibraryName;
+ } else if (partsLibraryName != partLibraryName) {
+ partsLibraryName = null;
+ }
} else if (libraryNameNode.name != partLibraryName) {
errors.add(new AnalysisError.con2(librarySource, partUri.offset,
partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [
@@ -613,8 +620,17 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
}
}
if (hasPartDirective && libraryNameNode == null) {
- errors.add(new AnalysisError.con1(librarySource,
- ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART));
+ AnalysisError error;
+ if (partsLibraryName != _UNKNOWN_LIBRARY_NAME &&
+ partsLibraryName != null) {
+ error = new AnalysisErrorWithProperties.con1(librarySource,
+ ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART)
+ ..setProperty(ErrorProperty.PARTS_LIBRARY_NAME, partsLibraryName);
+ } else {
+ error = new AnalysisError.con1(librarySource,
+ ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART);
+ }
+ errors.add(error);
}
//
// Create and populate the library element.
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698