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

Unified Diff: pkg/analyzer_cli/lib/src/driver.dart

Issue 2956093002: Issue 29960. Both CommandLineOptions and AnalysisOptions must be equal to reuse the context. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f80784331a4f443453fa3241dda7f57b9544a2ae..0654a4372d5cda82098f5cdf25c93e1793c66580 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -313,11 +313,14 @@ 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) {
+ bool _canContextBeReused(
+ CommandLineOptions options, AnalysisOptionsImpl other) {
// TODO(paulberry): add a command-line option that disables context re-use.
if (_context == null) {
return false;
}
+
+ // Check command line options.
if (options.packageRootPath != _previousOptions.packageRootPath) {
return false;
}
@@ -368,6 +371,25 @@ class Driver implements CommandLineStarter {
if (options.disableCacheFlushing != _previousOptions.disableCacheFlushing) {
return false;
}
+
+ // Check analysis options.
+ var c = _context.analysisOptions;
+ if (!(other.enableAssertInitializer == c.enableAssertInitializer &&
+ other.enableStrictCallChecks == c.enableStrictCallChecks &&
+ other.enableLazyAssignmentOperators ==
+ c.enableLazyAssignmentOperators &&
+ other.enableSuperMixins == c.enableSuperMixins &&
+ other.enableTiming == c.enableTiming &&
+ other.generateImplicitErrors == c.generateImplicitErrors &&
+ other.generateSdkErrors == c.generateSdkErrors &&
+ other.hint == c.hint &&
+ other.lint == c.lint &&
+ AnalysisOptionsImpl.compareLints(other.lintRules, c.lintRules) &&
+ other.preserveComments == c.preserveComments &&
+ other.strongMode == c.strongMode)) {
+ return false;
+ }
+
return true;
}
@@ -545,9 +567,15 @@ 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)) {
+ AnalysisOptionsImpl analysisOptions =
+ createAnalysisOptionsForCommandLineOptions(resourceProvider, options);
+ analysisOptions.analyzeFunctionBodiesPredicate =
+ _chooseDietParsingPolicy(options);
+
+ if (_canContextBeReused(options, analysisOptions)) {
return;
}
+
_previousOptions = options;
// Save stats from previous context before clobbering it.
@@ -577,11 +605,6 @@ class Driver implements CommandLineStarter {
SummaryDataStore summaryDataStore = new SummaryDataStore(
useSummaries ? options.buildSummaryInputs : <String>[]);
- AnalysisOptionsImpl analysisOptions =
- createAnalysisOptionsForCommandLineOptions(resourceProvider, options);
- analysisOptions.analyzeFunctionBodiesPredicate =
- _chooseDietParsingPolicy(options);
-
// Once options and embedders are processed, setup the SDK.
_setupSdk(options, useSummaries, analysisOptions);
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698