Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:convert'; | 5 import 'dart:convert'; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:analyzer/src/generated/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 11 import 'package:analyzer/src/summary/format.dart'; | 11 import 'package:analyzer/src/summary/format.dart'; |
| 12 import 'package:analyzer/src/summary/idl.dart'; | 12 import 'package:analyzer/src/summary/idl.dart'; |
| 13 import 'package:analyzer/src/summary/link.dart'; | 13 import 'package:analyzer/src/summary/link.dart'; |
| 14 import 'package:analyzer/src/summary/package_bundle_reader.dart'; | 14 import 'package:analyzer/src/summary/package_bundle_reader.dart'; |
| 15 import 'package:analyzer/src/summary/summarize_elements.dart'; | 15 import 'package:analyzer/src/summary/summarize_elements.dart'; |
| 16 import 'package:analyzer/src/util/fast_uri.dart'; | 16 import 'package:analyzer/src/util/fast_uri.dart'; |
| 17 import 'package:convert/convert.dart'; | 17 import 'package:convert/convert.dart'; |
| 18 import 'package:crypto/crypto.dart'; | 18 import 'package:crypto/crypto.dart'; |
| 19 import 'package:meta/meta.dart'; | 19 import 'package:meta/meta.dart'; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Return the [Folder] where bundles for the given [absoluteUri] should be | 22 * Return the [Folder] where bundles for the given [absoluteUri] should be |
| 23 * looked for. This folder should contain corresponding `*.full.ds` files, | 23 * looked for. This folder should contain corresponding `*.full.ds` files, |
| 24 * possibly more than one one. Return `null` if the given [absoluteUri] | 24 * possibly more than one one. Return `null` if the given [absoluteUri] |
| 25 * does not have the expected structure, so the output path cannot be computed. | 25 * does not have the expected structure, so the output path cannot be computed. |
| 26 */ | 26 */ |
| 27 typedef Folder GetOutputFolder(Uri absoluteUri); | 27 typedef Folder GetOutputFolder(Uri absoluteUri); |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Load linked packages on demand from [SummaryProvider]. | |
| 31 */ | |
| 32 class BazelResultProvider extends ResynthesizerResultProvider { | |
| 33 final SummaryDataStore dataStore; | |
| 34 final SummaryProvider summaryProvider; | |
| 35 | |
| 36 final Map<Source, bool> sourceToSuccessMap = <Source, bool>{}; | |
| 37 final Set<Package> addedPackages = new Set<Package>(); | |
| 38 | |
| 39 factory BazelResultProvider(SummaryProvider summaryProvider) { | |
| 40 SummaryDataStore dataStore = new SummaryDataStore(const <String>[]); | |
| 41 return new BazelResultProvider._( | |
| 42 summaryProvider.context, dataStore, summaryProvider); | |
| 43 } | |
| 44 | |
| 45 BazelResultProvider._(InternalAnalysisContext context, | |
|
Brian Wilkerson
2016/09/29 21:54:07
Should the context always be the same as the one i
| |
| 46 SummaryDataStore dataStore, this.summaryProvider) | |
| 47 : dataStore = dataStore, | |
| 48 super(context, dataStore) { | |
| 49 AnalysisContext sdkContext = context.sourceFactory.dartSdk.context; | |
| 50 createResynthesizer(sdkContext, sdkContext.typeProvider); | |
| 51 } | |
| 52 | |
| 53 @override | |
| 54 bool hasResultsForSource(Source source) { | |
| 55 return sourceToSuccessMap.putIfAbsent(source, () { | |
| 56 List<Package> packages = summaryProvider.getLinkedPackages(source); | |
| 57 if (packages == null) { | |
| 58 return false; | |
| 59 } | |
| 60 for (Package package in packages) { | |
| 61 if (addedPackages.add(package)) { | |
| 62 dataStore.addBundle(null, package.unlinked); | |
| 63 dataStore.addBundle(null, package.linked); | |
| 64 } | |
| 65 } | |
| 66 String uriString = source.uri.toString(); | |
| 67 return resynthesizer.hasLibrarySummary(uriString); | |
| 68 }); | |
| 69 } | |
| 70 } | |
| 71 | |
| 72 /** | |
| 30 * Information about a Dart package in Bazel. | 73 * Information about a Dart package in Bazel. |
| 31 */ | 74 */ |
| 32 class Package { | 75 class Package { |
| 33 final File unlinkedFile; | 76 final File unlinkedFile; |
| 34 final PackageBundle unlinked; | 77 final PackageBundle unlinked; |
| 35 final Set<String> _unitUris = new Set<String>(); | 78 final Set<String> _unitUris = new Set<String>(); |
| 36 | 79 |
| 37 PackageBundle _linked; | 80 PackageBundle _linked; |
| 38 | 81 |
| 39 Package(this.unlinkedFile, this.unlinked) { | 82 Package(this.unlinkedFile, this.unlinked) { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 appendDependencies(this); | 402 appendDependencies(this); |
| 360 if (transitiveDependencies.any((node) => node.failed)) { | 403 if (transitiveDependencies.any((node) => node.failed)) { |
| 361 failed = true; | 404 failed = true; |
| 362 } | 405 } |
| 363 } | 406 } |
| 364 } | 407 } |
| 365 | 408 |
| 366 @override | 409 @override |
| 367 String toString() => package.toString(); | 410 String toString() => package.toString(); |
| 368 } | 411 } |
| OLD | NEW |