| 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'; |    9 import 'dart:io'; | 
|   10  |   10  | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|   30 import 'package:analyzer/src/generated/source.dart'; |   30 import 'package:analyzer/src/generated/source.dart'; | 
|   31 import 'package:analyzer/src/generated/source_io.dart'; |   31 import 'package:analyzer/src/generated/source_io.dart'; | 
|   32 import 'package:analyzer/src/generated/utilities_general.dart' |   32 import 'package:analyzer/src/generated/utilities_general.dart' | 
|   33     show PerformanceTag; |   33     show PerformanceTag; | 
|   34 import 'package:analyzer/src/services/lint.dart'; |   34 import 'package:analyzer/src/services/lint.dart'; | 
|   35 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; |   35 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; | 
|   36 import 'package:analyzer/src/task/options.dart'; |   36 import 'package:analyzer/src/task/options.dart'; | 
|   37 import 'package:analyzer_cli/src/analyzer_impl.dart'; |   37 import 'package:analyzer_cli/src/analyzer_impl.dart'; | 
|   38 import 'package:analyzer_cli/src/build_mode.dart'; |   38 import 'package:analyzer_cli/src/build_mode.dart'; | 
|   39 import 'package:analyzer_cli/src/error_formatter.dart'; |   39 import 'package:analyzer_cli/src/error_formatter.dart'; | 
 |   40 import 'package:analyzer_cli/src/incremental_analyzer.dart'; | 
|   40 import 'package:analyzer_cli/src/options.dart'; |   41 import 'package:analyzer_cli/src/options.dart'; | 
|   41 import 'package:analyzer_cli/src/perf_report.dart'; |   42 import 'package:analyzer_cli/src/perf_report.dart'; | 
|   42 import 'package:analyzer_cli/starter.dart'; |   43 import 'package:analyzer_cli/starter.dart'; | 
|   43 import 'package:linter/src/plugin/linter_plugin.dart'; |   44 import 'package:linter/src/plugin/linter_plugin.dart'; | 
|   44 import 'package:package_config/discovery.dart' as pkg_discovery; |   45 import 'package:package_config/discovery.dart' as pkg_discovery; | 
|   45 import 'package:package_config/packages.dart' show Packages; |   46 import 'package:package_config/packages.dart' show Packages; | 
|   46 import 'package:package_config/packages_file.dart' as pkgfile show parse; |   47 import 'package:package_config/packages_file.dart' as pkgfile show parse; | 
|   47 import 'package:package_config/src/packages_impl.dart' show MapPackages; |   48 import 'package:package_config/src/packages_impl.dart' show MapPackages; | 
|   48 import 'package:path/path.dart' as path; |   49 import 'package:path/path.dart' as path; | 
|   49 import 'package:plugin/manager.dart'; |   50 import 'package:plugin/manager.dart'; | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|   79   /// `null` if [_analyzeAll] hasn't been called yet. |   80   /// `null` if [_analyzeAll] hasn't been called yet. | 
|   80   AnalysisContext _context; |   81   AnalysisContext _context; | 
|   81  |   82  | 
|   82   /// The total number of source files loaded by an AnalysisContext. |   83   /// The total number of source files loaded by an AnalysisContext. | 
|   83   int _analyzedFileCount = 0; |   84   int _analyzedFileCount = 0; | 
|   84  |   85  | 
|   85   /// If [_context] is not `null`, the [CommandLineOptions] that guided its |   86   /// If [_context] is not `null`, the [CommandLineOptions] that guided its | 
|   86   /// creation. |   87   /// creation. | 
|   87   CommandLineOptions _previousOptions; |   88   CommandLineOptions _previousOptions; | 
|   88  |   89  | 
 |   90   IncrementalAnalysisData incrementalData; | 
 |   91  | 
|   89   @override |   92   @override | 
|   90   EmbeddedResolverProvider embeddedUriResolverProvider; |   93   EmbeddedResolverProvider embeddedUriResolverProvider; | 
|   91  |   94  | 
|   92   @override |   95   @override | 
|   93   ResolverProvider packageResolverProvider; |   96   ResolverProvider packageResolverProvider; | 
|   94  |   97  | 
|   95   /// SDK instance. |   98   /// SDK instance. | 
|   96   DartSdk sdk; |   99   DartSdk sdk; | 
|   97  |  100  | 
|   98   /// Collected analysis statistics. |  101   /// Collected analysis statistics. | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  210     for (Source source in sourcesToAnalyze) { |  213     for (Source source in sourcesToAnalyze) { | 
|  211       if (context.computeKindOf(source) == SourceKind.PART) { |  214       if (context.computeKindOf(source) == SourceKind.PART) { | 
|  212         parts.add(source); |  215         parts.add(source); | 
|  213         continue; |  216         continue; | 
|  214       } |  217       } | 
|  215       ErrorSeverity status = _runAnalyzer(source, options); |  218       ErrorSeverity status = _runAnalyzer(source, options); | 
|  216       allResult = allResult.max(status); |  219       allResult = allResult.max(status); | 
|  217       libUris.add(source.uri); |  220       libUris.add(source.uri); | 
|  218     } |  221     } | 
|  219  |  222  | 
 |  223     incrementalData?.finish(); | 
 |  224  | 
