| OLD | NEW |
| 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.driver; | 5 library analyzer_cli.src.driver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 import 'package:analyzer/src/generated/interner.dart'; | 25 import 'package:analyzer/src/generated/interner.dart'; |
| 26 import 'package:analyzer/src/generated/java_engine.dart'; | 26 import 'package:analyzer/src/generated/java_engine.dart'; |
| 27 import 'package:analyzer/src/generated/sdk.dart'; | 27 import 'package:analyzer/src/generated/sdk.dart'; |
| 28 import 'package:analyzer/src/generated/source.dart'; | 28 import 'package:analyzer/src/generated/source.dart'; |
| 29 import 'package:analyzer/src/generated/source_io.dart'; | 29 import 'package:analyzer/src/generated/source_io.dart'; |
| 30 import 'package:analyzer/src/generated/utilities_general.dart' | 30 import 'package:analyzer/src/generated/utilities_general.dart' |
| 31 show PerformanceTag; | 31 show PerformanceTag; |
| 32 import 'package:analyzer/src/lint/registry.dart'; | 32 import 'package:analyzer/src/lint/registry.dart'; |
| 33 import 'package:analyzer/src/services/lint.dart'; | 33 import 'package:analyzer/src/services/lint.dart'; |
| 34 import 'package:analyzer/src/source/source_resource.dart'; | 34 import 'package:analyzer/src/source/source_resource.dart'; |
| 35 import 'package:analyzer/src/summary/idl.dart'; | |
| 36 import 'package:analyzer/src/summary/package_bundle_reader.dart'; | 35 import 'package:analyzer/src/summary/package_bundle_reader.dart'; |
| 37 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; | 36 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; |
| 38 import 'package:analyzer/src/task/options.dart'; | 37 import 'package:analyzer/src/task/options.dart'; |
| 39 import 'package:analyzer_cli/src/analyzer_impl.dart'; | 38 import 'package:analyzer_cli/src/analyzer_impl.dart'; |
| 40 import 'package:analyzer_cli/src/build_mode.dart'; | 39 import 'package:analyzer_cli/src/build_mode.dart'; |
| 41 import 'package:analyzer_cli/src/error_formatter.dart'; | 40 import 'package:analyzer_cli/src/error_formatter.dart'; |
| 42 import 'package:analyzer_cli/src/options.dart'; | 41 import 'package:analyzer_cli/src/options.dart'; |
| 43 import 'package:analyzer_cli/src/perf_report.dart'; | 42 import 'package:analyzer_cli/src/perf_report.dart'; |
| 44 import 'package:analyzer_cli/starter.dart'; | 43 import 'package:analyzer_cli/starter.dart'; |
| 45 import 'package:linter/src/rules.dart' as linter; | 44 import 'package:linter/src/rules.dart' as linter; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 'Summaries are not yet supported when using Flutter.'); | 509 'Summaries are not yet supported when using Flutter.'); |
| 511 } | 510 } |
| 512 | 511 |
| 513 // Read any input summaries. | 512 // Read any input summaries. |
| 514 SummaryDataStore summaryDataStore = new SummaryDataStore( | 513 SummaryDataStore summaryDataStore = new SummaryDataStore( |
| 515 useSummaries ? options.buildSummaryInputs : <String>[]); | 514 useSummaries ? options.buildSummaryInputs : <String>[]); |
| 516 | 515 |
| 517 // Once options and embedders are processed, setup the SDK. | 516 // Once options and embedders are processed, setup the SDK. |
| 518 _setupSdk(options, useSummaries); | 517 _setupSdk(options, useSummaries); |
| 519 | 518 |
| 520 PackageBundle sdkBundle = sdk.getLinkedBundle(); | |
| 521 if (sdkBundle != null) { | |
| 522 summaryDataStore.addBundle(null, sdkBundle); | |
| 523 } | |
| 524 | |
| 525 // Choose a package resolution policy and a diet parsing policy based on | 519 // Choose a package resolution policy and a diet parsing policy based on |
| 526 // the command-line options. | 520 // the command-line options. |
| 527 SourceFactory sourceFactory = _chooseUriResolutionPolicy( | 521 SourceFactory sourceFactory = _chooseUriResolutionPolicy( |
| 528 options, embedderMap, packageInfo, summaryDataStore); | 522 options, embedderMap, packageInfo, summaryDataStore); |
| 529 | 523 |
| 530 AnalyzeFunctionBodiesPredicate dietParsingPolicy = | 524 AnalyzeFunctionBodiesPredicate dietParsingPolicy = |
| 531 _chooseDietParsingPolicy(options); | 525 _chooseDietParsingPolicy(options); |
| 532 setAnalysisContextOptions( | 526 setAnalysisContextOptions( |
| 533 resourceProvider, sourceFactory, _context, options, | 527 resourceProvider, sourceFactory, _context, options, |
| 534 (AnalysisOptionsImpl contextOptions) { | 528 (AnalysisOptionsImpl contextOptions) { |
| 535 contextOptions.analyzeFunctionBodiesPredicate = dietParsingPolicy; | 529 contextOptions.analyzeFunctionBodiesPredicate = dietParsingPolicy; |
| 536 }); | 530 }); |
| 537 | 531 |
| 538 _context.sourceFactory = sourceFactory; | 532 _context.sourceFactory = sourceFactory; |
| 539 if (sdkBundle != null) { | 533 _context.resultProvider = |
| 540 _context.resultProvider = | 534 new InputPackagesResultProvider(_context, summaryDataStore); |
| 541 new InputPackagesResultProvider(_context, summaryDataStore); | |
| 542 } | |
| 543 } | 535 } |
| 544 | 536 |
| 545 /// Return discovered packagespec, or `null` if none is found. | 537 /// Return discovered packagespec, or `null` if none is found. |
| 546 Packages _discoverPackagespec(Uri root) { | 538 Packages _discoverPackagespec(Uri root) { |
| 547 try { | 539 try { |
| 548 Packages packages = pkg_discovery.findPackagesFromFile(root); | 540 Packages packages = pkg_discovery.findPackagesFromFile(root); |
| 549 if (packages != Packages.noPackages) { | 541 if (packages != Packages.noPackages) { |
| 550 return packages; | 542 return packages; |
| 551 } | 543 } |
| 552 } catch (_) { | 544 } catch (_) { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 for (var package in packages) { | 869 for (var package in packages) { |
| 878 var packageName = path.basename(package.path); | 870 var packageName = path.basename(package.path); |
| 879 var realPath = package.resolveSymbolicLinksSync(); | 871 var realPath = package.resolveSymbolicLinksSync(); |
| 880 result[packageName] = [ | 872 result[packageName] = [ |
| 881 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 873 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 882 ]; | 874 ]; |
| 883 } | 875 } |
| 884 return result; | 876 return result; |
| 885 } | 877 } |
| 886 } | 878 } |
| OLD | NEW |