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

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

Issue 1124113004: Get AnalysisCache from InternalAnalysisContext. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »
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.cache; 5 library analyzer.src.context.cache;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/engine.dart' 9 import 'package:analyzer/src/generated/engine.dart'
10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority; 10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority;
(...skipping 22 matching lines...) Expand all
33 * An array containing the partitions of which this cache is comprised. 33 * An array containing the partitions of which this cache is comprised.
34 */ 34 */
35 final List<CachePartition> _partitions; 35 final List<CachePartition> _partitions;
36 36
37 /** 37 /**
38 * Initialize a newly created cache to have the given [partitions]. The 38 * Initialize a newly created cache to have the given [partitions]. The
39 * partitions will be searched in the order in which they appear in the array, 39 * partitions will be searched in the order in which they appear in the array,
40 * so the most specific partition (usually an [SdkCachePartition]) should be 40 * so the most specific partition (usually an [SdkCachePartition]) should be
41 * first and the most general (usually a [UniversalCachePartition]) last. 41 * first and the most general (usually a [UniversalCachePartition]) last.
42 */ 42 */
43 AnalysisCache(this._partitions) { 43 AnalysisCache(this._partitions);
44 for (CachePartition partition in _partitions) {
45 partition._cache = this;
46 }
47 }
48 44
49 // TODO(brianwilkerson) Implement or delete this. 45 // TODO(brianwilkerson) Implement or delete this.
50 // /** 46 // /**
51 // * Return information about each of the partitions in this cache. 47 // * Return information about each of the partitions in this cache.
52 // */ 48 // */
53 // List<AnalysisContextStatistics_PartitionData> get partitionData { 49 // List<AnalysisContextStatistics_PartitionData> get partitionData {
54 // int count = _partitions.length; 50 // int count = _partitions.length;
55 // List<AnalysisContextStatistics_PartitionData> data = 51 // List<AnalysisContextStatistics_PartitionData> data =
56 // new List<AnalysisContextStatistics_PartitionData>(count); 52 // new List<AnalysisContextStatistics_PartitionData>(count);
57 // for (int i = 0; i < count; i++) { 53 // for (int i = 0; i < count; i++) {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 594 }
599 recentlyUsed.removeAll(resultsToRemove); 595 recentlyUsed.removeAll(resultsToRemove);
600 } 596 }
601 } 597 }
602 598
603 /** 599 /**
604 * A single partition in an LRU cache of information related to analysis. 600 * A single partition in an LRU cache of information related to analysis.
605 */ 601 */
606 abstract class CachePartition { 602 abstract class CachePartition {
607 /** 603 /**
608 * The [AnalysisCache] that owns this partition.
609 *
610 * TODO(scheglov) It seems wrong. Partitions may be shared between caches.
611 * But we need a way to go from every "enclosing" partition into "enclosed"
612 * ones.
613 */
614 AnalysisCache _cache;
615
616 /**
617 * The context that owns this partition. Multiple contexts can reference a 604 * The context that owns this partition. Multiple contexts can reference a
618 * partition, but only one context can own it. 605 * partition, but only one context can own it.
619 */ 606 */
620 final InternalAnalysisContext context; 607 final InternalAnalysisContext context;
621 608
622 /** 609 /**
623 * A table mapping caching policies to the cache flush managers. 610 * A table mapping caching policies to the cache flush managers.
624 */ 611 */
625 final HashMap<ResultCachingPolicy, CacheFlushManager> _flushManagerMap = 612 final HashMap<ResultCachingPolicy, CacheFlushManager> _flushManagerMap =
626 new HashMap<ResultCachingPolicy, CacheFlushManager>(); 613 new HashMap<ResultCachingPolicy, CacheFlushManager>();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 data.flush(); 700 data.flush();
714 } 701 }
715 } 702 }
716 703
717 /** 704 /**
718 * Return the number of targets that are mapped to cache entries. 705 * Return the number of targets that are mapped to cache entries.
719 */ 706 */
720 int size() => _targetMap.length; 707 int size() => _targetMap.length;
721 708
722 ResultData _getDataFor(TargetedResult result) { 709 ResultData _getDataFor(TargetedResult result) {
723 return _cache._getDataFor(result); 710 return context.analysisCache._getDataFor(result);
724 } 711 }
725 712
726 /** 713 /**
727 * Return the [CacheFlushManager] for the given [descriptor], not `null`. 714 * Return the [CacheFlushManager] for the given [descriptor], not `null`.
728 */ 715 */
729 CacheFlushManager _getFlushManager(ResultDescriptor descriptor) { 716 CacheFlushManager _getFlushManager(ResultDescriptor descriptor) {
730 ResultCachingPolicy policy = descriptor.cachingPolicy; 717 ResultCachingPolicy policy = descriptor.cachingPolicy;
731 return _flushManagerMap.putIfAbsent( 718 return _flushManagerMap.putIfAbsent(
732 policy, () => new CacheFlushManager(policy, _isPriorityAnalysisTarget)); 719 policy, () => new CacheFlushManager(policy, _isPriorityAnalysisTarget));
733 } 720 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 */ 840 */
854 class SdkCachePartition extends CachePartition { 841 class SdkCachePartition extends CachePartition {
855 /** 842 /**
856 * Initialize a newly created cache partition, belonging to the given 843 * Initialize a newly created cache partition, belonging to the given
857 * [context]. 844 * [context].
858 */ 845 */
859 SdkCachePartition(InternalAnalysisContext context) : super(context); 846 SdkCachePartition(InternalAnalysisContext context) : super(context);
860 847
861 @override 848 @override
862 bool contains(AnalysisTarget target) { 849 bool contains(AnalysisTarget target) {
850 if (target is AnalysisContextTarget) {
851 return true;
852 }
863 Source source = target.source; 853 Source source = target.source;
864 return source != null && source.isInSystemLibrary; 854 return source != null && source.isInSystemLibrary;
865 } 855 }
866 } 856 }
867 857
868 /** 858 /**
869 * A specification of a specific result computed for a specific target. 859 * A specification of a specific result computed for a specific target.
870 */ 860 */
871 class TargetedResult { 861 class TargetedResult {
872 /** 862 /**
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 class UniversalCachePartition extends CachePartition { 901 class UniversalCachePartition extends CachePartition {
912 /** 902 /**
913 * Initialize a newly created cache partition, belonging to the given 903 * Initialize a newly created cache partition, belonging to the given
914 * [context]. 904 * [context].
915 */ 905 */
916 UniversalCachePartition(InternalAnalysisContext context) : super(context); 906 UniversalCachePartition(InternalAnalysisContext context) : super(context);
917 907
918 @override 908 @override
919 bool contains(AnalysisTarget target) => true; 909 bool contains(AnalysisTarget target) => true;
920 } 910 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698