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 4069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4080 sourceKind = SourceKind.UNKNOWN; | 4080 sourceKind = SourceKind.UNKNOWN; |
4081 } else if (hasPartOfDirective && !hasNonPartOfDirective) { | 4081 } else if (hasPartOfDirective && !hasNonPartOfDirective) { |
4082 sourceKind = SourceKind.PART; | 4082 sourceKind = SourceKind.PART; |
4083 } | 4083 } |
4084 // | 4084 // |
4085 // Compute referenced names. | 4085 // Compute referenced names. |
4086 // | 4086 // |
4087 ReferencedNames referencedNames = new ReferencedNames(_source); | 4087 ReferencedNames referencedNames = new ReferencedNames(_source); |
4088 new ReferencedNamesBuilder(referencedNames).build(unit); | 4088 new ReferencedNamesBuilder(referencedNames).build(unit); |
4089 // | 4089 // |
4090 // Record outputs. | 4090 // Compute source lists. |
4091 // | 4091 // |
4092 List<Source> explicitlyImportedSources = | 4092 List<Source> explicitlyImportedSources = |
4093 explicitlyImportedSourceSet.toList(); | 4093 explicitlyImportedSourceSet.toList(); |
4094 List<Source> exportedSources = exportedSourceSet.toList(); | 4094 List<Source> exportedSources = exportedSourceSet.toList(); |
4095 List<Source> importedSources = importedSourceSet.toList(); | 4095 List<Source> importedSources = importedSourceSet.toList(); |
4096 List<Source> includedSources = includedSourceSet.toList(); | 4096 List<Source> includedSources = includedSourceSet.toList(); |
4097 List<AnalysisError> parseErrors = getUniqueErrors(errorListener.errors); | |
4098 List<Source> unitSources = <Source>[_source]..addAll(includedSourceSet); | 4097 List<Source> unitSources = <Source>[_source]..addAll(includedSourceSet); |
4099 List<Source> referencedSources = (new Set<Source>() | |
4100 ..addAll(importedSources) | |
4101 ..addAll(exportedSources) | |
4102 ..addAll(unitSources)) | |
4103 .toList(); | |
4104 List<LibrarySpecificUnit> librarySpecificUnits = | 4098 List<LibrarySpecificUnit> librarySpecificUnits = |
4105 unitSources.map((s) => new LibrarySpecificUnit(_source, s)).toList(); | 4099 unitSources.map((s) => new LibrarySpecificUnit(_source, s)).toList(); |
| 4100 // |
| 4101 // Compute referenced sources. |
| 4102 // |
| 4103 Set<Source> referencedSources = new Set<Source>(); |
| 4104 referencedSources.add(coreLibrarySource); |
| 4105 referencedSources.addAll(unitSources); |
| 4106 for (Directive directive in unit.directives) { |
| 4107 if (directive is NamespaceDirective) { |
| 4108 referencedSources.add(directive.uriSource); |
| 4109 for (Configuration configuration in directive.configurations) { |
| 4110 referencedSources.add(configuration.uriSource); |
| 4111 } |
| 4112 } |
| 4113 } |
| 4114 referencedSources.removeWhere((source) => source == null); |
| 4115 // |
| 4116 // Record outputs. |
| 4117 // |
| 4118 List<AnalysisError> parseErrors = getUniqueErrors(errorListener.errors); |
4106 outputs[EXPLICITLY_IMPORTED_LIBRARIES] = explicitlyImportedSources; | 4119 outputs[EXPLICITLY_IMPORTED_LIBRARIES] = explicitlyImportedSources; |
4107 outputs[EXPORTED_LIBRARIES] = exportedSources; | 4120 outputs[EXPORTED_LIBRARIES] = exportedSources; |
4108 outputs[IMPORTED_LIBRARIES] = importedSources; | 4121 outputs[IMPORTED_LIBRARIES] = importedSources; |
4109 outputs[INCLUDED_PARTS] = includedSources; | 4122 outputs[INCLUDED_PARTS] = includedSources; |
4110 outputs[LIBRARY_SPECIFIC_UNITS] = librarySpecificUnits; | 4123 outputs[LIBRARY_SPECIFIC_UNITS] = librarySpecificUnits; |
4111 outputs[PARSE_ERRORS] = parseErrors; | 4124 outputs[PARSE_ERRORS] = parseErrors; |
4112 outputs[PARSED_UNIT] = unit; | 4125 outputs[PARSED_UNIT] = unit; |
4113 outputs[REFERENCED_NAMES] = referencedNames; | 4126 outputs[REFERENCED_NAMES] = referencedNames; |
4114 outputs[REFERENCED_SOURCES] = referencedSources; | 4127 outputs[REFERENCED_SOURCES] = referencedSources.toList(); |
4115 outputs[SOURCE_KIND] = sourceKind; | 4128 outputs[SOURCE_KIND] = sourceKind; |
4116 outputs[UNITS] = unitSources; | 4129 outputs[UNITS] = unitSources; |
4117 } | 4130 } |
4118 | 4131 |
4119 /** | 4132 /** |
4120 * Return the result of resolving the URI of the given URI-based [directive] | 4133 * Return the result of resolving the URI of the given URI-based [directive] |
4121 * against the URI of the given library, or `null` if the URI is not valid. | 4134 * against the URI of the given library, or `null` if the URI is not valid. |
4122 */ | 4135 */ |
4123 Source _resolveDirective(UriBasedDirective directive) { | 4136 Source _resolveDirective(UriBasedDirective directive) { |
4124 bool isImport = directive is ImportDirective; | 4137 bool isImport = directive is ImportDirective; |
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6428 | 6441 |
6429 @override | 6442 @override |
6430 bool moveNext() { | 6443 bool moveNext() { |
6431 if (_newSources.isEmpty) { | 6444 if (_newSources.isEmpty) { |
6432 return false; | 6445 return false; |
6433 } | 6446 } |
6434 currentTarget = _newSources.removeLast(); | 6447 currentTarget = _newSources.removeLast(); |
6435 return true; | 6448 return true; |
6436 } | 6449 } |
6437 } | 6450 } |
OLD | NEW |