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

Side by Side Diff: pkg/analyzer_cli/lib/src/build_mode.dart

Issue 1974323003: Add '--dart-sdk-summary' option to analyzer-cli and use SummaryBasedDartSdk. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 analyzer_cli.src.build_mode; 5 library analyzer_cli.src.build_mode;
6 6
7 import 'dart:core' hide Resource; 7 import 'dart:core' hide Resource;
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 9
10 import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit; 10 import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit;
11 import 'package:analyzer/dart/element/element.dart'; 11 import 'package:analyzer/dart/element/element.dart';
12 import 'package:analyzer/file_system/file_system.dart'; 12 import 'package:analyzer/file_system/file_system.dart';
13 import 'package:analyzer/file_system/physical_file_system.dart'; 13 import 'package:analyzer/file_system/physical_file_system.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 14 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/error.dart'; 15 import 'package:analyzer/src/generated/error.dart';
16 import 'package:analyzer/src/generated/java_io.dart'; 16 import 'package:analyzer/src/generated/java_io.dart';
17 import 'package:analyzer/src/generated/sdk.dart';
17 import 'package:analyzer/src/generated/sdk_io.dart'; 18 import 'package:analyzer/src/generated/sdk_io.dart';
18 import 'package:analyzer/src/generated/source.dart'; 19 import 'package:analyzer/src/generated/source.dart';
19 import 'package:analyzer/src/generated/source_io.dart'; 20 import 'package:analyzer/src/generated/source_io.dart';
20 import 'package:analyzer/src/summary/format.dart'; 21 import 'package:analyzer/src/summary/format.dart';
21 import 'package:analyzer/src/summary/idl.dart'; 22 import 'package:analyzer/src/summary/idl.dart';
22 import 'package:analyzer/src/summary/link.dart'; 23 import 'package:analyzer/src/summary/link.dart';
23 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 24 import 'package:analyzer/src/summary/package_bundle_reader.dart';
24 import 'package:analyzer/src/summary/summarize_ast.dart'; 25 import 'package:analyzer/src/summary/summarize_ast.dart';
25 import 'package:analyzer/src/summary/summarize_elements.dart'; 26 import 'package:analyzer/src/summary/summarize_elements.dart';
27 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
26 import 'package:analyzer/task/dart.dart'; 28 import 'package:analyzer/task/dart.dart';
27 import 'package:analyzer_cli/src/analyzer_impl.dart'; 29 import 'package:analyzer_cli/src/analyzer_impl.dart';
28 import 'package:analyzer_cli/src/driver.dart'; 30 import 'package:analyzer_cli/src/driver.dart';
29 import 'package:analyzer_cli/src/error_formatter.dart'; 31 import 'package:analyzer_cli/src/error_formatter.dart';
30 import 'package:analyzer_cli/src/options.dart'; 32 import 'package:analyzer_cli/src/options.dart';
31 import 'package:bazel_worker/bazel_worker.dart'; 33 import 'package:bazel_worker/bazel_worker.dart';
32 34
33 /** 35 /**
34 * Persistent Bazel worker. 36 * Persistent Bazel worker.
35 */ 37 */
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (processedSeverity != null) { 232 if (processedSeverity != null) {
231 maxSeverity = maxSeverity.max(processedSeverity.severity); 233 maxSeverity = maxSeverity.max(processedSeverity.severity);
232 } 234 }
233 } 235 }
234 } 236 }
235 } 237 }
236 return maxSeverity; 238 return maxSeverity;
237 } 239 }
238 240
239 void _createContext() { 241 void _createContext() {
240 DirectoryBasedDartSdk sdk =
241 new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath));
242 sdk.analysisOptions =
243 Driver.createAnalysisOptionsForCommandLineOptions(options);
244 sdk.useSummary = !options.buildSummaryOnlyAst;
245
246 // Read the summaries. 242 // Read the summaries.
247 summaryDataStore = new SummaryDataStore(options.buildSummaryInputs); 243 summaryDataStore = new SummaryDataStore(options.buildSummaryInputs);
248 244
245 DartSdk sdk;
246 PackageBundle sdkBundle;
247 if (options.dartSdkSummaryPath != null) {
248 SummaryBasedDartSdk summarySdk =
249 new SummaryBasedDartSdk(options.dartSdkSummaryPath);
250 sdk = summarySdk;
251 sdkBundle = summarySdk.bundle;
252 } else {
253 DirectoryBasedDartSdk directorySdk =
254 new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath));
255 directorySdk.analysisOptions =
256 Driver.createAnalysisOptionsForCommandLineOptions(options);
257 directorySdk.useSummary = !options.buildSummaryOnlyAst;
258 sdk = directorySdk;
259 sdkBundle = directorySdk.getSummarySdkBundle();
260 }
261
249 // In AST mode include SDK bundle to avoid parsing SDK sources. 262 // In AST mode include SDK bundle to avoid parsing SDK sources.
250 if (options.buildSummaryOnlyAst) { 263 if (options.buildSummaryOnlyAst) {
251 summaryDataStore.addBundle(null, sdk.getSummarySdkBundle()); 264 summaryDataStore.addBundle(null, sdkBundle);
252 } 265 }
253 266
254 // Create the context. 267 // Create the context.
255 context = AnalysisEngine.instance.createAnalysisContext(); 268 context = AnalysisEngine.instance.createAnalysisContext();
256 context.sourceFactory = new SourceFactory(<UriResolver>[ 269 context.sourceFactory = new SourceFactory(<UriResolver>[
257 new DartUriResolver(sdk), 270 new DartUriResolver(sdk),
258 new InSummaryPackageUriResolver(summaryDataStore), 271 new InSummaryPackageUriResolver(summaryDataStore),
259 new ExplicitSourceResolver(uriToFileMap) 272 new ExplicitSourceResolver(uriToFileMap)
260 ]); 273 ]);
261 274
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 'Illegal input file (must be "\$uri|\$path"): $sourceFile'); 370 'Illegal input file (must be "\$uri|\$path"): $sourceFile');
358 return null; 371 return null;
359 } 372 }
360 Uri uri = Uri.parse(sourceFile.substring(0, pipeIndex)); 373 Uri uri = Uri.parse(sourceFile.substring(0, pipeIndex));
361 String path = sourceFile.substring(pipeIndex + 1); 374 String path = sourceFile.substring(pipeIndex + 1);
362 uriToFileMap[uri] = new JavaFile(path); 375 uriToFileMap[uri] = new JavaFile(path);
363 } 376 }
364 return uriToFileMap; 377 return uriToFileMap;
365 } 378 }
366 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698