| Index: pkg/analyzer_cli/lib/src/package_analyzer.dart
|
| diff --git a/pkg/analyzer_cli/lib/src/package_analyzer.dart b/pkg/analyzer_cli/lib/src/package_analyzer.dart
|
| index 3b53b3f7e304315aaab8c1699cdf4bf12a66f672..746c77a22d14836f4e9475346f2086cc6ed2855c 100644
|
| --- a/pkg/analyzer_cli/lib/src/package_analyzer.dart
|
| +++ b/pkg/analyzer_cli/lib/src/package_analyzer.dart
|
| @@ -11,23 +11,15 @@ import 'package:analyzer/dart/element/element.dart';
|
| import 'package:analyzer/file_system/file_system.dart';
|
| import 'package:analyzer/file_system/physical_file_system.dart';
|
| import 'package:analyzer/source/package_map_resolver.dart';
|
| -import 'package:analyzer/src/context/cache.dart';
|
| -import 'package:analyzer/src/context/context.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/generated/error.dart';
|
| import 'package:analyzer/src/generated/java_io.dart';
|
| -import 'package:analyzer/src/generated/resolver.dart';
|
| import 'package:analyzer/src/generated/sdk_io.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| import 'package:analyzer/src/generated/source_io.dart';
|
| import 'package:analyzer/src/summary/format.dart';
|
| -import 'package:analyzer/src/summary/idl.dart';
|
| -import 'package:analyzer/src/summary/resynthesize.dart';
|
| +import 'package:analyzer/src/summary/package_bundle_reader.dart';
|
| import 'package:analyzer/src/summary/summarize_elements.dart';
|
| -import 'package:analyzer/src/summary/summary_sdk.dart';
|
| -import 'package:analyzer/src/task/dart.dart';
|
| -import 'package:analyzer/task/dart.dart';
|
| -import 'package:analyzer/task/model.dart';
|
| import 'package:analyzer_cli/src/analyzer_impl.dart';
|
| import 'package:analyzer_cli/src/driver.dart';
|
| import 'package:analyzer_cli/src/error_formatter.dart';
|
| @@ -35,214 +27,6 @@ import 'package:analyzer_cli/src/options.dart';
|
| import 'package:path/path.dart' as pathos;
|
|
|
| /**
|
| - * If [uri] has the `package` scheme in form of `package:pkg/file.dart`,
|
| - * return the `pkg` name. Otherwise return `null`.
|
| - */
|
| -String getPackageName(Uri uri) {
|
| - if (uri.scheme != 'package') {
|
| - return null;
|
| - }
|
| - String path = uri.path;
|
| - int index = path.indexOf('/');
|
| - if (index == -1) {
|
| - return null;
|
| - }
|
| - return path.substring(0, index);
|
| -}
|
| -
|
| -/**
|
| - * A concrete resynthesizer that serves summaries from given file paths.
|
| - */
|
| -class FileBasedSummaryResynthesizer extends SummaryResynthesizer {
|
| - final Map<String, UnlinkedUnit> unlinkedMap = <String, UnlinkedUnit>{};
|
| - final Map<String, LinkedLibrary> linkedMap = <String, LinkedLibrary>{};
|
| -
|
| - FileBasedSummaryResynthesizer(
|
| - SummaryResynthesizer parent,
|
| - AnalysisContext context,
|
| - TypeProvider typeProvider,
|
| - SourceFactory sourceFactory,
|
| - bool strongMode,
|
| - List<String> summaryPaths)
|
| - : super(parent, context, typeProvider, sourceFactory, strongMode) {
|
| - summaryPaths.forEach(_fillMaps);
|
| - }
|
| -
|
| - @override
|
| - LinkedLibrary getLinkedSummary(String uri) {
|
| - return linkedMap[uri];
|
| - }
|
| -
|
| - @override
|
| - UnlinkedUnit getUnlinkedSummary(String uri) {
|
| - return unlinkedMap[uri];
|
| - }
|
| -
|
| - @override
|
| - bool hasLibrarySummary(String uri) {
|
| - return linkedMap.containsKey(uri);
|
| - }
|
| -
|
| - void _fillMaps(String path) {
|
| - io.File file = new io.File(path);
|
| - List<int> buffer = file.readAsBytesSync();
|
| - PackageBundle bundle = new PackageBundle.fromBuffer(buffer);
|
| - for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
|
| - unlinkedMap[bundle.unlinkedUnitUris[i]] = bundle.unlinkedUnits[i];
|
| - }
|
| - for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
|
| - linkedMap[bundle.linkedLibraryUris[i]] = bundle.linkedLibraries[i];
|
| - }
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * The [ResultProvider] that provides results from input package summaries.
|
| - */
|
| -class InputPackagesResultProvider extends ResultProvider {
|
| - final InternalAnalysisContext context;
|
| - final Map<String, String> packageSummaryInputs;
|
| -
|
| - FileBasedSummaryResynthesizer resynthesizer;
|
| - SummaryResultProvider sdkProvider;
|
| -
|
| - InputPackagesResultProvider(this.context, this.packageSummaryInputs) {
|
| - InternalAnalysisContext sdkContext = context.sourceFactory.dartSdk.context;
|
| - sdkProvider = sdkContext.resultProvider;
|
| - // Set the type provider to prevent the context from computing it.
|
| - context.typeProvider = sdkContext.typeProvider;
|
| - // Create a chained resynthesizer.
|
| - resynthesizer = new FileBasedSummaryResynthesizer(
|
| - sdkProvider.resynthesizer,
|
| - context,
|
| - context.typeProvider,
|
| - context.sourceFactory,
|
| - context.analysisOptions.strongMode,
|
| - packageSummaryInputs.values.toList());
|
| - }
|
| -
|
| - bool compute(CacheEntry entry, ResultDescriptor result) {
|
| - if (sdkProvider.compute(entry, result)) {
|
| - return true;
|
| - }
|
| - AnalysisTarget target = entry.target;
|
| - // Only library results are supported for now.
|
| - if (target is Source) {
|
| - Uri uri = target.uri;
|
| - // We know how to server results to input packages.
|
| - String sourcePackageName = getPackageName(uri);
|
| - if (!packageSummaryInputs.containsKey(sourcePackageName)) {
|
| - return false;
|
| - }
|
| - // Provide known results.
|
| - String uriString = uri.toString();
|
| - if (result == LIBRARY_ELEMENT1 ||
|
| - result == LIBRARY_ELEMENT2 ||
|
| - result == LIBRARY_ELEMENT3 ||
|
| - result == LIBRARY_ELEMENT4 ||
|
| - result == LIBRARY_ELEMENT5 ||
|
| - result == LIBRARY_ELEMENT6 ||
|
| - result == LIBRARY_ELEMENT7 ||
|
| - result == LIBRARY_ELEMENT8 ||
|
| - result == LIBRARY_ELEMENT ||
|
| - false) {
|
| - LibraryElement libraryElement =
|
| - resynthesizer.getLibraryElement(uriString);
|
| - entry.setValue(result, libraryElement, TargetedResult.EMPTY_LIST);
|
| - return true;
|
| - } else if (result == READY_LIBRARY_ELEMENT2 ||
|
| - result == READY_LIBRARY_ELEMENT5 ||
|
| - result == READY_LIBRARY_ELEMENT6) {
|
| - entry.setValue(result, true, TargetedResult.EMPTY_LIST);
|
| - return true;
|
| - } else if (result == SOURCE_KIND) {
|
| - if (resynthesizer.linkedMap.containsKey(uriString)) {
|
| - entry.setValue(result, SourceKind.LIBRARY, TargetedResult.EMPTY_LIST);
|
| - return true;
|
| - }
|
| - if (resynthesizer.unlinkedMap.containsKey(uriString)) {
|
| - entry.setValue(result, SourceKind.PART, TargetedResult.EMPTY_LIST);
|
| - return true;
|
| - }
|
| - return false;
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * The [UriResolver] that knows about sources that are parts of packages which
|
| - * are served from their summaries.
|
| - */
|
| -class InSummaryPackageUriResolver extends UriResolver {
|
| - final Map<String, String> packageSummaryInputs;
|
| -
|
| - InSummaryPackageUriResolver(this.packageSummaryInputs);
|
| -
|
| - @override
|
| - Source resolveAbsolute(Uri uri, [Uri actualUri]) {
|
| - actualUri ??= uri;
|
| - String packageName = getPackageName(actualUri);
|
| - if (packageSummaryInputs.containsKey(packageName)) {
|
| - return new InSummarySource(actualUri);
|
| - }
|
| - return null;
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * A placeholder of a source that is part of a package whose analysis results
|
| - * are served from its summary. This source uses its URI as [fullName] and has
|
| - * empty contents.
|
| - */
|
| -class InSummarySource extends Source {
|
| - final Uri uri;
|
| -
|
| - InSummarySource(this.uri);
|
| -
|
| - @override
|
| - TimestampedData<String> get contents => new TimestampedData<String>(0, '');
|
| -
|
| - @override
|
| - String get encoding => uri.toString();
|
| -
|
| - @override
|
| - String get fullName => encoding;
|
| -
|
| - @override
|
| - int get hashCode => uri.hashCode;
|
| -
|
| - @override
|
| - bool get isInSystemLibrary => false;
|
| -
|
| - @override
|
| - int get modificationStamp => 0;
|
| -
|
| - @override
|
| - String get shortName => pathos.basename(fullName);
|
| -
|
| - @override
|
| - UriKind get uriKind => UriKind.PACKAGE_URI;
|
| -
|
| - @override
|
| - bool operator ==(Object object) =>
|
| - object is InSummarySource && object.uri == uri;
|
| -
|
| - @override
|
| - bool exists() => true;
|
| -
|
| - @override
|
| - Uri resolveRelativeUri(Uri relativeUri) {
|
| - Uri baseUri = uri;
|
| - return baseUri.resolveUri(relativeUri);
|
| - }
|
| -
|
| - @override
|
| - String toString() => uri.toString();
|
| -}
|
| -
|
| -/**
|
| * The hermetic whole package analyzer.
|
| */
|
| class PackageAnalyzer {
|
|
|