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 * A concrete implementation of a [ContributionPoint]. | 12 * A concrete implementation of a [ContributionPoint]. |
| 13 */ | 13 */ |
| 14 class ContributionPointImpl<V> extends ResultDescriptorImpl<V> implements | 14 class ContributionPointImpl<V> extends ResultDescriptorImpl<V> implements |
| 15 ContributionPoint<V> { | 15 ContributionPoint<V> { |
| 16 /** | 16 /** |
| 17 * The results that contribute to this result. | 17 * The results that contribute to this result. |
| 18 */ | 18 */ |
| 19 final List<ResultDescriptor<V>> contributors = <ResultDescriptor<V>>[]; | 19 final List<ResultDescriptor<V>> contributors = <ResultDescriptor<V>>[]; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Initialize a newly created contribution point to have the given [name]. | 22 * Initialize a newly created contribution point to have the given [name] and |
| 23 * [defaultValue]. | |
| 23 */ | 24 */ |
| 24 ContributionPointImpl(String name) : super(name); | 25 ContributionPointImpl(String name, V defaultValue) |
|
Paul Berry
2015/01/26 17:31:06
Since the "value" associated with a contribution p
Brian Wilkerson
2015/01/26 19:47:53
I think it doesn't. I'll make the change.
| |
| 26 : super(name, defaultValue); | |
| 25 | 27 |
| 26 /** | 28 /** |
| 27 * Record that the given analysis [result] contibutes to this result. | 29 * Record that the given analysis [result] contibutes to this result. |
| 28 */ | 30 */ |
| 29 void recordContributor(ResultDescriptor<V> result) { | 31 void recordContributor(ResultDescriptor<V> result) { |
| 30 contributors.add(result); | 32 contributors.add(result); |
| 31 } | 33 } |
| 32 } | 34 } |
| 33 | 35 |
| 34 /** | 36 /** |
| 35 * A concrete implementation of a [ResultDescriptor]. | 37 * A concrete implementation of a [ResultDescriptor]. |
| 36 */ | 38 */ |
| 37 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { | 39 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { |
| 38 /** | 40 /** |
| 39 * The name of the result, used for debugging. | 41 * The name of the result, used for debugging. |
| 40 */ | 42 */ |
| 41 final String name; | 43 final String name; |
| 42 | 44 |
| 43 /** | 45 /** |
| 44 * Initialize a newly created analysis result to have the given [name]. If a | 46 * Return the default value for results described by this descriptor. |
| 45 * contribution point is specified, then this result will contribute to it. | |
| 46 */ | 47 */ |
| 47 ResultDescriptorImpl(this.name, {ContributionPoint contributesTo}) { | 48 final V defaultValue; |
|
Paul Berry
2015/01/26 17:31:06
This design forces all results to share the same d
Brian Wilkerson
2015/01/26 19:47:53
Good point! It isn't a problem at the moment becau
| |
| 49 | |
| 50 /** | |
| 51 * Initialize a newly created analysis result to have the given [name] and | |
| 52 * [defaultValue]. If a contribution point is specified, then this result will | |
| 53 * contribute to it. | |
| 54 */ | |
| 55 ResultDescriptorImpl(this.name, this.defaultValue, | |
| 56 {ContributionPoint contributesTo}) { | |
| 48 if (contributesTo is ContributionPointImpl) { | 57 if (contributesTo is ContributionPointImpl) { |
| 49 contributesTo.recordContributor(this); | 58 contributesTo.recordContributor(this); |
| 50 } | 59 } |
| 51 } | 60 } |
| 52 | 61 |
| 53 @override | 62 @override |
| 54 TaskInput<V> inputFor(AnalysisTarget target) => | 63 TaskInput<V> inputFor(AnalysisTarget target) => |
| 55 new SimpleTaskInput<V>(target, this); | 64 new SimpleTaskInput<V>(target, this); |
| 56 | 65 |
| 57 @override | 66 @override |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, | 106 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, |
| 98 Map<String, dynamic> inputs) { | 107 Map<String, dynamic> inputs) { |
| 99 AnalysisTask task = buildTask(context, target); | 108 AnalysisTask task = buildTask(context, target); |
| 100 task.inputs = inputs; | 109 task.inputs = inputs; |
| 101 return task; | 110 return task; |
| 102 } | 111 } |
| 103 | 112 |
| 104 @override | 113 @override |
| 105 String toString() => name; | 114 String toString() => name; |
| 106 } | 115 } |
| OLD | NEW |