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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 2138603002: Keep resolution results in more cases. Invalidate only errors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index 8df541e8d9ce823bf6ec877519945e845adf0415..4dde93d09a6e0d4e3cd3ad6d340bf7f17321b50b 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -327,6 +327,33 @@ final ResultDescriptor<bool> CREATED_RESOLVED_UNIT9 =
new ResultDescriptor<bool>('CREATED_RESOLVED_UNIT9', false);
/**
+ * All [AnalysisError]s results for [Source]s.
+ */
+final List<ListResultDescriptor<AnalysisError>> ERROR_SOURCE_RESULTS =
+ <ListResultDescriptor<AnalysisError>>[
+ BUILD_DIRECTIVES_ERRORS,
+ BUILD_LIBRARY_ERRORS,
+ PARSE_ERRORS,
+ SCAN_ERRORS,
+];
+
+/**
+ * All [AnalysisError]s results in for [LibrarySpecificUnit]s.
+ */
+final List<ListResultDescriptor<AnalysisError>> ERROR_UNIT_RESULTS =
+ <ListResultDescriptor<AnalysisError>>[
+ HINTS,
+ LIBRARY_UNIT_ERRORS,
+ LINTS,
+ RESOLVE_TYPE_BOUNDS_ERRORS,
+ RESOLVE_TYPE_NAMES_ERRORS,
+ RESOLVE_UNIT_ERRORS,
+ STRONG_MODE_ERRORS,
+ VARIABLE_REFERENCE_ERRORS,
+ VERIFY_ERRORS
+];
+
+/**
* The sources representing the export closure of a library.
* The [Source]s include only library sources, not their units.
*
@@ -2487,12 +2514,18 @@ class DartDelta extends Delta {
/**
* The cache of libraries in which all results are invalid.
*/
- final Set<Source> librariesWithInvalidResults = new Set<Source>();
+ final Set<Source> librariesWithAllInvalidResults = new Set<Source>();
/**
* The cache of libraries in which all results are valid.
*/
- final Set<Source> librariesWithValidResults = new Set<Source>();
+ final Set<Source> librariesWithAllValidResults = new Set<Source>();
+
+ /**
+ * The cache of libraries with all, but [HINTS] and [VERIFY_ERRORS] results
+ * are valid.
+ */
+ final Set<Source> libraryWithInvalidErrors = new Set<Source>();
DartDelta(Source source) : super(source);
@@ -2553,22 +2586,19 @@ class DartDelta extends Delta {
nameChanged(librarySource, element.name);
}
- bool hasAffectedReferences(ReferencedNames references, Source refLibrary) {
- // Verify errors must be recomputed when a superclass changes.
+ bool hasAffectedHintsVerifyErrors(
+ ReferencedNames references, Source refLibrary) {
for (String superName in references.superToSubs.keys) {
if (isChangedOrClass(refLibrary, superName)) {
- _log(() => '$refLibrary is affected because '
+ _log(() => '$refLibrary hints/verify errors are affected because '
'${references.superToSubs[superName]} subclasses $superName');
return true;
}
}
- // Verify errors must be recomputed when an instantiated class changes.
- for (String name in references.instantiatedNames) {
- if (isChangedOrClass(refLibrary, name)) {
- _log(() => '$refLibrary is affected because $name is instantiated');
- return true;
- }
- }
+ return false;
+ }
+
+ bool hasAffectedReferences(ReferencedNames references, Source refLibrary) {
// Resolution must be performed when a referenced element changes.
for (String name in references.names) {
if (isChangedOrClassMember(refLibrary, name)) {
@@ -2678,12 +2708,20 @@ class DartDelta extends Delta {
// Handle in-library results only for now.
if (targetLibrary != null) {
// Use cached library results.
- if (librariesWithInvalidResults.contains(targetLibrary)) {
+ if (librariesWithAllInvalidResults.contains(targetLibrary)) {
return DeltaResult.INVALIDATE;
}
- if (librariesWithValidResults.contains(targetLibrary)) {
+ if (librariesWithAllValidResults.contains(targetLibrary)) {
return DeltaResult.STOP;
}
+ // The library is almost, but not completely valid.
+ // Some error results are invalid.
+ if (libraryWithInvalidErrors.contains(targetLibrary)) {
+ if (descriptor == HINTS || descriptor == VERIFY_ERRORS) {
+ return DeltaResult.INVALIDATE_NO_DELTA;
+ }
+ return DeltaResult.KEEP_CONTINUE;
+ }
// Compute the library result.
ReferencedNames referencedNames =
context.getResult(targetUnit, REFERENCED_NAMES);
@@ -2692,10 +2730,14 @@ class DartDelta extends Delta {
}
addChangedElements(referencedNames, targetLibrary);
if (hasAffectedReferences(referencedNames, targetLibrary)) {
- librariesWithInvalidResults.add(targetLibrary);
+ librariesWithAllInvalidResults.add(targetLibrary);
return DeltaResult.INVALIDATE;
}
- librariesWithValidResults.add(targetLibrary);
+ if (hasAffectedHintsVerifyErrors(referencedNames, targetLibrary)) {
+ libraryWithInvalidErrors.add(targetLibrary);
+ return DeltaResult.KEEP_CONTINUE;
+ }
+ librariesWithAllValidResults.add(targetLibrary);
return DeltaResult.STOP;
}
// We don't know what to do with the given target, invalidate it.
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698