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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 2226093002: Record information about a summary's dependencies in the summary itself. (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library serialization.elements; 5 library serialization.elements;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
11 import 'package:analyzer/dart/element/type.dart'; 11 import 'package:analyzer/dart/element/type.dart';
12 import 'package:analyzer/src/dart/element/element.dart'; 12 import 'package:analyzer/src/dart/element/element.dart';
13 import 'package:analyzer/src/dart/element/member.dart'; 13 import 'package:analyzer/src/dart/element/member.dart';
14 import 'package:analyzer/src/dart/element/type.dart'; 14 import 'package:analyzer/src/dart/element/type.dart';
15 import 'package:analyzer/src/generated/java_engine.dart'; 15 import 'package:analyzer/src/generated/java_engine.dart';
16 import 'package:analyzer/src/generated/resolver.dart'; 16 import 'package:analyzer/src/generated/resolver.dart';
17 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
18 import 'package:analyzer/src/generated/utilities_dart.dart'; 18 import 'package:analyzer/src/generated/utilities_dart.dart';
19 import 'package:analyzer/src/summary/api_signature.dart'; 19 import 'package:analyzer/src/summary/api_signature.dart';
20 import 'package:analyzer/src/summary/format.dart'; 20 import 'package:analyzer/src/summary/format.dart';
21 import 'package:analyzer/src/summary/idl.dart'; 21 import 'package:analyzer/src/summary/idl.dart';
22 import 'package:analyzer/src/summary/name_filter.dart'; 22 import 'package:analyzer/src/summary/name_filter.dart';
23 import 'package:analyzer/src/summary/summarize_const_expr.dart'; 23 import 'package:analyzer/src/summary/summarize_const_expr.dart';
24 import 'package:convert/convert.dart'; 24 import 'package:convert/convert.dart';
25 import 'package:crypto/crypto.dart'; 25 import 'package:crypto/crypto.dart';
26 import 'package:path/path.dart' as path; 26 import 'package:path/path.dart' as path;
27 import 'package:analyzer/src/summary/package_bundle_reader.dart';
27 28
28 /** 29 /**
29 * Serialize all the elements in [lib] to a summary using [ctx] as the context 30 * Serialize all the elements in [lib] to a summary using [ctx] as the context
30 * for building the summary, and using [typeProvider] to find built-in types. 31 * for building the summary, and using [typeProvider] to find built-in types.
31 */ 32 */
32 LibrarySerializationResult serializeLibrary( 33 LibrarySerializationResult serializeLibrary(
33 LibraryElement lib, TypeProvider typeProvider, bool strongMode) { 34 LibraryElement lib, TypeProvider typeProvider, bool strongMode) {
34 _LibrarySerializer serializer = 35 _LibrarySerializer serializer =
35 new _LibrarySerializer(lib, typeProvider, strongMode); 36 new _LibrarySerializer(lib, typeProvider, strongMode);
36 LinkedLibraryBuilder linked = serializer.serializeLibrary(); 37 LinkedLibraryBuilder linked = serializer.serializeLibrary();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 * data that was previously not summarized), this value should be incremented 134 * data that was previously not summarized), this value should be incremented
134 * by 1. 135 * by 1.
135 */ 136 */
136 static const int currentMinorVersion = 0; 137 static const int currentMinorVersion = 0;
137 138
138 final List<String> _linkedLibraryUris = <String>[]; 139 final List<String> _linkedLibraryUris = <String>[];
139 final List<LinkedLibraryBuilder> _linkedLibraries = <LinkedLibraryBuilder>[]; 140 final List<LinkedLibraryBuilder> _linkedLibraries = <LinkedLibraryBuilder>[];
140 final List<String> _unlinkedUnitUris = <String>[]; 141 final List<String> _unlinkedUnitUris = <String>[];
141 final List<UnlinkedUnitBuilder> _unlinkedUnits = <UnlinkedUnitBuilder>[]; 142 final List<UnlinkedUnitBuilder> _unlinkedUnits = <UnlinkedUnitBuilder>[];
142 final List<String> _unlinkedUnitHashes; 143 final List<String> _unlinkedUnitHashes;
144 final List<PackageDependencyInfoBuilder> _dependencies =
145 <PackageDependencyInfoBuilder>[];
143 final bool _excludeHashes; 146 final bool _excludeHashes;
144 147
145 /** 148 /**
146 * Create a [PackageBundleAssembler]. If [excludeHashes] is `true`, hash 149 * Create a [PackageBundleAssembler]. If [excludeHashes] is `true`, hash
147 * computation will be skipped. 150 * computation will be skipped.
148 */ 151 */
149 PackageBundleAssembler({bool excludeHashes: false}) 152 PackageBundleAssembler({bool excludeHashes: false})
150 : _excludeHashes = excludeHashes, 153 : _excludeHashes = excludeHashes,
151 _unlinkedUnitHashes = excludeHashes ? null : <String>[]; 154 _unlinkedUnitHashes = excludeHashes ? null : <String>[];
152 155
153 /** 156 /**
154 * Add a fallback library to the package bundle, corresponding to the library 157 * Add a fallback library to the package bundle, corresponding to the library
155 * whose defining compilation unit is located at [source]. Caller must also 158 * whose defining compilation unit is located at [source]. Caller must also
156 * call [addFallbackUnit] for all compilation units contained in the library 159 * call [addFallbackUnit] for all compilation units contained in the library
157 * (including the defining compilation unit). 160 * (including the defining compilation unit).
158 */ 161 */
159 void addFallbackLibrary(Source source) { 162 void addFallbackLibrary(Source source) {
160 String uri = source.uri.toString(); 163 String uri = source.uri.toString();
161 _linkedLibraryUris.add(uri); 164 _linkedLibraryUris.add(uri);
162 _linkedLibraries.add(new LinkedLibraryBuilder(fallbackMode: true)); 165 _linkedLibraries.add(new LinkedLibraryBuilder(fallbackMode: true));
163 } 166 }
164 167
165 /** 168 /**
169 * Use the dependency information in [summaryDataStore] to populate the
170 * dependencies in the package bundle being assembled.
171 */
172 void recordDependencies(SummaryDataStore summaryDataStore) {
173 _dependencies.addAll(summaryDataStore.dependencies);
174 }
175
176 /**
166 * Add a fallback compilation unit to the package bundle, corresponding to 177 * Add a fallback compilation unit to the package bundle, corresponding to
167 * the compilation unit located at [source]. 178 * the compilation unit located at [source].
168 */ 179 */
169 void addFallbackUnit(Source source) { 180 void addFallbackUnit(Source source) {
170 String uri = source.uri.toString(); 181 String uri = source.uri.toString();
171 _unlinkedUnitUris.add(uri); 182 _unlinkedUnitUris.add(uri);
172 _unlinkedUnits.add(new UnlinkedUnitBuilder( 183 _unlinkedUnits.add(new UnlinkedUnitBuilder(
173 fallbackModePath: path.relative(source.fullName))); 184 fallbackModePath: path.relative(source.fullName)));
174 } 185 }
175 186
(...skipping 18 matching lines...) Expand all
194 * Assemble a new [PackageBundleBuilder] using the gathered information. 205 * Assemble a new [PackageBundleBuilder] using the gathered information.
195 */ 206 */
196 PackageBundleBuilder assemble() { 207 PackageBundleBuilder assemble() {
197 PackageBundleBuilder packageBundle = new PackageBundleBuilder( 208 PackageBundleBuilder packageBundle = new PackageBundleBuilder(
198 linkedLibraryUris: _linkedLibraryUris, 209 linkedLibraryUris: _linkedLibraryUris,
199 linkedLibraries: _linkedLibraries, 210 linkedLibraries: _linkedLibraries,
200 unlinkedUnitUris: _unlinkedUnitUris, 211 unlinkedUnitUris: _unlinkedUnitUris,
201 unlinkedUnits: _unlinkedUnits, 212 unlinkedUnits: _unlinkedUnits,
202 unlinkedUnitHashes: _unlinkedUnitHashes, 213 unlinkedUnitHashes: _unlinkedUnitHashes,
203 majorVersion: currentMajorVersion, 214 majorVersion: currentMajorVersion,
204 minorVersion: currentMinorVersion); 215 minorVersion: currentMinorVersion,
216 dependencies: _dependencies);
205 ApiSignature apiSignature = new ApiSignature(); 217 ApiSignature apiSignature = new ApiSignature();
206 packageBundle.collectApiSignature(apiSignature); 218 packageBundle.collectApiSignature(apiSignature);
207 packageBundle.apiSignature = apiSignature.toHex(); 219 packageBundle.apiSignature = apiSignature.toHex();
208 return packageBundle; 220 return packageBundle;
209 } 221 }
210 222
211 /** 223 /**
212 * Serialize the library with the given [element]. 224 * Serialize the library with the given [element].
213 */ 225 */
214 void serializeLibraryElement(LibraryElement element) { 226 void serializeLibraryElement(LibraryElement element) {
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 exportNames.add(new LinkedExportNameBuilder( 1695 exportNames.add(new LinkedExportNameBuilder(
1684 name: name, 1696 name: name,
1685 dependency: serializeDependency(dependentLibrary), 1697 dependency: serializeDependency(dependentLibrary),
1686 unit: unit, 1698 unit: unit,
1687 kind: kind)); 1699 kind: kind));
1688 } 1700 }
1689 pb.exportNames = exportNames; 1701 pb.exportNames = exportNames;
1690 return pb; 1702 return pb;
1691 } 1703 }
1692 } 1704 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698