Revert "Flush AST results for source outside of the analysis roots."

This reverts commit b115309531.

Revert "Use FlushTargetFilter to pre-filter targets before checking their results."

This reverts commit 2e24662c06.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2298043002 .
This commit is contained in:
Konstantin Shcheglov 2016-08-30 19:55:10 -07:00
parent ba11ae416f
commit f8f4228728
6 changed files with 20 additions and 55 deletions

View file

@ -9,7 +9,6 @@ import 'package:analysis_server/src/computer/computer_highlights.dart';
import 'package:analysis_server/src/computer/computer_highlights2.dart';
import 'package:analysis_server/src/computer/computer_outline.dart';
import 'package:analysis_server/src/computer/computer_overrides.dart';
import 'package:analysis_server/src/context_manager.dart';
import 'package:analysis_server/src/domains/analysis/implemented_dart.dart';
import 'package:analysis_server/src/domains/analysis/navigation.dart';
import 'package:analysis_server/src/domains/analysis/occurrences.dart';
@ -22,8 +21,6 @@ import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/task/dart.dart';
import 'package:analyzer/task/model.dart';
/**
* Runs the given function [f] with the working cache size in [context].
@ -379,7 +376,6 @@ class PerformAnalysisOperation extends ServerOperation {
setCacheSize(context, IDLE_CACHE_SIZE);
server.sendContextAnalysisDoneNotifications(
context, AnalysisDoneReason.COMPLETE);
_flushCache(server);
return;
}
// process results
@ -391,28 +387,6 @@ class PerformAnalysisOperation extends ServerOperation {
server.addOperation(new PerformAnalysisOperation(context, true));
}
/**
* Flush some of the [context] cache results, which we probably not
* going to use anymore.
*/
void _flushCache(AnalysisServer server) {
if (context is InternalAnalysisContext) {
InternalAnalysisContext context = this.context;
// Flush AST results for source outside of the analysis roots.
ContextManager contextManager = server.contextManager;
context.analysisCache.flush((target) {
if (target is Source || target is LibrarySpecificUnit) {
Source targetSource = target.source;
return !context.prioritySources.contains(targetSource) &&
!contextManager.isInAnalysisRoot(targetSource.fullName);
}
return false;
}, (target, result) {
return result is ResultDescriptor<CompilationUnit>;
});
}
}
/**
* Send the information in the given list of notices back to the client.
*/

View file

@ -310,7 +310,7 @@ class CompletionDomainHandlerTest extends AbstractCompletionDomainTest {
expect(suggestions, isEmpty);
}
fail_inDartDoc_reference1() async {
test_inDartDoc_reference1() async {
addFile(
'/testA.dart',
'''
@ -498,7 +498,7 @@ class B extends A {m() {^}}
});
}
fail_partFile2() {
test_partFile2() {
addFile(
'/testA.dart',
'''

View file

@ -26,11 +26,6 @@ typedef void CacheResultVisitor(AnalysisTarget target, ResultData data);
typedef bool FlushResultFilter<V>(
AnalysisTarget target, ResultDescriptor<V> result);
/**
* Return `true` if some results of the [target] should be flushed.
*/
typedef bool FlushTargetFilter<V>(AnalysisTarget target);
/**
* Return `true` if the given [target] is a priority one.
*/
@ -118,11 +113,11 @@ class AnalysisCache {
}
/**
* Flush results that satisfy the given [targetFilter] and [resultFilter].
* Flush results that satisfy the given [filter].
*/
void flush(FlushTargetFilter targetFilter, FlushResultFilter resultFilter) {
void flush(FlushResultFilter filter) {
for (CachePartition partition in _partitions) {
partition.flush(targetFilter, resultFilter);
partition.flush(filter);
}
}
@ -410,18 +405,14 @@ class CacheEntry {
}
/**
* Flush results that satisfy the given [targetFilter] and [resultFilter].
* Flush results that satisfy the given [filter].
*/
void flush(FlushTargetFilter targetFilter, FlushResultFilter resultFilter) {
if (targetFilter(target)) {
_resultMap.forEach((ResultDescriptor result, ResultData data) {
if (data.state == CacheState.VALID) {
if (resultFilter(target, result)) {
data.flush();
}
}
});
}
void flush(FlushResultFilter filter) {
_resultMap.forEach((ResultDescriptor result, ResultData data) {
if (filter(target, result)) {
data.flush();
}
});
}
/**
@ -1102,11 +1093,11 @@ abstract class CachePartition {
}
/**
* Flush results that satisfy the given [targetFilter] and [resultFilter].
* Flush results that satisfy the given [filter].
*/
void flush(FlushTargetFilter targetFilter, FlushResultFilter resultFilter) {
void flush(FlushResultFilter filter) {
for (CacheEntry entry in entryMap.values) {
entry.flush(targetFilter, resultFilter);
entry.flush(filter);
}
}

View file

@ -70,7 +70,7 @@ class AnalysisCacheTest extends AbstractCacheTest {
expect(cache.getValue(target, resultA), 'a');
expect(cache.getValue(target, resultB), 'b');
// flush A
cache.flush((target) => true, (target, result) => result == resultA);
cache.flush((target, result) => result == resultA);
expect(cache.getState(target, resultA), CacheState.FLUSHED);
expect(cache.getState(target, resultB), CacheState.VALID);
expect(cache.getValue(target, resultA), isNull);
@ -336,7 +336,7 @@ class CacheEntryTest extends AbstractCacheTest {
expect(entry.getValue(resultA), 'a');
expect(entry.getValue(resultB), 'b');
// flush A
entry.flush((target) => true, (target, result) => result == resultA);
entry.flush((target, result) => result == resultA);
expect(entry.getState(resultA), CacheState.FLUSHED);
expect(entry.getState(resultB), CacheState.VALID);
expect(entry.getValue(resultA), isNull);

View file

@ -1122,7 +1122,7 @@ import 'dart:async';
context.applyChanges(new ChangeSet()..addedSource(source));
context.resolveCompilationUnit2(source, source);
// Flush all results units.
context.analysisCache.flush((target) => true, (target, result) {
context.analysisCache.flush((target, result) {
if (target.source == source) {
return RESOLVED_UNIT_RESULTS.contains(result);
}
@ -1148,7 +1148,7 @@ main() {}
context.applyChanges(new ChangeSet()..addedSource(source));
context.resolveCompilationUnit2(source, source);
// Flush all results units.
context.analysisCache.flush((target) => true, (target, result) {
context.analysisCache.flush((target, result) {
if (target.source == source) {
if (target.source == source) {
return RESOLVED_UNIT_RESULTS.contains(result);

View file

@ -2001,7 +2001,7 @@ main() {
unitDelta = builder.unitDelta;
expect(newUnit.element, unitElement);
// Flush all tokens, ASTs and elements.
context.analysisCache.flush((target) => true, (target, result) {
context.analysisCache.flush((target, result) {
return result == TOKEN_STREAM ||
result == PARSED_UNIT ||
RESOLVED_UNIT_RESULTS.contains(result) ||