Fix couple problems with in-body incremental resolution.
1. We were performing cache walking even though we don't need.
This might take up to 50 ms for analyzer codebase.
2. STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT had null as a default
value, which is not something what incremental resolver expected.
R=brianwilkerson@google.com
BUG=
Review URL: https://codereview.chromium.org/2266403008 .
diff --git a/pkg/analyzer/lib/src/context/cache.dart b/pkg/analyzer/lib/src/context/cache.dart
index 104d89a..58dda21 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -617,6 +617,9 @@
if (delta == null) {
return false;
}
+ if (!delta.shouldGatherChanges) {
+ return true;
+ }
for (int i = 0; i < 64; i++) {
bool hasVisitChanges = false;
_visitResults(nextVisitId++, result,
@@ -1255,6 +1258,21 @@
Delta(this.source);
+ /**
+ * Return `true` if this delta needs cache walking to gather additional
+ * changes before it can be used to [validate]. In this case [gatherChanges]
+ * is invoked for every targeted result in transitive dependencies, and
+ * [gatherEnd] is invoked after cache walking is done.
+ */
+ bool get shouldGatherChanges => false;
+
+ /**
+ * This method is called during a cache walk, so that the delta can gather
+ * additional changes to which are caused by the changes it already knows
+ * about. Return `true` if a new change was added, so that one more cache
+ * walk will be performed (to include changes that depend on results which we
+ * decided to be changed later in the previous cache walk).
+ */
bool gatherChanges(InternalAnalysisContext context, AnalysisTarget target,
ResultDescriptor descriptor, Object value) {
return false;
diff --git a/pkg/analyzer/lib/src/generated/incremental_resolver.dart b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
index 9e2a1d4..c1bc461 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -77,6 +77,7 @@
bool isByTask(TaskDescriptor taskDescriptor) {
return taskDescriptor.results.contains(descriptor);
}
+
if (descriptor == CONTENT) {
return DeltaResult.KEEP_CONTINUE;
}
@@ -809,6 +810,7 @@
}
}
}
+
Element parentElement = ElementLocator.locate(newComment.parent);
if (parentElement is ElementImpl) {
setElementDocumentationComment(parentElement, parent);
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index da8fcec..04c4ec4 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -975,7 +975,7 @@
final ListResultDescriptor<AnalysisError>
STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT =
new ListResultDescriptor<AnalysisError>(
- 'STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT', null);
+ 'STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT', AnalysisError.NO_ERRORS);
/**
* The additional strong mode errors produced while verifying a
@@ -2563,6 +2563,9 @@
DartDelta(Source source) : super(source);
+ @override
+ bool get shouldGatherChanges => true;
+
/**
* Add names that are changed in the given [references].
* Return `true` if any change was added.
diff --git a/pkg/analyzer/test/src/context/cache_test.dart b/pkg/analyzer/test/src/context/cache_test.dart
index 1d4bc4f..387eae9 100644
--- a/pkg/analyzer/test/src/context/cache_test.dart
+++ b/pkg/analyzer/test/src/context/cache_test.dart
@@ -1244,6 +1244,9 @@
_KeepContinueDelta(this.source, this.keepDescriptor);
@override
+ bool get shouldGatherChanges => false;
+
+ @override
bool gatherChanges(InternalAnalysisContext context, AnalysisTarget target,
ResultDescriptor descriptor, Object value) {
return false;