Remove CompositeResultDescriptor

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1136603002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45613 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
brianwilkerson@google.com 2015-05-07 20:00:49 +00:00
parent 05e6d1cf78
commit 9414515ba7
4 changed files with 14 additions and 131 deletions

View file

@ -1337,14 +1337,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
Object /*V*/ _computeResult(
AnalysisTarget target, ResultDescriptor /*<V>*/ descriptor) {
cache.CacheEntry entry = getCacheEntry(target);
if (descriptor is CompositeResultDescriptor) {
List compositeResults = [];
for (ResultDescriptor descriptor in descriptor.contributors) {
List value = _computeResult(target, descriptor);
compositeResults.addAll(value);
}
return compositeResults;
}
CacheState state = entry.getState(descriptor);
if (state == CacheState.FLUSHED || state == CacheState.INVALID) {
_driver.computeResult(target, descriptor);
@ -1488,14 +1480,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (entry == null) {
return descriptor.defaultValue;
}
if (descriptor is CompositeResultDescriptor) {
List compositeResults = [];
for (ResultDescriptor descriptor in descriptor.contributors) {
List value = _getResult(target, descriptor);
compositeResults.addAll(value);
}
return compositeResults;
}
if (entry.isValid(descriptor)) {
return entry.getValue(descriptor);
}

View file

@ -14,29 +14,6 @@ import 'package:analyzer/task/model.dart';
const ResultCachingPolicy DEFAULT_CACHING_POLICY =
const SimpleResultCachingPolicy(-1, -1);
/**
* A concrete implementation of a [CompositeResultDescriptor].
*/
class CompositeResultDescriptorImpl<V> extends ResultDescriptorImpl<V>
implements CompositeResultDescriptor<V> {
/**
* The results that contribute to this result.
*/
final List<ResultDescriptor<V>> contributors = <ResultDescriptor<V>>[];
/**
* Initialize a newly created composite result to have the given [name].
*/
CompositeResultDescriptorImpl(String name) : super(name, null);
/**
* Record that the given analysis [result] contibutes to this result.
*/
void recordContributor(ResultDescriptor<V> result) {
contributors.add(result);
}
}
/**
* A concrete implementation of a [ListResultDescriptor].
*/
@ -44,14 +21,12 @@ class ListResultDescriptorImpl<E> extends ResultDescriptorImpl<List<E>>
implements ListResultDescriptor<E> {
/**
* Initialize a newly created analysis result to have the given [name] and
* [defaultValue]. If a composite result is specified, then this result will
* contribute to it.
* [defaultValue]. If a [cachingPolicy] is provided, it will control how long
* values associated with this result will remain in the cache.
*/
ListResultDescriptorImpl(String name, List<E> defaultValue,
{CompositeResultDescriptor contributesTo,
ResultCachingPolicy<List<E>> cachingPolicy: DEFAULT_CACHING_POLICY})
: super(name, defaultValue,
contributesTo: contributesTo, cachingPolicy: cachingPolicy);
{ResultCachingPolicy<List<E>> cachingPolicy: DEFAULT_CACHING_POLICY})
: super(name, defaultValue, cachingPolicy: cachingPolicy);
@override
ListTaskInput<E> of(AnalysisTarget target) =>
@ -79,16 +54,11 @@ class ResultDescriptorImpl<V> implements ResultDescriptor<V> {
/**
* Initialize a newly created analysis result to have the given [name] and
* [defaultValue]. If a composite result is specified, then this result will
* contribute to it.
* [defaultValue]. If a [cachingPolicy] is provided, it will control how long
* values associated with this result will remain in the cache.
*/
ResultDescriptorImpl(this.name, this.defaultValue,
{CompositeResultDescriptor contributesTo,
this.cachingPolicy: DEFAULT_CACHING_POLICY}) {
if (contributesTo is CompositeResultDescriptorImpl) {
contributesTo.recordContributor(this);
}
}
{this.cachingPolicy: DEFAULT_CACHING_POLICY});
@override
TaskInput<V> of(AnalysisTarget target) =>

View file

@ -245,28 +245,6 @@ abstract class AnalysisTask {
}
}
/**
* A [ResultDescriptor] that denotes an analysis result that is a union of
* one or more other results.
*
* Clients are not expected to subtype this class.
*/
abstract class CompositeResultDescriptor<V> extends ResultDescriptor<V> {
/**
* Initialize a newly created composite result to have the given [name].
*/
factory CompositeResultDescriptor(
String name) = CompositeResultDescriptorImpl;
/**
* Return a list containing the descriptors of the results that are unioned
* together to compose the value of this result.
*
* Clients must not modify the returned list.
*/
List<ResultDescriptor<V>> get contributors;
}
/**
* A description of a [List]-based analysis result that can be computed by an
* [AnalysisTask].
@ -275,12 +253,12 @@ abstract class CompositeResultDescriptor<V> extends ResultDescriptor<V> {
*/
abstract class ListResultDescriptor<E> implements ResultDescriptor<List<E>> {
/**
* Initialize a newly created analysis result to have the given [name]. If a
* composite result is specified, then this result will contribute to it.
* Initialize a newly created analysis result to have the given [name] and
* [defaultValue]. If a [cachingPolicy] is provided, it will control how long
* values associated with this result will remain in the cache.
*/
factory ListResultDescriptor(String name, List<E> defaultValue,
{CompositeResultDescriptor<List<E>> contributesTo,
ResultCachingPolicy<List<E>> cachingPolicy}) = ListResultDescriptorImpl<E>;
{ResultCachingPolicy<List<E>> cachingPolicy}) = ListResultDescriptorImpl<E>;
@override
ListTaskInput<E> of(AnalysisTarget target);
@ -371,16 +349,15 @@ abstract class ResultCachingPolicy<T> {
*/
abstract class ResultDescriptor<V> {
/**
* Initialize a newly created analysis result to have the given [name]. If a
* composite result is specified, then this result will contribute to it.
* Initialize a newly created analysis result to have the given [name] and
* [defaultValue].
*
* The given [cachingPolicy] is used to limit the total size of results
* described by this descriptor. If no policy is specified, the results are
* never evicted from the cache, and removed only when they are invalidated.
*/
factory ResultDescriptor(String name, V defaultValue,
{CompositeResultDescriptor<V> contributesTo,
ResultCachingPolicy<V> cachingPolicy}) = ResultDescriptorImpl;
{ResultCachingPolicy<V> cachingPolicy}) = ResultDescriptorImpl;
/**
* Return the caching policy for results described by this descriptor.

View file

@ -17,7 +17,6 @@ import 'test_support.dart';
main() {
groupSep = ' | ';
runReflectiveTests(AnalysisTaskTest);
runReflectiveTests(ContributionPointImplTest);
runReflectiveTests(ResultDescriptorImplTest);
runReflectiveTests(SimpleResultCachingPolicyTest);
runReflectiveTests(TaskDescriptorImplTest);
@ -56,43 +55,6 @@ class AnalysisTaskTest extends EngineTestCase {
}
}
@reflectiveTest
class ContributionPointImplTest extends EngineTestCase {
test_contributors_empty() {
CompositeResultDescriptorImpl point =
new CompositeResultDescriptorImpl('point');
List<ResultDescriptor> contributors = point.contributors;
expect(contributors, isEmpty);
}
test_contributors_nonEmpty() {
ResultDescriptorImpl result1 = new ResultDescriptorImpl('result1', null);
ResultDescriptorImpl result2 = new ResultDescriptorImpl('result2', null);
CompositeResultDescriptorImpl point =
new CompositeResultDescriptorImpl('point');
point.recordContributor(result1);
point.recordContributor(result2);
List<ResultDescriptor> contributors = point.contributors;
expect(contributors, isNotNull);
expect(contributors, hasLength(2));
if (!(contributors[0] == result1 && contributors[1] == result2) ||
(contributors[0] == result2 && contributors[1] == result1)) {
fail("Invalid contributors: $contributors");
}
}
test_create() {
expect(new CompositeResultDescriptorImpl('name'), isNotNull);
}
test_name() {
String name = 'point';
CompositeResultDescriptorImpl point =
new CompositeResultDescriptorImpl(name);
expect(point.name, name);
}
}
@reflectiveTest
class ResultDescriptorImplTest extends EngineTestCase {
test_create_withCachingPolicy() {
@ -102,16 +64,6 @@ class ResultDescriptorImplTest extends EngineTestCase {
expect(result.cachingPolicy, same(policy));
}
test_create_withContribution() {
CompositeResultDescriptorImpl point =
new CompositeResultDescriptorImpl('point');
ResultDescriptorImpl result =
new ResultDescriptorImpl('result', null, contributesTo: point);
expect(result, isNotNull);
List<ResultDescriptor> contributors = point.contributors;
expect(contributors, unorderedEquals([result]));
}
test_create_withoutCachingPolicy() {
ResultDescriptorImpl result = new ResultDescriptorImpl('result', null);
ResultCachingPolicy cachingPolicy = result.cachingPolicy;