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

Side by Side Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 1218503003: Don't remove ResultData(s) for incrementally updated results. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Disable 'limitInvalidationInTaskModel' Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.context.cache; 5 library analyzer.src.context.cache;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 /** 485 /**
486 * Return the value of the flag with the given [index]. 486 * Return the value of the flag with the given [index].
487 */ 487 */
488 bool _getFlag(int index) => BooleanArray.get(_flags, index); 488 bool _getFlag(int index) => BooleanArray.get(_flags, index);
489 489
490 /** 490 /**
491 * Invalidate the result represented by the given [descriptor] and propagate 491 * Invalidate the result represented by the given [descriptor] and propagate
492 * invalidation to other results that depend on it. 492 * invalidation to other results that depend on it.
493 */ 493 */
494 void _invalidate(ResultDescriptor descriptor, Delta delta) { 494 void _invalidate(ResultDescriptor descriptor, Delta delta) {
495 if (delta != null && 495 DeltaResult deltaResult = null;
496 !delta.affects(_partition.context, target, descriptor)) { 496 if (delta != null) {
497 // print('not-invalidate $descriptor for $target'); 497 deltaResult = delta.validate(_partition.context, target, descriptor);
498 return; 498 if (deltaResult == DeltaResult.STOP) {
499 // print('not-invalidate $descriptor for $target');
500 return;
501 }
499 } 502 }
500 // print('invalidate $descriptor for $target'); 503 // print('invalidate $descriptor for $target');
501 ResultData thisData = _resultMap.remove(descriptor); 504 ResultData thisData;
505 if (deltaResult == null || deltaResult == DeltaResult.INVALIDATE) {
506 thisData = _resultMap.remove(descriptor);
507 }
508 if (deltaResult == DeltaResult.KEEP_CONTINUE) {
509 thisData = _resultMap[descriptor];
510 }
502 if (thisData == null) { 511 if (thisData == null) {
503 return; 512 return;
504 } 513 }
505 // Stop depending on other results. 514 // Stop depending on other results.
506 TargetedResult thisResult = new TargetedResult(target, descriptor); 515 TargetedResult thisResult = new TargetedResult(target, descriptor);
507 thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) { 516 for (TargetedResult dependedOnResult in thisData.dependedOnResults) {
508 ResultData data = _partition._getDataFor(dependedOnResult, orNull: true); 517 ResultData data = _partition._getDataFor(dependedOnResult, orNull: true);
509 if (data != null) { 518 if (data != null) {
510 data.dependentResults.remove(thisResult); 519 data.dependentResults.remove(thisResult);
511 } 520 }
512 }); 521 }
513 // Invalidate results that depend on this result. 522 // Invalidate results that depend on this result.
514 Set<TargetedResult> dependentResults = thisData.dependentResults; 523 List<TargetedResult> dependentResults = thisData.dependentResults.toList();
515 thisData.dependentResults = new Set<TargetedResult>(); 524 for (TargetedResult dependentResult in dependentResults) {
516 dependentResults.forEach((TargetedResult dependentResult) {
517 CacheEntry entry = _partition.get(dependentResult.target); 525 CacheEntry entry = _partition.get(dependentResult.target);
518 if (entry != null) { 526 if (entry != null) {
519 entry._invalidate(dependentResult.result, delta); 527 entry._invalidate(dependentResult.result, delta);
520 } 528 }
521 }); 529 }
522 // If empty, remove the entry altogether. 530 // If empty, remove the entry altogether.
523 if (_resultMap.isEmpty) { 531 if (_resultMap.isEmpty) {
524 _partition._targetMap.remove(target); 532 _partition._targetMap.remove(target);
525 _partition._removeIfSource(target); 533 _partition._removeIfSource(target);
526 } 534 }
527 // Notify controller. 535 // Notify controller.
528 _partition._onResultInvalidated 536 _partition._onResultInvalidated
529 .add(new InvalidatedResult(this, descriptor)); 537 .add(new InvalidatedResult(this, descriptor));
530 } 538 }
531 539
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 */ 977 */
970 class Delta { 978 class Delta {
971 final Source source; 979 final Source source;
972 980
973 Delta(this.source); 981 Delta(this.source);
974 982
975 /** 983 /**
976 * Check whether this delta affects the result described by the given 984 * Check whether this delta affects the result described by the given
977 * [descriptor] and [target]. 985 * [descriptor] and [target].
978 */ 986 */
979 bool affects(InternalAnalysisContext context, AnalysisTarget target, 987 DeltaResult validate(InternalAnalysisContext context, AnalysisTarget target,
980 ResultDescriptor descriptor) { 988 ResultDescriptor descriptor) {
981 return true; 989 return DeltaResult.INVALIDATE;
982 } 990 }
983 } 991 }
984 992
985 /** 993 /**
994 * The possible results of validating analysis results againt a [Delta].
995 */
996 enum DeltaResult { INVALIDATE, KEEP_CONTINUE, STOP }
997
998 /**
986 * [InvalidatedResult] describes an invalidated result. 999 * [InvalidatedResult] describes an invalidated result.
987 */ 1000 */
988 class InvalidatedResult { 1001 class InvalidatedResult {
989 /** 1002 /**
990 * The target in which the result was invalidated. 1003 * The target in which the result was invalidated.
991 */ 1004 */
992 final CacheEntry entry; 1005 final CacheEntry entry;
993 1006
994 /** 1007 /**
995 * The descriptor of the result which was invalidated. 1008 * The descriptor of the result which was invalidated.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 void resultAccessed(TargetedResult result) {} 1151 void resultAccessed(TargetedResult result) {}
1139 1152
1140 @override 1153 @override
1141 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { 1154 List<TargetedResult> resultStored(TargetedResult newResult, newValue) {
1142 return TargetedResult.EMPTY_LIST; 1155 return TargetedResult.EMPTY_LIST;
1143 } 1156 }
1144 1157
1145 @override 1158 @override
1146 void targetRemoved(AnalysisTarget target) {} 1159 void targetRemoved(AnalysisTarget target) {}
1147 } 1160 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | pkg/analyzer/lib/src/context/context.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698