Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.task.model; | 5 library analyzer.src.task.model; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 8 import 'package:analyzer/src/task/inputs.dart'; | 8 import 'package:analyzer/src/task/inputs.dart'; |
| 9 import 'package:analyzer/task/model.dart'; | 9 import 'package:analyzer/task/model.dart'; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * The default [ResultCachingPolicy], results are never flushed. | 12 * The default [ResultCachingPolicy], results are never flushed. |
| 13 */ | 13 */ |
| 14 const ResultCachingPolicy DEFAULT_CACHING_POLICY = | 14 const ResultCachingPolicy DEFAULT_CACHING_POLICY = |
| 15 const SimpleResultCachingPolicy(-1, -1); | 15 const SimpleResultCachingPolicy(-1, -1); |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * A concrete implementation of a [CompositeResultDescriptor]. | |
| 19 */ | |
| 20 class CompositeResultDescriptorImpl<V> extends ResultDescriptorImpl<V> | |
| 21 implements CompositeResultDescriptor<V> { | |
| 22 /** | |
| 23 * The results that contribute to this result. | |
| 24 */ | |
| 25 final List<ResultDescriptor<V>> contributors = <ResultDescriptor<V>>[]; | |
| 26 | |
| 27 /** | |
| 28 * Initialize a newly created composite result to have the given [name]. | |
| 29 */ | |
| 30 CompositeResultDescriptorImpl(String name) : super(name, null); | |
| 31 | |
| 32 /** | |
| 33 * Record that the given analysis [result] contibutes to this result. | |
| 34 */ | |
| 35 void recordContributor(ResultDescriptor<V> result) { | |
| 36 contributors.add(result); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 /** | |
| 41 * A concrete implementation of a [ListResultDescriptor]. | 18 * A concrete implementation of a [ListResultDescriptor]. |
| 42 */ | 19 */ |
| 43 class ListResultDescriptorImpl<E> extends ResultDescriptorImpl<List<E>> | 20 class ListResultDescriptorImpl<E> extends ResultDescriptorImpl<List<E>> |
| 44 implements ListResultDescriptor<E> { | 21 implements ListResultDescriptor<E> { |
| 45 /** | 22 /** |
| 46 * Initialize a newly created analysis result to have the given [name] and | 23 * Initialize a newly created analysis result to have the given [name] and |
| 47 * [defaultValue]. If a composite result is specified, then this result will | 24 * [defaultValue]. If a [cachingPolicy] is provided, it will control how long |
| 48 * contribute to it. | 25 * values associated with this result will remain in the cache. |
| 49 */ | 26 */ |
| 50 ListResultDescriptorImpl(String name, List<E> defaultValue, | 27 ListResultDescriptorImpl(String name, List<E> defaultValue, |
| 51 {CompositeResultDescriptor contributesTo, | 28 {ResultCachingPolicy<List<E>> cachingPolicy: DEFAULT_CACHING_POLICY}) |
| 52 ResultCachingPolicy<List<E>> cachingPolicy: DEFAULT_CACHING_POLICY}) | 29 : super(name, defaultValue, cachingPolicy: cachingPolicy); |
| 53 : super(name, defaultValue, | |
| 54 contributesTo: contributesTo, cachingPolicy: cachingPolicy); | |
| 55 | 30 |
| 56 @override | 31 @override |
| 57 ListTaskInput<E> of(AnalysisTarget target) => | 32 ListTaskInput<E> of(AnalysisTarget target) => |
| 58 new ListTaskInputImpl<E>(target, this); | 33 new ListTaskInputImpl<E>(target, this); |
| 59 } | 34 } |
| 60 | 35 |
| 61 /** | 36 /** |
| 62 * A concrete implementation of a [ResultDescriptor]. | 37 * A concrete implementation of a [ResultDescriptor]. |
| 63 */ | 38 */ |
| 64 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { | 39 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { |
| 65 /** | 40 /** |
| 66 * The name of the result, used for debugging. | 41 * The name of the result, used for debugging. |
| 67 */ | 42 */ |
| 68 final String name; | 43 final String name; |
| 69 | 44 |
| 70 /** | 45 /** |
| 71 * Return the default value for results described by this descriptor. | 46 * Return the default value for results described by this descriptor. |
| 72 */ | 47 */ |
| 73 final V defaultValue; | 48 final V defaultValue; |
| 74 | 49 |
| 75 /** | 50 /** |
| 76 * The caching policy for results described by this descriptor. | 51 * The caching policy for results described by this descriptor. |
| 77 */ | 52 */ |
| 78 final ResultCachingPolicy<V> cachingPolicy; | 53 final ResultCachingPolicy<V> cachingPolicy; |
| 79 | 54 |
| 80 /** | 55 /** |
| 81 * Initialize a newly created analysis result to have the given [name] and | 56 * Initialize a newly created analysis result to have the given [name] and |
| 82 * [defaultValue]. If a composite result is specified, then this result will | 57 * [defaultValue]. If a [cachingPolicy] is provided, it will control how long |
| 83 * contribute to it. | 58 * values associated with this result will remain in the cache. |
| 84 */ | 59 */ |
| 85 ResultDescriptorImpl(this.name, this.defaultValue, | 60 ResultDescriptorImpl(this.name, this.defaultValue, |
|
scheglov
2015/05/07 19:33:50
Can we make this a constant constructor now?
Brian Wilkerson
2015/05/07 20:00:30
I'm not sure it can remain a const constructor. We
| |
| 86 {CompositeResultDescriptor contributesTo, | 61 {this.cachingPolicy: DEFAULT_CACHING_POLICY}); |
| 87 this.cachingPolicy: DEFAULT_CACHING_POLICY}) { | |
| 88 if (contributesTo is CompositeResultDescriptorImpl) { | |
| 89 contributesTo.recordContributor(this); | |
| 90 } | |
| 91 } | |
| 92 | 62 |
| 93 @override | 63 @override |
| 94 TaskInput<V> of(AnalysisTarget target) => | 64 TaskInput<V> of(AnalysisTarget target) => |
| 95 new SimpleTaskInput<V>(target, this); | 65 new SimpleTaskInput<V>(target, this); |
| 96 | 66 |
| 97 @override | 67 @override |
| 98 String toString() => name; | 68 String toString() => name; |
| 99 } | 69 } |
| 100 | 70 |
| 101 /** | 71 /** |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 Map<String, dynamic> inputs, Object inputMemento) { | 125 Map<String, dynamic> inputs, Object inputMemento) { |
| 156 AnalysisTask task = buildTask(context, target); | 126 AnalysisTask task = buildTask(context, target); |
| 157 task.inputs = inputs; | 127 task.inputs = inputs; |
| 158 task.inputMemento = inputMemento; | 128 task.inputMemento = inputMemento; |
| 159 return task; | 129 return task; |
| 160 } | 130 } |
| 161 | 131 |
| 162 @override | 132 @override |
| 163 String toString() => name; | 133 String toString() => name; |
| 164 } | 134 } |
| OLD | NEW |