Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: pkg/analyzer/lib/src/task/inputs.dart

Issue 1370323003: Fix computation of errors to not run extra tasks (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Added tests Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/inputs_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/inputs.dart
diff --git a/pkg/analyzer/lib/src/task/inputs.dart b/pkg/analyzer/lib/src/task/inputs.dart
index c93a1273dc431b4e9961fb1b8c9ccfa8b3224afc..3de18e870bf0f015619852d127e5d5a8f69b30d9 100644
--- a/pkg/analyzer/lib/src/task/inputs.dart
+++ b/pkg/analyzer/lib/src/task/inputs.dart
@@ -24,6 +24,52 @@ typedef R Mapper<P, R>(P value);
* An input to an [AnalysisTask] that is computed by accessing a single result
* defined on a single target.
*/
+class ConstantTaskInput<V> extends TaskInputImpl<V> {
+ final V value;
+
+ ConstantTaskInput(this.value);
+
+ @override
+ TaskInputBuilder<V> createBuilder() {
+ return new ConstantTaskInputBuilder<V>(this);
+ }
+}
+
+/**
+ * A [TaskInputBuilder] used to build an input based on a [ConstantTaskInput].
+ */
+class ConstantTaskInputBuilder<V> implements TaskInputBuilder<V> {
+ final ConstantTaskInput input;
+
+ ConstantTaskInputBuilder(this.input);
+
+ @override
+ ResultDescriptor get currentResult => null;
+
+ @override
+ AnalysisTarget get currentTarget => null;
+
+ @override
+ void set currentValue(Object value) {
+ throw new StateError('Only supported after moveNext() returns true');
+ }
+
+ @override
+ V get inputValue => input.value;
+
+ @override
+ void currentValueNotAvailable() {
+ throw new StateError('Only supported after moveNext() returns true');
+ }
+
+ @override
+ bool moveNext() => false;
+}
+
+/**
+ * An input to an [AnalysisTask] that is computed by accessing a single result
+ * defined on a single target.
+ */
class ListTaskInputImpl<E> extends SimpleTaskInput<List<E>>
with ListTaskInputMixin<E>
implements ListTaskInput<E> {
@@ -675,11 +721,18 @@ class TopLevelTaskInputBuilder
return false;
}
currentBuilder = inputDescriptors[_currentName].createBuilder();
- // NOTE: This assumes that every builder will require at least one result
- // value to be created. If that assumption is every broken, this method will
- // need to be changed to advance until we find a builder that does require
- // a result to be computed (or run out of builders).
- return currentBuilder.moveNext();
+ while (!currentBuilder.moveNext()) {
+ if (currentBuilder.inputValue != null) {
+ inputs[_currentName] = currentBuilder.inputValue;
+ }
+ nameIndex++;
+ if (nameIndex >= inputNames.length) {
+ // There is no next value, so we're done.
+ return false;
+ }
+ currentBuilder = inputDescriptors[_currentName].createBuilder();
+ }
+ return true;
}
}
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/inputs_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698