Chromium Code Reviews| 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..d114a0e8b77446489a56d2374dc9d71bdfd1b951 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,12 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask { |
| } |
| } |
| if (hasPartDirective && libraryNameNode == null) { |
| - errors.add(new AnalysisError.con1(librarySource, |
| - ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART)); |
| + AnalysisErrorWithProperties error = new AnalysisErrorWithProperties.con1( |
|
Brian Wilkerson
2015/03/15 23:28:14
There's no point in creating an AnalysisErrorWithP
scheglov
2015/03/15 23:38:15
Done.
|
| + librarySource, ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART); |
| + if (partsLibraryName != _UNKNOWN_LIBRARY_NAME) { |
|
Brian Wilkerson
2015/03/15 23:28:14
"&& partsLibraryName != null"?
I'm guessing we do
scheglov
2015/03/15 23:38:15
Done.
|
| + error.setProperty(ErrorProperty.PARTS_LIBRARY_NAME, partsLibraryName); |
| + } |
| + errors.add(error); |
| } |
| // |
| // Create and populate the library element. |