Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: pkg/analyzer_cli/lib/src/package_analyzer.dart

Issue 1722413002: Extract PackageBundleAssembler and use for SDK and package summary generation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/tool/summary/build_sdk_summaries.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0bad2605798be96f5e064f084f3f5ea9f59ed9ce..2241634786890a9ce91fc12d389215dbfcd4f752 100644
--- a/pkg/analyzer_cli/lib/src/package_analyzer.dart
+++ b/pkg/analyzer_cli/lib/src/package_analyzer.dart
@@ -4,7 +4,6 @@
library analyzer_cli.src.package_analyzer;
-import 'dart:convert';
import 'dart:core' hide Resource;
import 'dart:io' as io;
@@ -32,7 +31,6 @@ import 'package:analyzer_cli/src/analyzer_impl.dart';
import 'package:analyzer_cli/src/driver.dart';
import 'package:analyzer_cli/src/error_formatter.dart';
import 'package:analyzer_cli/src/options.dart';
-import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as pathos;
/**
@@ -249,12 +247,6 @@ class PackageAnalyzer {
InternalAnalysisContext context;
final List<Source> explicitSources = <Source>[];
- final List<String> linkedLibraryUris = <String>[];
- final List<LinkedLibraryBuilder> linkedLibraries = <LinkedLibraryBuilder>[];
- final List<String> unlinkedUnitUris = <String>[];
- final List<UnlinkedUnitBuilder> unlinkedUnits = <UnlinkedUnitBuilder>[];
- final List<String> unlinkedUnitHashes = <String>[];
-
PackageAnalyzer(this.options);
/**
@@ -306,21 +298,17 @@ class PackageAnalyzer {
// Write summary for Dart libraries.
if (options.packageSummaryOutput != null) {
+ PackageBundleAssembler assembler = new PackageBundleAssembler();
for (Source source in context.librarySources) {
if (pathos.isWithin(packageLibPath, source.fullName)) {
LibraryElement libraryElement = context.getLibraryElement(source);
if (libraryElement != null) {
- _serializeSingleLibrary(libraryElement);
+ assembler.serializeLibraryElement(libraryElement);
}
}
}
// Write the whole package bundle.
- PackageBundleBuilder sdkBundle = new PackageBundleBuilder(
- linkedLibraryUris: linkedLibraryUris,
- linkedLibraries: linkedLibraries,
- unlinkedUnitUris: unlinkedUnitUris,
- unlinkedUnits: unlinkedUnits,
- unlinkedUnitHashes: unlinkedUnitHashes);
+ PackageBundleBuilder sdkBundle = assembler.assemble();
io.File file = new io.File(options.packageSummaryOutput);
file.writeAsBytesSync(sdkBundle.toBuffer(), mode: io.FileMode.WRITE_ONLY);
}
@@ -385,15 +373,6 @@ class PackageAnalyzer {
}
/**
- * Compute a hash of the given file contents.
- */
- String _hash(String contents) {
- MD5 md5 = new MD5();
- md5.add(UTF8.encode(contents));
- return CryptoUtils.bytesToHex(md5.close());
- }
-
- /**
* Print errors for all explicit sources.
*/
void _printErrors() {
@@ -408,20 +387,4 @@ class PackageAnalyzer {
formatter.formatErrors([errorInfo]);
}
}
-
- /**
- * Serialize the library with the given [element].
- */
- void _serializeSingleLibrary(LibraryElement element) {
- String uri = element.source.uri.toString();
- LibrarySerializationResult libraryResult =
- serializeLibrary(element, context.typeProvider, options.strongMode);
- linkedLibraryUris.add(uri);
- linkedLibraries.add(libraryResult.linked);
- unlinkedUnitUris.addAll(libraryResult.unitUris);
- unlinkedUnits.addAll(libraryResult.unlinkedUnits);
- for (Source source in libraryResult.unitSources) {
- unlinkedUnitHashes.add(_hash(source.contents.data));
- }
- }
}
« no previous file with comments | « pkg/analyzer/tool/summary/build_sdk_summaries.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698