OLD | NEW |
---|---|
1 import 'dart:io' as io; | 1 import 'dart:io' as io; |
2 | 2 |
3 import 'package:analyzer/dart/element/element.dart'; | 3 import 'package:analyzer/dart/element/element.dart'; |
4 import 'package:analyzer/src/context/cache.dart'; | 4 import 'package:analyzer/src/context/cache.dart'; |
5 import 'package:analyzer/src/context/context.dart'; | 5 import 'package:analyzer/src/context/context.dart'; |
6 import 'package:analyzer/src/dart/element/element.dart'; | 6 import 'package:analyzer/src/dart/element/element.dart'; |
7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
8 import 'package:analyzer/src/generated/java_io.dart'; | 8 import 'package:analyzer/src/generated/java_io.dart'; |
9 import 'package:analyzer/src/generated/resolver.dart'; | 9 import 'package:analyzer/src/generated/resolver.dart'; |
10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
11 import 'package:analyzer/src/generated/source_io.dart'; | 11 import 'package:analyzer/src/generated/source_io.dart'; |
12 import 'package:analyzer/src/generated/utilities_dart.dart'; | 12 import 'package:analyzer/src/generated/utilities_dart.dart'; |
13 import 'package:analyzer/src/summary/format.dart'; | |
13 import 'package:analyzer/src/summary/idl.dart'; | 14 import 'package:analyzer/src/summary/idl.dart'; |
14 import 'package:analyzer/src/summary/resynthesize.dart'; | 15 import 'package:analyzer/src/summary/resynthesize.dart'; |
15 import 'package:analyzer/src/task/dart.dart'; | 16 import 'package:analyzer/src/task/dart.dart'; |
16 import 'package:analyzer/src/util/fast_uri.dart'; | 17 import 'package:analyzer/src/util/fast_uri.dart'; |
17 import 'package:analyzer/task/dart.dart'; | 18 import 'package:analyzer/task/dart.dart'; |
18 import 'package:analyzer/task/model.dart'; | 19 import 'package:analyzer/task/model.dart'; |
19 import 'package:path/path.dart' as pathos; | 20 import 'package:path/path.dart' as pathos; |
20 | 21 |
21 /** | 22 /** |
22 * The [ResultProvider] that provides results from input package summaries. | 23 * The [ResultProvider] that provides results from input package summaries. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 * summary package bundles. It contains maps which can be used to find linked | 267 * summary package bundles. It contains maps which can be used to find linked |
267 * and unlinked summaries by URI. | 268 * and unlinked summaries by URI. |
268 */ | 269 */ |
269 class SummaryDataStore { | 270 class SummaryDataStore { |
270 /** | 271 /** |
271 * List of all [PackageBundle]s. | 272 * List of all [PackageBundle]s. |
272 */ | 273 */ |
273 final List<PackageBundle> bundles = <PackageBundle>[]; | 274 final List<PackageBundle> bundles = <PackageBundle>[]; |
274 | 275 |
275 /** | 276 /** |
277 * List of dependency information for the package bundles in this | |
278 * [SummaryDataStore], in a form that is ready to store in a newly generated. | |
scheglov
2016/08/09 02:39:44
Extra '.' at the end.
Paul Berry
2016/08/09 16:30:30
Fixed.
| |
279 * summary. Computing this information has nonzero cost, so it is only | |
280 * recorded if the [SummaryDataStore] is constructed with the argument | |
281 * `recordDependencies`. Otherwise `null`. | |
282 */ | |
283 final List<PackageDependencyInfoBuilder> dependencies; | |
284 | |
285 /** | |
276 * Map from the URI of a compilation unit to the unlinked summary of that | 286 * Map from the URI of a compilation unit to the unlinked summary of that |
277 * compilation unit. | 287 * compilation unit. |
278 */ | 288 */ |
279 final Map<String, UnlinkedUnit> unlinkedMap = <String, UnlinkedUnit>{}; | 289 final Map<String, UnlinkedUnit> unlinkedMap = <String, UnlinkedUnit>{}; |
280 | 290 |
281 /** | 291 /** |
282 * Map from the URI of a library to the linked summary of that library. | 292 * Map from the URI of a library to the linked summary of that library. |
283 */ | 293 */ |
284 final Map<String, LinkedLibrary> linkedMap = <String, LinkedLibrary>{}; | 294 final Map<String, LinkedLibrary> linkedMap = <String, LinkedLibrary>{}; |
285 | 295 |
286 /** | 296 /** |
287 * Map from the URI of a library to the summary path that contained it. | 297 * Map from the URI of a library to the summary path that contained it. |
288 */ | 298 */ |
289 final Map<String, String> uriToSummaryPath = <String, String>{}; | 299 final Map<String, String> uriToSummaryPath = <String, String>{}; |
290 | 300 |
291 SummaryDataStore(Iterable<String> summaryPaths) { | 301 /** |
302 * Create a [SummaryDataStore] and populate it with the summaries in | |
303 * [summaryPaths]. If [recordDependencyInfo] is `true`, record | |
304 * [PackageDependencyInfo] for each summary, for later access via | |
305 * [dependencies]. | |
306 */ | |
307 SummaryDataStore(Iterable<String> summaryPaths, | |
308 {bool recordDependencyInfo: false}) | |
309 : dependencies = | |
310 recordDependencyInfo ? <PackageDependencyInfoBuilder>[] : null { | |
292 summaryPaths.forEach(_fillMaps); | 311 summaryPaths.forEach(_fillMaps); |
293 } | 312 } |
294 | 313 |
295 /** | 314 /** |
296 * Add the given [bundle] loaded from the file with the given [path]. | 315 * Add the given [bundle] loaded from the file with the given [path]. |
297 */ | 316 */ |
298 void addBundle(String path, PackageBundle bundle) { | 317 void addBundle(String path, PackageBundle bundle) { |
299 bundles.add(bundle); | 318 bundles.add(bundle); |
319 if (dependencies != null) { | |
320 Set<String> includedPackageNames = new Set<String>(); | |
321 bool includesDartUris = false; | |
322 bool includesFileUris = false; | |
323 for (String uriString in bundle.unlinkedUnitUris) { | |
324 Uri uri = FastUri.parse(uriString); | |
325 String scheme = uri.scheme; | |
326 if (scheme == 'package') { | |
327 List<String> pathSegments = uri.pathSegments; | |
328 includedPackageNames.add(pathSegments.isEmpty ? '' : pathSegments[0]); | |
329 } else if (scheme == 'file') { | |
330 includesFileUris = true; | |
331 } else if (scheme == 'dart') { | |
332 includesDartUris = true; | |
333 } | |
334 } | |
335 dependencies.add(new PackageDependencyInfoBuilder( | |
336 includedPackageNames: includedPackageNames.toList()..sort(), | |
337 includesDartUris: includesDartUris, | |
338 includesFileUris: includesFileUris, | |
339 apiSignature: bundle.apiSignature, | |
340 summaryPath: path)); | |
341 } | |
300 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { | 342 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { |
301 String uri = bundle.unlinkedUnitUris[i]; | 343 String uri = bundle.unlinkedUnitUris[i]; |
302 uriToSummaryPath[uri] = path; | 344 uriToSummaryPath[uri] = path; |
303 unlinkedMap[uri] = bundle.unlinkedUnits[i]; | 345 unlinkedMap[uri] = bundle.unlinkedUnits[i]; |
304 } | 346 } |
305 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { | 347 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { |
306 String uri = bundle.linkedLibraryUris[i]; | 348 String uri = bundle.linkedLibraryUris[i]; |
307 linkedMap[uri] = bundle.linkedLibraries[i]; | 349 linkedMap[uri] = bundle.linkedLibraries[i]; |
308 } | 350 } |
309 } | 351 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 * also provides [summaryPath]. | 421 * also provides [summaryPath]. |
380 */ | 422 */ |
381 class _InSummaryFallbackSource extends FileBasedSource | 423 class _InSummaryFallbackSource extends FileBasedSource |
382 implements InSummarySource { | 424 implements InSummarySource { |
383 @override | 425 @override |
384 final String summaryPath; | 426 final String summaryPath; |
385 | 427 |
386 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) | 428 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) |
387 : super(file, uri); | 429 : super(file, uri); |
388 } | 430 } |
OLD | NEW |