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

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

Issue 1838883002: Add the '--build-summary-only-ast' flag for generating summaries using only ASTs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer_cli/lib/src/build_mode.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import 'dart:io' as io; 1 import 'dart:io' as io;
2 2
3 import 'package:analyzer/dart/element/element.dart'; 3 import 'package:analyzer/dart/element/element.dart';
4 import 'package:analyzer/src/context/cache.dart'; 4 import 'package:analyzer/src/context/cache.dart';
5 import 'package:analyzer/src/context/context.dart'; 5 import 'package:analyzer/src/context/context.dart';
6 import 'package:analyzer/src/generated/engine.dart'; 6 import 'package:analyzer/src/generated/engine.dart';
7 import 'package:analyzer/src/generated/java_io.dart'; 7 import 'package:analyzer/src/generated/java_io.dart';
8 import 'package:analyzer/src/generated/resolver.dart'; 8 import 'package:analyzer/src/generated/resolver.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 /** 186 /**
187 * Map from the URI of a library to the summary path that contained it. 187 * Map from the URI of a library to the summary path that contained it.
188 */ 188 */
189 final Map<String, String> uriToSummaryPath = <String, String>{}; 189 final Map<String, String> uriToSummaryPath = <String, String>{};
190 190
191 SummaryDataStore(Iterable<String> summaryPaths) { 191 SummaryDataStore(Iterable<String> summaryPaths) {
192 summaryPaths.forEach(_fillMaps); 192 summaryPaths.forEach(_fillMaps);
193 } 193 }
194 194
195 void _fillMaps(String path) { 195 /**
196 io.File file = new io.File(path); 196 * Add the given [bundle] loaded from the file with the given [path].
197 List<int> buffer = file.readAsBytesSync(); 197 */
198 PackageBundle bundle = new PackageBundle.fromBuffer(buffer); 198 void addBundle(String path, PackageBundle bundle) {
199 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { 199 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
200 String uri = bundle.unlinkedUnitUris[i]; 200 String uri = bundle.unlinkedUnitUris[i];
201 uriToSummaryPath[uri] = path; 201 uriToSummaryPath[uri] = path;
202 unlinkedMap[uri] = bundle.unlinkedUnits[i]; 202 unlinkedMap[uri] = bundle.unlinkedUnits[i];
203 } 203 }
204 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { 204 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
205 String uri = bundle.linkedLibraryUris[i]; 205 String uri = bundle.linkedLibraryUris[i];
206 linkedMap[uri] = bundle.linkedLibraries[i]; 206 linkedMap[uri] = bundle.linkedLibraries[i];
207 } 207 }
208 } 208 }
209
210 void _fillMaps(String path) {
211 io.File file = new io.File(path);
212 List<int> buffer = file.readAsBytesSync();
213 PackageBundle bundle = new PackageBundle.fromBuffer(buffer);
214 addBundle(path, bundle);
215 }
209 } 216 }
210 217
211 /** 218 /**
212 * A concrete resynthesizer that serves summaries from given file paths. 219 * A concrete resynthesizer that serves summaries from given file paths.
213 */ 220 */
214 class _FileBasedSummaryResynthesizer extends SummaryResynthesizer { 221 class _FileBasedSummaryResynthesizer extends SummaryResynthesizer {
215 final SummaryDataStore _dataStore; 222 final SummaryDataStore _dataStore;
216 223
217 _FileBasedSummaryResynthesizer( 224 _FileBasedSummaryResynthesizer(
218 SummaryResynthesizer parent, 225 SummaryResynthesizer parent,
(...skipping 27 matching lines...) Expand all
246 * also provides [summaryPath]. 253 * also provides [summaryPath].
247 */ 254 */
248 class _InSummaryFallbackSource extends FileBasedSource 255 class _InSummaryFallbackSource extends FileBasedSource
249 implements InSummarySource { 256 implements InSummarySource {
250 @override 257 @override
251 final String summaryPath; 258 final String summaryPath;
252 259
253 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) 260 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath)
254 : super(file, uri); 261 : super(file, uri);
255 } 262 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer_cli/lib/src/build_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698