Chromium Code Reviews| 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 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1503 CompilationUnit partUnit = partUnits[i]; | 1503 CompilationUnit partUnit = partUnits[i]; |
| 1504 Source partSource = partUnit.element.source; | 1504 Source partSource = partUnit.element.source; |
| 1505 partUnitMap[partSource] = partUnit; | 1505 partUnitMap[partSource] = partUnit; |
| 1506 } | 1506 } |
| 1507 // | 1507 // |
| 1508 // Update "part" directives. | 1508 // Update "part" directives. |
| 1509 // | 1509 // |
| 1510 LibraryIdentifier libraryNameNode = null; | 1510 LibraryIdentifier libraryNameNode = null; |
| 1511 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; | 1511 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; |
| 1512 bool hasPartDirective = false; | 1512 bool hasPartDirective = false; |
| 1513 Set<String> seenPartUris = new Set<String>(); | 1513 Set<Source> seenPartSources = new Set<Source>(); |
| 1514 FunctionElement entryPoint = | 1514 FunctionElement entryPoint = |
| 1515 _findEntryPoint(definingCompilationUnitElement); | 1515 _findEntryPoint(definingCompilationUnitElement); |
| 1516 List<Directive> directivesToResolve = <Directive>[]; | 1516 List<Directive> directivesToResolve = <Directive>[]; |
| 1517 List<CompilationUnitElementImpl> sourcedCompilationUnits = | 1517 List<CompilationUnitElementImpl> sourcedCompilationUnits = |
| 1518 <CompilationUnitElementImpl>[]; | 1518 <CompilationUnitElementImpl>[]; |
| 1519 NodeList<Directive> directives = definingCompilationUnit.directives; | 1519 NodeList<Directive> directives = definingCompilationUnit.directives; |
| 1520 int directiveLength = directives.length; | 1520 int directiveLength = directives.length; |
| 1521 for (int i = 0; i < directiveLength; i++) { | 1521 for (int i = 0; i < directiveLength; i++) { |
| 1522 Directive directive = directives[i]; | 1522 Directive directive = directives[i]; |
| 1523 if (directive is LibraryDirective) { | 1523 if (directive is LibraryDirective) { |
| 1524 libraryNameNode = directive.name; | 1524 libraryNameNode = directive.name; |
| 1525 directivesToResolve.add(directive); | 1525 directivesToResolve.add(directive); |
| 1526 } else if (directive is PartDirective) { | 1526 } else if (directive is PartDirective) { |
| 1527 StringLiteral partUri = directive.uri; | 1527 StringLiteral partUri = directive.uri; |
| 1528 Source partSource = directive.uriSource; | 1528 Source partSource = directive.uriSource; |
| 1529 hasPartDirective = true; | 1529 hasPartDirective = true; |
| 1530 CompilationUnit partUnit = partUnitMap[partSource]; | 1530 CompilationUnit partUnit = partUnitMap[partSource]; |
| 1531 if (partUnit != null) { | 1531 if (partUnit != null) { |
| 1532 CompilationUnitElementImpl partElement = partUnit.element; | 1532 CompilationUnitElementImpl partElement = partUnit.element; |
| 1533 partElement.uriOffset = partUri.offset; | 1533 partElement.uriOffset = partUri.offset; |
| 1534 partElement.uriEnd = partUri.end; | 1534 partElement.uriEnd = partUri.end; |
| 1535 partElement.uri = directive.uriContent; | 1535 partElement.uri = directive.uriContent; |
| 1536 // | 1536 // |
| 1537 // Validate that the part URI is unique in the library. | 1537 // Validate that the part source is unique in the library. |
| 1538 // | 1538 // |
| 1539 if (!seenPartUris.add(directive.uriContent)) { | 1539 if (!seenPartSources.add(partSource)) { |
| 1540 errors.add(new AnalysisError( | 1540 errors.add(new AnalysisError( |
| 1541 librarySource, | 1541 librarySource, |
| 1542 partUri.offset, | 1542 partUri.offset, |
| 1543 partUri.length, | 1543 partUri.length, |
| 1544 CompileTimeErrorCode.DUPLICATE_PART, | 1544 CompileTimeErrorCode.DUPLICATE_PART, |
| 1545 [directive.uriContent])); | 1545 [directive.uriContent])); |
|
Brian Wilkerson
2016/10/06 22:14:11
We should either restore the argument to the messa
| |
| 1546 } | 1546 } |
| 1547 // | 1547 // |
| 1548 // Validate that the part contains a part-of directive with the same | 1548 // Validate that the part contains a part-of directive with the same |
| 1549 // name as the library. | 1549 // name as the library. |
| 1550 // | 1550 // |
| 1551 if (context.exists(partSource)) { | 1551 if (context.exists(partSource)) { |
| 1552 String partLibraryName = | 1552 String partLibraryName = |
| 1553 _getPartLibraryName(partSource, partUnit, directivesToResolve); | 1553 _getPartLibraryName(partSource, partUnit, directivesToResolve); |
| 1554 if (partLibraryName == null) { | 1554 if (partLibraryName == null) { |
| 1555 errors.add(new AnalysisError( | 1555 errors.add(new AnalysisError( |
| (...skipping 4888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6444 | 6444 |
| 6445 @override | 6445 @override |
| 6446 bool moveNext() { | 6446 bool moveNext() { |
| 6447 if (_newSources.isEmpty) { | 6447 if (_newSources.isEmpty) { |
| 6448 return false; | 6448 return false; |
| 6449 } | 6449 } |
| 6450 currentTarget = _newSources.removeLast(); | 6450 currentTarget = _newSources.removeLast(); |
| 6451 return true; | 6451 return true; |
| 6452 } | 6452 } |
| 6453 } | 6453 } |
| OLD | NEW |