Chromium Code Reviews| Index: pkg/analyzer_cli/lib/src/driver.dart |
| diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart |
| index dc40c0d6f3fe3927b1173258deaf65a83f8eccc9..c604c34702d032b1582bb68363a1b0819a8cd0ab 100644 |
| --- a/pkg/analyzer_cli/lib/src/driver.dart |
| +++ b/pkg/analyzer_cli/lib/src/driver.dart |
| @@ -79,10 +79,6 @@ class Driver implements CommandLineStarter { |
| /// `null` if [_analyzeAll] hasn't been called yet. |
| AnalysisContext _context; |
| - /// If [_context] is not `null`, the [CommandLineOptions] that guided its |
| - /// creation. |
| - CommandLineOptions _previousOptions; |
| - |
| @override |
| EmbeddedResolverProvider embeddedUriResolverProvider; |
| @@ -101,6 +97,9 @@ class Driver implements CommandLineStarter { |
| @override |
| void start(List<String> args) { |
| + if (_context != null) { |
| + throw new StateError("start() can only be called once"); |
|
Brian Wilkerson
2016/03/18 14:13:17
Start *is* only called once, and it seems unlikely
skybrian
2016/03/18 22:32:44
It's to make it easier for the next reader to tell
|
| + } |
| int startTime = new DateTime.now().millisecondsSinceEpoch; |
| StringUtilities.INTERNER = new MappedInterner(); |
| @@ -134,7 +133,8 @@ class Driver implements CommandLineStarter { |
| } |
| if (options.perfReport != null) { |
| - String json = makePerfReport(startTime, currentTimeMillis(), options); |
| + String json = |
| + makePerfReport(startTime, currentTimeMillis(), options, _context); |
| new File(options.perfReport).writeAsStringSync(json); |
| } |
| } |
| @@ -229,55 +229,6 @@ class Driver implements CommandLineStarter { |
| }); |
| } |
| - /// Determine whether the context created during a previous call to |
| - /// [_analyzeAll] can be re-used in order to analyze using [options]. |
| - bool _canContextBeReused(CommandLineOptions options) { |
| - // TODO(paulberry): add a command-line option that disables context re-use. |
| - if (_context == null) { |
| - return false; |
| - } |
| - if (options.packageRootPath != _previousOptions.packageRootPath) { |
| - return false; |
| - } |
| - if (options.packageConfigPath != _previousOptions.packageConfigPath) { |
| - return false; |
| - } |
| - if (!_equalMaps( |
| - options.definedVariables, _previousOptions.definedVariables)) { |
| - return false; |
| - } |
| - if (options.log != _previousOptions.log) { |
| - return false; |
| - } |
| - if (options.disableHints != _previousOptions.disableHints) { |
| - return false; |
| - } |
| - if (options.enableStrictCallChecks != |
| - _previousOptions.enableStrictCallChecks) { |
| - return false; |
| - } |
| - if (options.showPackageWarnings != _previousOptions.showPackageWarnings) { |
| - return false; |
| - } |
| - if (options.showSdkWarnings != _previousOptions.showSdkWarnings) { |
| - return false; |
| - } |
| - if (options.lints != _previousOptions.lints) { |
| - return false; |
| - } |
| - if (options.strongMode != _previousOptions.strongMode) { |
| - return false; |
| - } |
| - if (options.enableSuperMixins != _previousOptions.enableSuperMixins) { |
| - return false; |
| - } |
| - if (options.enableConditionalDirectives != |
| - _previousOptions.enableConditionalDirectives) { |
| - return false; |
| - } |
| - return true; |
| - } |
| - |
| /// Decide on the appropriate policy for which files need to be fully parsed |
| /// and which files need to be diet parsed, based on [options], and return an |
| /// [AnalyzeFunctionBodiesPredicate] that implements this policy. |
| @@ -292,38 +243,14 @@ class Driver implements CommandLineStarter { |
| return (Source source) => true; |
| } |
| - // Determine the set of packages requiring a full parse. Use null to |
| - // represent the case where all packages require a full parse. |
| - Set<String> packagesRequiringFullParse; |
| - if (options.showPackageWarnings) { |
| - // We are showing warnings from all packages so all packages require a |
| - // full parse. |
| - packagesRequiringFullParse = null; |
| - } else { |
| - // We aren't showing warnings for dependent packages, but we may still |
| - // need to show warnings for "self" packages, so we need to do a full |
| - // parse in any package containing files mentioned on the command line. |
| - // TODO(paulberry): implement this. As a temporary workaround, we're |
| - // fully parsing all packages. |
| - packagesRequiringFullParse = null; |
| - } |
| return (Source source) { |
| if (options.sourceFiles.contains(source.fullName)) { |
| return true; |
| } else if (source.uri.scheme == 'dart') { |
| return options.showSdkWarnings; |
| - } else if (source.uri.scheme == 'package') { |
| - if (packagesRequiringFullParse == null) { |
| - return true; |
| - } else if (source.uri.pathSegments.length == 0) { |
| - // We should never see a URI like this, but fully parse it to be |
| - // safe. |
| - return true; |
| - } else { |
| - return packagesRequiringFullParse |
| - .contains(source.uri.pathSegments[0]); |
| - } |
| } else { |
| + // TODO(paulberry): diet parse package: imports where we don't want |
| + // diagnostics. (Full parse is still needed for "self" packages.) |
| return true; |
| } |
| }; |
| @@ -472,23 +399,17 @@ class Driver implements CommandLineStarter { |
| /// Create an analysis context that is prepared to analyze sources according |
| /// to the given [options], and store it in [_context]. |
| void _createAnalysisContext(CommandLineOptions options) { |
| - if (_canContextBeReused(options)) { |
| - return; |
| - } |
| - _previousOptions = options; |
| - |
| - // Create a context. |
| - AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); |
| - _context = context; |
| + assert(_context == null); |
| + _context = AnalysisEngine.instance.createAnalysisContext(); |
| // Choose a package resolution policy and a diet parsing policy based on |
| // the command-line options. |
| SourceFactory sourceFactory = _chooseUriResolutionPolicy( |
| - options, (context as InternalAnalysisContext).embedderYamlLocator); |
| + options, (_context as InternalAnalysisContext).embedderYamlLocator); |
| AnalyzeFunctionBodiesPredicate dietParsingPolicy = |
| _chooseDietParsingPolicy(options); |
| - context.sourceFactory = sourceFactory; |
| + _context.sourceFactory = sourceFactory; |
| setAnalysisContextOptions(_context, options, |
| (AnalysisOptionsImpl contextOptions) { |
| @@ -599,19 +520,6 @@ class Driver implements CommandLineStarter { |
| _processAnalysisOptions(context, options); |
| } |
| - /// Perform a deep comparison of two string maps. |
| - static bool _equalMaps(Map<String, String> m1, Map<String, String> m2) { |
| - if (m1.length != m2.length) { |
| - return false; |
| - } |
| - for (String key in m1.keys) { |
| - if (!m2.containsKey(key) || m1[key] != m2[key]) { |
| - return false; |
| - } |
| - } |
| - return true; |
| - } |
| - |
| static fileSystem.File _getOptionsFile(CommandLineOptions options) { |
| fileSystem.File file; |
| String filePath = options.analysisOptionsFile; |