OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.task.dart; | 5 library analyzer.src.task.dart; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
9 | 9 |
10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 if (libraryNameNode == null) { | 1324 if (libraryNameNode == null) { |
1325 libraryNameNode = directive.name; | 1325 libraryNameNode = directive.name; |
1326 directivesToResolve.add(directive); | 1326 directivesToResolve.add(directive); |
1327 } | 1327 } |
1328 } else if (directive is PartDirective) { | 1328 } else if (directive is PartDirective) { |
1329 PartDirective partDirective = directive; | 1329 PartDirective partDirective = directive; |
1330 StringLiteral partUri = partDirective.uri; | 1330 StringLiteral partUri = partDirective.uri; |
1331 Source partSource = partDirective.source; | 1331 Source partSource = partDirective.source; |
1332 hasPartDirective = true; | 1332 hasPartDirective = true; |
1333 CompilationUnit partUnit = partUnitMap[partSource]; | 1333 CompilationUnit partUnit = partUnitMap[partSource]; |
1334 if (partUnit != null && context.exists(partSource)) { | 1334 if (partUnit != null) { |
1335 CompilationUnitElementImpl partElement = partUnit.element; | 1335 CompilationUnitElementImpl partElement = partUnit.element; |
1336 partElement.uriOffset = partUri.offset; | 1336 partElement.uriOffset = partUri.offset; |
1337 partElement.uriEnd = partUri.end; | 1337 partElement.uriEnd = partUri.end; |
1338 partElement.uri = partDirective.uriContent; | 1338 partElement.uri = partDirective.uriContent; |
1339 // | 1339 // |
1340 // Validate that the part contains a part-of directive with the same | 1340 // Validate that the part contains a part-of directive with the same |
1341 // name as the library. | 1341 // name as the library. |
1342 // | 1342 // |
1343 String partLibraryName = | 1343 if (context.exists(partSource)) { |
1344 _getPartLibraryName(partSource, partUnit, directivesToResolve); | 1344 String partLibraryName = |
1345 if (partLibraryName == null) { | 1345 _getPartLibraryName(partSource, partUnit, directivesToResolve); |
1346 errors.add(new AnalysisError(librarySource, partUri.offset, | 1346 if (partLibraryName == null) { |
1347 partUri.length, CompileTimeErrorCode.PART_OF_NON_PART, | 1347 errors.add(new AnalysisError(librarySource, partUri.offset, |
1348 [partUri.toSource()])); | 1348 partUri.length, CompileTimeErrorCode.PART_OF_NON_PART, |
1349 } else if (libraryNameNode == null) { | 1349 [partUri.toSource()])); |
1350 if (partsLibraryName == _UNKNOWN_LIBRARY_NAME) { | 1350 } else if (libraryNameNode == null) { |
1351 partsLibraryName = partLibraryName; | 1351 if (partsLibraryName == _UNKNOWN_LIBRARY_NAME) { |
1352 } else if (partsLibraryName != partLibraryName) { | 1352 partsLibraryName = partLibraryName; |
1353 partsLibraryName = null; | 1353 } else if (partsLibraryName != partLibraryName) { |
| 1354 partsLibraryName = null; |
| 1355 } |
| 1356 } else if (libraryNameNode.name != partLibraryName) { |
| 1357 errors.add(new AnalysisError(librarySource, partUri.offset, |
| 1358 partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [ |
| 1359 libraryNameNode.name, |
| 1360 partLibraryName |
| 1361 ])); |
1354 } | 1362 } |
1355 } else if (libraryNameNode.name != partLibraryName) { | |
1356 errors.add(new AnalysisError(librarySource, partUri.offset, | |
1357 partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [ | |
1358 libraryNameNode.name, | |
1359 partLibraryName | |
1360 ])); | |
1361 } | 1363 } |
1362 if (entryPoint == null) { | 1364 if (entryPoint == null) { |
1363 entryPoint = _findEntryPoint(partElement); | 1365 entryPoint = _findEntryPoint(partElement); |
1364 } | 1366 } |
1365 directive.element = partElement; | 1367 directive.element = partElement; |
1366 sourcedCompilationUnits.add(partElement); | 1368 sourcedCompilationUnits.add(partElement); |
1367 } | 1369 } |
1368 } | 1370 } |
1369 } | 1371 } |
1370 if (hasPartDirective && libraryNameNode == null) { | 1372 if (hasPartDirective && libraryNameNode == null) { |
(...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3384 @override | 3386 @override |
3385 bool moveNext() { | 3387 bool moveNext() { |
3386 if (_newSources.isEmpty) { | 3388 if (_newSources.isEmpty) { |
3387 return false; | 3389 return false; |
3388 } | 3390 } |
3389 currentTarget = _newSources.first; | 3391 currentTarget = _newSources.first; |
3390 _newSources.remove(currentTarget); | 3392 _newSources.remove(currentTarget); |
3391 return true; | 3393 return true; |
3392 } | 3394 } |
3393 } | 3395 } |
OLD | NEW |