|  220     // Check that each part has a corresponding source in the input list. |  225     // Check that each part has a corresponding source in the input list. | 
|  221     for (Source part in parts) { |  226     for (Source part in parts) { | 
|  222       bool found = false; |  227       bool found = false; | 
|  223       for (var lib in context.getLibrariesContaining(part)) { |  228       for (var lib in context.getLibrariesContaining(part)) { | 
|  224         if (libUris.contains(lib.uri)) { |  229         if (libUris.contains(lib.uri)) { | 
|  225           found = true; |  230           found = true; | 
|  226         } |  231         } | 
|  227       } |  232       } | 
|  228       if (!found) { |  233       if (!found) { | 
|  229         errorSink.writeln("${part.fullName} is a part and cannot be analyzed."); |  234         errorSink.writeln("${part.fullName} is a part and cannot be analyzed."); | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  290     } |  295     } | 
|  291     if (options.lints != _previousOptions.lints) { |  296     if (options.lints != _previousOptions.lints) { | 
|  292       return false; |  297       return false; | 
|  293     } |  298     } | 
|  294     if (options.strongMode != _previousOptions.strongMode) { |  299     if (options.strongMode != _previousOptions.strongMode) { | 
|  295       return false; |  300       return false; | 
|  296     } |  301     } | 
|  297     if (options.enableSuperMixins != _previousOptions.enableSuperMixins) { |  302     if (options.enableSuperMixins != _previousOptions.enableSuperMixins) { | 
|  298       return false; |  303       return false; | 
|  299     } |  304     } | 
 |  305     if (options.incrementalCachePath != _previousOptions.incrementalCachePath) { | 
 |  306       return false; | 
 |  307     } | 
|  300     return true; |  308     return true; | 
|  301   } |  309   } | 
|  302  |  310  | 
|  303   /// Decide on the appropriate policy for which files need to be fully parsed |  311   /// Decide on the appropriate policy for which files need to be fully parsed | 
|  304   /// and which files need to be diet parsed, based on [options], and return an |  312   /// and which files need to be diet parsed, based on [options], and return an | 
|  305   /// [AnalyzeFunctionBodiesPredicate] that implements this policy. |  313   /// [AnalyzeFunctionBodiesPredicate] that implements this policy. | 
|  306   AnalyzeFunctionBodiesPredicate _chooseDietParsingPolicy( |  314   AnalyzeFunctionBodiesPredicate _chooseDietParsingPolicy( | 
|  307       CommandLineOptions options) { |  315       CommandLineOptions options) { | 
|  308     if (options.shouldBatch) { |  316     if (options.shouldBatch) { | 
|  309       // As analyzer is currently implemented, once a file has been diet |  317       // As analyzer is currently implemented, once a file has been diet | 
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  503  |  511  | 
|  504     // Once options and embedders are processed, setup the SDK. |  512     // Once options and embedders are processed, setup the SDK. | 
|  505     _setupSdk(options, useSummaries); |  513     _setupSdk(options, useSummaries); | 
|  506  |  514  | 
|  507     // Choose a package resolution policy and a diet parsing policy based on |  515     // Choose a package resolution policy and a diet parsing policy based on | 
|  508     // the command-line options. |  516     // the command-line options. | 
|  509     SourceFactory sourceFactory = |  517     SourceFactory sourceFactory = | 
|  510         _chooseUriResolutionPolicy(options, embedderMap, packageInfo); |  518         _chooseUriResolutionPolicy(options, embedderMap, packageInfo); | 
|  511  |  519  | 
|  512     _context.sourceFactory = sourceFactory; |  520     _context.sourceFactory = sourceFactory; | 
 |  521  | 
 |  522     incrementalData = configureIncrementalAnalysis(options, context); | 
|  513   } |  523   } | 
|  514  |  524  | 
|  515   /// Return discovered packagespec, or `null` if none is found. |  525   /// Return discovered packagespec, or `null` if none is found. | 
|  516   Packages _discoverPackagespec(Uri root) { |  526   Packages _discoverPackagespec(Uri root) { | 
|  517     try { |  527     try { | 
|  518       Packages packages = pkg_discovery.findPackagesFromFile(root); |  528       Packages packages = pkg_discovery.findPackagesFromFile(root); | 
|  519       if (packages != Packages.noPackages) { |  529       if (packages != Packages.noPackages) { | 
|  520         return packages; |  530         return packages; | 
|  521       } |  531       } | 
|  522     } catch (_) { |  532     } catch (_) { | 
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  845     for (var package in packages) { |  855     for (var package in packages) { | 
|  846       var packageName = path.basename(package.path); |  856       var packageName = path.basename(package.path); | 
|  847       var realPath = package.resolveSymbolicLinksSync(); |  857       var realPath = package.resolveSymbolicLinksSync(); | 
|  848       result[packageName] = [ |  858       result[packageName] = [ | 
|  849         PhysicalResourceProvider.INSTANCE.getFolder(realPath) |  859         PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 
|  850       ]; |  860       ]; | 
|  851     } |  861     } | 
|  852     return result; |  862     return result; | 
|  853   } |  863   } | 
|  854 } |  864 } | 
| OLD | NEW |