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

Unified Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 2228083002: Make API signature based only on unlinked data. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/summarize_elements.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 65b92432d77b6aa3d8052da29f380ca2a03d2201..9f08b40bbab87e8e1d4808ceab5885e46eb80246 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -12,7 +12,6 @@ import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/member.dart';
import 'package:analyzer/src/dart/element/type.dart';
-import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
@@ -20,11 +19,11 @@ import 'package:analyzer/src/summary/api_signature.dart';
import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/name_filter.dart';
+import 'package:analyzer/src/summary/package_bundle_reader.dart';
import 'package:analyzer/src/summary/summarize_const_expr.dart';
import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as path;
-import 'package:analyzer/src/summary/package_bundle_reader.dart';
/**
* Serialize all the elements in [lib] to a summary using [ctx] as the context
@@ -140,6 +139,8 @@ class PackageBundleAssembler {
final List<LinkedLibraryBuilder> _linkedLibraries = <LinkedLibraryBuilder>[];
final List<String> _unlinkedUnitUris = <String>[];
final List<UnlinkedUnitBuilder> _unlinkedUnits = <UnlinkedUnitBuilder>[];
+ final Map<String, UnlinkedUnitBuilder> _unlinkedUnitMap =
+ <String, UnlinkedUnitBuilder>{};
final List<String> _unlinkedUnitHashes;
final List<PackageDependencyInfoBuilder> _dependencies =
<PackageDependencyInfoBuilder>[];
@@ -166,22 +167,16 @@ class PackageBundleAssembler {
}
/**
- * Use the dependency information in [summaryDataStore] to populate the
- * dependencies in the package bundle being assembled.
- */
- void recordDependencies(SummaryDataStore summaryDataStore) {
- _dependencies.addAll(summaryDataStore.dependencies);
- }
-
- /**
* Add a fallback compilation unit to the package bundle, corresponding to
* the compilation unit located at [source].
*/
void addFallbackUnit(Source source) {
String uri = source.uri.toString();
+ UnlinkedUnitBuilder unit = new UnlinkedUnitBuilder(
+ fallbackModePath: path.relative(source.fullName));
_unlinkedUnitUris.add(uri);
- _unlinkedUnits.add(new UnlinkedUnitBuilder(
- fallbackModePath: path.relative(source.fullName)));
+ _unlinkedUnits.add(unit);
+ _unlinkedUnitMap[uri] = unit;
}
void addLinkedLibrary(String uri, LinkedLibraryBuilder library) {
@@ -198,6 +193,7 @@ class PackageBundleAssembler {
String uri, UnlinkedUnitBuilder unit, String hash) {
_unlinkedUnitUris.add(uri);
_unlinkedUnits.add(unit);
+ _unlinkedUnitMap[uri] = unit;
_unlinkedUnitHashes?.add(hash);
}
@@ -205,7 +201,7 @@ class PackageBundleAssembler {
* Assemble a new [PackageBundleBuilder] using the gathered information.
*/
PackageBundleBuilder assemble() {
- PackageBundleBuilder packageBundle = new PackageBundleBuilder(
+ return new PackageBundleBuilder(
linkedLibraryUris: _linkedLibraryUris,
linkedLibraries: _linkedLibraries,
unlinkedUnitUris: _unlinkedUnitUris,
@@ -213,11 +209,16 @@ class PackageBundleAssembler {
unlinkedUnitHashes: _unlinkedUnitHashes,
majorVersion: currentMajorVersion,
minorVersion: currentMinorVersion,
- dependencies: _dependencies);
- ApiSignature apiSignature = new ApiSignature();
- packageBundle.collectApiSignature(apiSignature);
- packageBundle.apiSignature = apiSignature.toHex();
- return packageBundle;
+ dependencies: _dependencies,
+ apiSignature: _computeApiSignature());
+ }
+
+ /**
+ * Use the dependency information in [summaryDataStore] to populate the
+ * dependencies in the package bundle being assembled.
+ */
+ void recordDependencies(SummaryDataStore summaryDataStore) {
+ _dependencies.addAll(summaryDataStore.dependencies);
}
/**
@@ -233,12 +234,28 @@ class PackageBundleAssembler {
_linkedLibraries.add(libraryResult.linked);
_unlinkedUnitUris.addAll(libraryResult.unitUris);
_unlinkedUnits.addAll(libraryResult.unlinkedUnits);
+ for (int i = 0; i < libraryResult.unitUris.length; i++) {
+ _unlinkedUnitMap[libraryResult.unitUris[i]] =
+ libraryResult.unlinkedUnits[i];
+ }
for (Source source in libraryResult.unitSources) {
_unlinkedUnitHashes?.add(_hash(source.contents.data));
}
}
/**
+ * Compute the API signature for this package bundle.
+ */
+ String _computeApiSignature() {
+ ApiSignature apiSignature = new ApiSignature();
+ for (String unitUri in _unlinkedUnitUris.toList()..sort()) {
scheglov 2016/08/09 17:12:36 It's probably equivalent, but if we ask values fro
Paul Berry 2016/08/09 17:18:02 Done.
+ apiSignature.addString(unitUri);
+ _unlinkedUnitMap[unitUri].collectApiSignature(apiSignature);
+ }
+ return apiSignature.toHex();
+ }
+
+ /**
* Compute a hash of the given file contents.
*/
String _hash(String contents) {
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698