| 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 62fed3be1866d76cfc386fb077736ee9e2474424..04baefa1a3c857ec68765cb33837a7fc6fd5cd0e 100644
|
| --- a/pkg/analyzer/lib/src/task/dart.dart
|
| +++ b/pkg/analyzer/lib/src/task/dart.dart
|
| @@ -1923,12 +1923,35 @@ class DartDelta extends Delta {
|
| invalidatedSources.add(source);
|
| }
|
|
|
| + void elementAdded(Element element) {
|
| + addedNames.add(element.name);
|
| + }
|
| +
|
| + void elementChanged(Element element) {
|
| + changedNames.add(element.name);
|
| + }
|
| +
|
| + void elementRemoved(Element element) {
|
| + removedNames.add(element.name);
|
| + }
|
| +
|
| + bool isNameAffected(String name) {
|
| + return addedNames.contains(name) ||
|
| + changedNames.contains(name) ||
|
| + removedNames.contains(name);
|
| + }
|
| +
|
| + bool nameChanged(String name) {
|
| + return changedNames.add(name);
|
| + }
|
| +
|
| @override
|
| - bool affects(InternalAnalysisContext context, AnalysisTarget target,
|
| + DeltaResult validate(InternalAnalysisContext context, AnalysisTarget target,
|
| ResultDescriptor descriptor) {
|
| if (hasDirectiveChange) {
|
| - return true;
|
| + return DeltaResult.INVALIDATE;
|
| }
|
| + // Prepare target source.
|
| Source targetSource = null;
|
| if (target is Source) {
|
| targetSource = target;
|
| @@ -1939,9 +1962,25 @@ class DartDelta extends Delta {
|
| if (target is Element) {
|
| targetSource = target.source;
|
| }
|
| + // Keep results that are updated incrementally.
|
| + // If we want to analyze only some references to the source being changed,
|
| + // we need to keep the same instances of CompilationUnitElement and
|
| + // LibraryElement.
|
| if (targetSource == source) {
|
| - return true;
|
| + if (ParseDartTask.DESCRIPTOR.results.contains(descriptor)) {
|
| + return DeltaResult.KEEP_CONTINUE;
|
| + }
|
| + if (BuildCompilationUnitElementTask.DESCRIPTOR.results
|
| + .contains(descriptor)) {
|
| + return DeltaResult.KEEP_CONTINUE;
|
| + }
|
| + if (BuildLibraryElementTask.DESCRIPTOR.results.contains(descriptor)) {
|
| + return DeltaResult.KEEP_CONTINUE;
|
| + }
|
| + return DeltaResult.INVALIDATE;
|
| }
|
| + // Use the target library dependency information to decide whether
|
| + // the delta affects the library.
|
| if (targetSource != null) {
|
| List<Source> librarySources =
|
| context.getLibrariesContaining(targetSource);
|
| @@ -1950,38 +1989,17 @@ class DartDelta extends Delta {
|
| ReferencedNames referencedNames =
|
| cache.getValue(librarySource, REFERENCED_NAMES);
|
| if (referencedNames == null) {
|
| - return true;
|
| + return DeltaResult.INVALIDATE;
|
| }
|
| referencedNames.addChangedElements(this);
|
| if (referencedNames.isAffectedBy(this)) {
|
| - return true;
|
| + return DeltaResult.INVALIDATE;
|
| }
|
| }
|
| - return false;
|
| + return DeltaResult.STOP;
|
| }
|
| - return true;
|
| - }
|
| -
|
| - void elementAdded(Element element) {
|
| - addedNames.add(element.name);
|
| - }
|
| -
|
| - void elementChanged(Element element) {
|
| - changedNames.add(element.name);
|
| - }
|
| -
|
| - void elementRemoved(Element element) {
|
| - removedNames.add(element.name);
|
| - }
|
| -
|
| - bool isNameAffected(String name) {
|
| - return addedNames.contains(name) ||
|
| - changedNames.contains(name) ||
|
| - removedNames.contains(name);
|
| - }
|
| -
|
| - bool nameChanged(String name) {
|
| - return changedNames.add(name);
|
| + // We don't know what to do with the given target, invalidate it.
|
| + return DeltaResult.INVALIDATE;
|
| }
|
| }
|
|
|
|
|