mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:37:53 +00:00
Get AnalysisCache from InternalAnalysisContext.
R=brianwilkerson@google.com BUG= Review URL: https://codereview.chromium.org//1124113004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45609 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
11f96844dc
commit
9aeccc0d2f
|
@ -40,11 +40,7 @@ class AnalysisCache {
|
|||
* so the most specific partition (usually an [SdkCachePartition]) should be
|
||||
* first and the most general (usually a [UniversalCachePartition]) last.
|
||||
*/
|
||||
AnalysisCache(this._partitions) {
|
||||
for (CachePartition partition in _partitions) {
|
||||
partition._cache = this;
|
||||
}
|
||||
}
|
||||
AnalysisCache(this._partitions);
|
||||
|
||||
// TODO(brianwilkerson) Implement or delete this.
|
||||
// /**
|
||||
|
@ -644,15 +640,6 @@ class CacheFlushManager<T> {
|
|||
* A single partition in an LRU cache of information related to analysis.
|
||||
*/
|
||||
abstract class CachePartition {
|
||||
/**
|
||||
* The [AnalysisCache] that owns this partition.
|
||||
*
|
||||
* TODO(scheglov) It seems wrong. Partitions may be shared between caches.
|
||||
* But we need a way to go from every "enclosing" partition into "enclosed"
|
||||
* ones.
|
||||
*/
|
||||
AnalysisCache _cache;
|
||||
|
||||
/**
|
||||
* The context that owns this partition. Multiple contexts can reference a
|
||||
* partition, but only one context can own it.
|
||||
|
@ -760,7 +747,7 @@ abstract class CachePartition {
|
|||
int size() => _targetMap.length;
|
||||
|
||||
ResultData _getDataFor(TargetedResult result) {
|
||||
return _cache._getDataFor(result);
|
||||
return context.analysisCache._getDataFor(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -845,6 +832,9 @@ class SdkCachePartition extends CachePartition {
|
|||
|
||||
@override
|
||||
bool contains(AnalysisTarget target) {
|
||||
if (target is AnalysisContextTarget) {
|
||||
return true;
|
||||
}
|
||||
Source source = target.source;
|
||||
return source != null && source.isInSystemLibrary;
|
||||
}
|
||||
|
|
|
@ -189,6 +189,9 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
|||
new StreamController<SourcesChangedEvent>.broadcast();
|
||||
}
|
||||
|
||||
@override
|
||||
cache.AnalysisCache get analysisCache => _cache;
|
||||
|
||||
@override
|
||||
AnalysisOptions get analysisOptions => _options;
|
||||
|
||||
|
@ -566,8 +569,10 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
|||
}
|
||||
|
||||
@override
|
||||
LibraryElement computeLibraryElement(Source source) => _computeResult(
|
||||
source, LIBRARY_ELEMENT); //_computeResult(source, HtmlEntry.ELEMENT);
|
||||
LibraryElement computeLibraryElement(Source source) {
|
||||
//_computeResult(source, HtmlEntry.ELEMENT);
|
||||
return _computeResult(source, LIBRARY_ELEMENT);
|
||||
}
|
||||
|
||||
@override
|
||||
LineInfo computeLineInfo(Source source) => _computeResult(source, LINE_INFO);
|
||||
|
|
|
@ -1032,6 +1032,9 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
|||
new StreamController<SourcesChangedEvent>.broadcast();
|
||||
}
|
||||
|
||||
@override
|
||||
AnalysisCache get analysisCache => _cache;
|
||||
|
||||
@override
|
||||
AnalysisOptions get analysisOptions => _options;
|
||||
|
||||
|
@ -4057,28 +4060,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Record the results produced by performing a [task] and return the cache
|
||||
* entry associated with the results.
|
||||
*/
|
||||
DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
|
||||
Source source = task.source;
|
||||
Source library = task.library;
|
||||
DartEntry dartEntry = _cache.get(source);
|
||||
CaughtException thrownException = task.exception;
|
||||
if (thrownException != null) {
|
||||
dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
|
||||
throw new AnalysisException('<rethrow>', thrownException);
|
||||
}
|
||||
dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
|
||||
dartEntry.setValueInLibrary(
|
||||
DartEntry.BUILT_ELEMENT, library, task.unitElement);
|
||||
ChangeNoticeImpl notice = _getNotice(source);
|
||||
LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
|
||||
notice.setErrors(dartEntry.allErrors, lineInfo);
|
||||
return dartEntry;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Notify all of the analysis listeners that the given source is no longer included in the set of
|
||||
// * sources that are being analyzed.
|
||||
|
@ -4157,6 +4138,28 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
|||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Record the results produced by performing a [task] and return the cache
|
||||
* entry associated with the results.
|
||||
*/
|
||||
DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
|
||||
Source source = task.source;
|
||||
Source library = task.library;
|
||||
DartEntry dartEntry = _cache.get(source);
|
||||
CaughtException thrownException = task.exception;
|
||||
if (thrownException != null) {
|
||||
dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
|
||||
throw new AnalysisException('<rethrow>', thrownException);
|
||||
}
|
||||
dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
|
||||
dartEntry.setValueInLibrary(
|
||||
DartEntry.BUILT_ELEMENT, library, task.unitElement);
|
||||
ChangeNoticeImpl notice = _getNotice(source);
|
||||
LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
|
||||
notice.setErrors(dartEntry.allErrors, lineInfo);
|
||||
return dartEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a [dartEntry] and a [library] element, record the library element and
|
||||
* other information gleaned from the element in the cache entry.
|
||||
|
@ -9018,6 +9021,14 @@ class IncrementalAnalysisTask extends AnalysisTask {
|
|||
* users of the context.
|
||||
*/
|
||||
abstract class InternalAnalysisContext implements AnalysisContext {
|
||||
/**
|
||||
* A table mapping the sources known to the context to the information known
|
||||
* about the source.
|
||||
*
|
||||
* TODO(scheglov) add the type, once we have only one cache.
|
||||
*/
|
||||
dynamic get analysisCache;
|
||||
|
||||
/**
|
||||
* Allow the client to supply its own content cache. This will take the
|
||||
* place of the content cache created by default, allowing clients to share
|
||||
|
|
|
@ -5409,6 +5409,11 @@ class SourcesChangedListener {
|
|||
* method will cause a test to fail when invoked.
|
||||
*/
|
||||
class TestAnalysisContext implements InternalAnalysisContext {
|
||||
@override
|
||||
AnalysisCache get analysisCache {
|
||||
fail("Unexpected invocation of analysisCache");
|
||||
return null;
|
||||
}
|
||||
@override
|
||||
AnalysisOptions get analysisOptions {
|
||||
fail("Unexpected invocation of getAnalysisOptions");
|
||||
|
|
|
@ -106,7 +106,7 @@ class CacheEntryTest extends EngineTestCase {
|
|||
context = new _InternalAnalysisContextMock();
|
||||
when(context.priorityTargets).thenReturn([]);
|
||||
cache = createCache(context: context);
|
||||
// when(context.analysisCache).thenReturn(cache);
|
||||
when(context.analysisCache).thenReturn(cache);
|
||||
}
|
||||
|
||||
test_explicitlyAdded() {
|
||||
|
|
Loading…
Reference in a new issue