| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Record that the given analysis [result] contibutes to this result. | 27 * Record that the given analysis [result] contibutes to this result. |
| 28 */ | 28 */ |
| 29 void recordContributor(ResultDescriptor<V> result) { | 29 void recordContributor(ResultDescriptor<V> result) { |
| 30 contributors.add(result); | 30 contributors.add(result); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * A concrete implementation of a [ListResultDescriptor]. |
| 36 */ |
| 37 class ListResultDescriptorImpl<E> extends ResultDescriptorImpl<List<E>> |
| 38 implements ListResultDescriptor<E> { |
| 39 /** |
| 40 * Initialize a newly created analysis result to have the given [name] and |
| 41 * [defaultValue]. If a composite result is specified, then this result will |
| 42 * contribute to it. |
| 43 */ |
| 44 ListResultDescriptorImpl(String name, List<E> defaultValue, |
| 45 {CompositeResultDescriptor contributesTo}) |
| 46 : super(name, defaultValue, contributesTo: contributesTo); |
| 47 |
| 48 @override |
| 49 ListTaskInput<E> of(AnalysisTarget target) => |
| 50 new ListTaskInputImpl<E>(target, this); |
| 51 } |
| 52 |
| 53 /** |
| 35 * A concrete implementation of a [ResultDescriptor]. | 54 * A concrete implementation of a [ResultDescriptor]. |
| 36 */ | 55 */ |
| 37 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { | 56 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { |
| 38 /** | 57 /** |
| 39 * The name of the result, used for debugging. | 58 * The name of the result, used for debugging. |
| 40 */ | 59 */ |
| 41 final String name; | 60 final String name; |
| 42 | 61 |
| 43 /** | 62 /** |
| 44 * Return the default value for results described by this descriptor. | 63 * Return the default value for results described by this descriptor. |
| 45 */ | 64 */ |
| 46 final V defaultValue; | 65 final V defaultValue; |
| 47 | 66 |
| 48 /** | 67 /** |
| 49 * Initialize a newly created analysis result to have the given [name] and | 68 * Initialize a newly created analysis result to have the given [name] and |
| 50 * [defaultValue]. If a composite result is specified, then this result will | 69 * [defaultValue]. If a composite result is specified, then this result will |
| 51 * contribute to it. | 70 * contribute to it. |
| 52 */ | 71 */ |
| 53 ResultDescriptorImpl(this.name, this.defaultValue, | 72 ResultDescriptorImpl(this.name, this.defaultValue, |
| 54 {CompositeResultDescriptor contributesTo}) { | 73 {CompositeResultDescriptor contributesTo}) { |
| 55 if (contributesTo is CompositeResultDescriptorImpl) { | 74 if (contributesTo is CompositeResultDescriptorImpl) { |
| 56 contributesTo.recordContributor(this); | 75 contributesTo.recordContributor(this); |
| 57 } | 76 } |
| 58 } | 77 } |
| 59 | 78 |
| 60 @override | 79 @override |
| 61 TaskInput<V> inputFor(AnalysisTarget target) => | 80 TaskInput<V> of(AnalysisTarget target) => |
| 62 new SimpleTaskInput<V>(target, this); | 81 new SimpleTaskInput<V>(target, this); |
| 63 | 82 |
| 64 @override | 83 @override |
| 65 String toString() => name; | 84 String toString() => name; |
| 66 } | 85 } |
| 67 | 86 |
| 68 /** | 87 /** |
| 69 * A concrete implementation of a [TaskDescriptor]. | 88 * A concrete implementation of a [TaskDescriptor]. |
| 70 */ | 89 */ |
| 71 class TaskDescriptorImpl implements TaskDescriptor { | 90 class TaskDescriptorImpl implements TaskDescriptor { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, | 123 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, |
| 105 Map<String, dynamic> inputs) { | 124 Map<String, dynamic> inputs) { |
| 106 AnalysisTask task = buildTask(context, target); | 125 AnalysisTask task = buildTask(context, target); |
| 107 task.inputs = inputs; | 126 task.inputs = inputs; |
| 108 return task; | 127 return task; |
| 109 } | 128 } |
| 110 | 129 |
| 111 @override | 130 @override |
| 112 String toString() => name; | 131 String toString() => name; |
| 113 } | 132 } |
| OLD | NEW |