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

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

Issue 2050573003: Issue 26629. Detect cache inconsistency in GetContentTask. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | pkg/analyzer/lib/task/model.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.context; 5 library analyzer.src.context.context;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 @override 674 @override
675 Object/*=V*/ computeResult/*<V>*/( 675 Object/*=V*/ computeResult/*<V>*/(
676 AnalysisTarget target, ResultDescriptor/*<V>*/ descriptor) { 676 AnalysisTarget target, ResultDescriptor/*<V>*/ descriptor) {
677 // Make sure we are not trying to invoke the task model in a reentrant 677 // Make sure we are not trying to invoke the task model in a reentrant
678 // fashion. 678 // fashion.
679 assert(!driver.isTaskRunning); 679 assert(!driver.isTaskRunning);
680 CacheEntry entry = getCacheEntry(target); 680 CacheEntry entry = getCacheEntry(target);
681 CacheState state = entry.getState(descriptor); 681 CacheState state = entry.getState(descriptor);
682 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { 682 if (state == CacheState.FLUSHED || state == CacheState.INVALID) {
683 driver.computeResult(target, descriptor); 683 driver.computeResult(target, descriptor);
684 entry = getCacheEntry(target);
684 } 685 }
685 state = entry.getState(descriptor); 686 state = entry.getState(descriptor);
686 if (state == CacheState.ERROR) { 687 if (state == CacheState.ERROR) {
687 throw new AnalysisException( 688 throw new AnalysisException(
688 'Cannot compute $descriptor for $target', entry.exception); 689 'Cannot compute $descriptor for $target', entry.exception);
689 } 690 }
690 return entry.getValue(descriptor); 691 return entry.getValue(descriptor);
691 } 692 }
692 693
693 /** 694 /**
(...skipping 27 matching lines...) Expand all
721 } 722 }
722 }); 723 });
723 return cache; 724 return cache;
724 } 725 }
725 726
726 /** 727 /**
727 * Create a minimalistic mock dart:async library 728 * Create a minimalistic mock dart:async library
728 * to stand in for a real one if one does not exist 729 * to stand in for a real one if one does not exist
729 * facilitating creation a type provider without dart:async. 730 * facilitating creation a type provider without dart:async.
730 */ 731 */
731 LibraryElement createMockAsyncLib(LibraryElement coreLibrary, Source asyncSour ce) { 732 LibraryElement createMockAsyncLib(
733 LibraryElement coreLibrary, Source asyncSource) {
732 InterfaceType objType = coreLibrary.getType('Object').type; 734 InterfaceType objType = coreLibrary.getType('Object').type;
733 735
734 ClassElement _classElement(String typeName, [List<String> parameterNames]) { 736 ClassElement _classElement(String typeName, [List<String> parameterNames]) {
735 ClassElementImpl element = 737 ClassElementImpl element =
736 new ClassElementImpl.forNode(AstFactory.identifier3(typeName)); 738 new ClassElementImpl.forNode(AstFactory.identifier3(typeName));
737 element.supertype = objType; 739 element.supertype = objType;
738 if (parameterNames != null) { 740 if (parameterNames != null) {
739 int count = parameterNames.length; 741 int count = parameterNames.length;
740 if (count > 0) { 742 if (count > 0) {
741 List<TypeParameterElementImpl> typeParameters = 743 List<TypeParameterElementImpl> typeParameters =
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 @override 1051 @override
1050 bool handleContentsChanged( 1052 bool handleContentsChanged(
1051 Source source, String originalContents, String newContents, bool notify) { 1053 Source source, String originalContents, String newContents, bool notify) {
1052 CacheEntry entry = _cache.get(source); 1054 CacheEntry entry = _cache.get(source);
1053 if (entry == null) { 1055 if (entry == null) {
1054 return false; 1056 return false;
1055 } 1057 }
1056 bool changed = newContents != originalContents; 1058 bool changed = newContents != originalContents;
1057 if (newContents != null) { 1059 if (newContents != null) {
1058 if (changed) { 1060 if (changed) {
1061 entry.modificationTime = _contentCache.getModificationStamp(source);
1059 if (!analysisOptions.incremental || 1062 if (!analysisOptions.incremental ||
1060 !_tryPoorMansIncrementalResolution(source, newContents)) { 1063 !_tryPoorMansIncrementalResolution(source, newContents)) {
1061 // Don't compare with old contents because the cache has already been 1064 // Don't compare with old contents because the cache has already been
1062 // updated, and we know at this point that it changed. 1065 // updated, and we know at this point that it changed.
1063 _sourceChanged(source, compareWithOld: false); 1066 _sourceChanged(source, compareWithOld: false);
1064 } 1067 }
1065 entry.modificationTime = _contentCache.getModificationStamp(source);
1066 entry.setValue(CONTENT, newContents, TargetedResult.EMPTY_LIST); 1068 entry.setValue(CONTENT, newContents, TargetedResult.EMPTY_LIST);
1067 } else { 1069 } else {
1068 entry.modificationTime = _contentCache.getModificationStamp(source); 1070 entry.modificationTime = _contentCache.getModificationStamp(source);
1069 } 1071 }
1070 } else if (originalContents != null) { 1072 } else if (originalContents != null) {
1071 // We are removing the overlay for the file, check if the file's 1073 // We are removing the overlay for the file, check if the file's
1072 // contents is the same as it was in the overlay. 1074 // contents is the same as it was in the overlay.
1073 try { 1075 try {
1074 TimestampedData<String> fileContents = getContents(source); 1076 TimestampedData<String> fileContents = getContents(source);
1075 newContents = fileContents.data; 1077 newContents = fileContents.data;
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 } 2223 }
2222 DartSdk sdk = factory.dartSdk; 2224 DartSdk sdk = factory.dartSdk;
2223 if (sdk == null) { 2225 if (sdk == null) {
2224 throw new IllegalArgumentException( 2226 throw new IllegalArgumentException(
2225 "The source factory for an SDK analysis context must have a DartUriRes olver"); 2227 "The source factory for an SDK analysis context must have a DartUriRes olver");
2226 } 2228 }
2227 return new AnalysisCache( 2229 return new AnalysisCache(
2228 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); 2230 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]);
2229 } 2231 }
2230 } 2232 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | pkg/analyzer/lib/task/model.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698