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

Side by Side Diff: pkg/analyzer/lib/src/task/inputs.dart

Issue 2196363003: Make analyzer strong-mode clean (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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.inputs; 5 library analyzer.src.task.inputs;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/task/model.dart'; 9 import 'package:analyzer/task/model.dart';
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 /** 87 /**
88 * A mixin-ready implementation of [ListTaskInput]. 88 * A mixin-ready implementation of [ListTaskInput].
89 */ 89 */
90 abstract class ListTaskInputMixin<E> implements ListTaskInput<E> { 90 abstract class ListTaskInputMixin<E> implements ListTaskInput<E> {
91 @override 91 @override
92 ListTaskInput/*<V>*/ toFlattenListOf/*<V>*/( 92 ListTaskInput/*<V>*/ toFlattenListOf/*<V>*/(
93 ListResultDescriptor/*<V>*/ subListResult) { 93 ListResultDescriptor/*<V>*/ subListResult) {
94 return new ListToFlattenListTaskInput<E, dynamic/*=V*/ >( 94 return new ListToFlattenListTaskInput<E, dynamic/*=V*/ >(
95 this, subListResult.of as dynamic); 95 this,
96 (E element) =>
97 subListResult.of(element as AnalysisTarget) as TaskInput/*<V>*/);
96 } 98 }
97 99
98 ListTaskInput/*<V>*/ toList/*<V>*/(UnaryFunction<E, dynamic/*=V*/ > mapper) { 100 ListTaskInput/*<V>*/ toList/*<V>*/(UnaryFunction<E, dynamic/*=V*/ > mapper) {
99 return new ListToListTaskInput<E, dynamic/*=V*/ >(this, mapper); 101 return new ListToListTaskInput<E, dynamic/*=V*/ >(this, mapper);
100 } 102 }
101 103
102 ListTaskInput/*<V>*/ toListOf/*<V>*/(ResultDescriptor/*<V>*/ valueResult) { 104 ListTaskInput/*<V>*/ toListOf/*<V>*/(ResultDescriptor/*<V>*/ valueResult) {
103 return (this as ListTaskInput<AnalysisTarget>).toList(valueResult.of); 105 return (this as ListTaskInput<AnalysisTarget>).toList(valueResult.of);
104 } 106 }
105 107
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 currentBuilder.currentValueNotAvailable(); 365 currentBuilder.currentValueNotAvailable();
364 } 366 }
365 367
366 @override 368 @override
367 bool moveNext() { 369 bool moveNext() {
368 // Prepare base Map. 370 // Prepare base Map.
369 if (baseMap == null) { 371 if (baseMap == null) {
370 if (currentBuilder.moveNext()) { 372 if (currentBuilder.moveNext()) {
371 return true; 373 return true;
372 } 374 }
373 baseMap = currentBuilder.inputValue; 375 baseMap = currentBuilder.inputValue as dynamic/*=Map<K, List<V>>*/;
374 if (baseMap == null) { 376 if (baseMap == null) {
375 // No base map could be computed due to a circular dependency. Use an 377 // No base map could be computed due to a circular dependency. Use an
376 // empty map so that no further results will be computed. 378 // empty map so that no further results will be computed.
377 baseMap = {}; 379 baseMap = {};
378 } 380 }
379 keyIterator = baseMap.keys.iterator; 381 keyIterator = baseMap.keys.iterator;
380 // Done with this builder. 382 // Done with this builder.
381 currentBuilder = null; 383 currentBuilder = null;
382 } 384 }
383 // Prepare the next result value. 385 // Prepare the next result value.
384 if (currentBuilder != null) { 386 if (currentBuilder != null) {
385 if (currentBuilder.moveNext()) { 387 if (currentBuilder.moveNext()) {
386 return true; 388 return true;
387 } 389 }
388 // Add the result value for the current Map key/value. 390 // Add the result value for the current Map key/value.
389 E resultValue = currentBuilder.inputValue; 391 E resultValue = currentBuilder.inputValue as dynamic/*=E*/;
390 if (resultValue != null) { 392 if (resultValue != null) {
391 inputValue.add(resultValue); 393 inputValue.add(resultValue);
392 } 394 }
393 // Done with this builder. 395 // Done with this builder.
394 currentBuilder = null; 396 currentBuilder = null;
395 } 397 }
396 // Move to the next Map value. 398 // Move to the next Map value.
397 if (valueIterator != null && valueIterator.moveNext()) { 399 if (valueIterator != null && valueIterator.moveNext()) {
398 K key = keyIterator.current; 400 K key = keyIterator.current;
399 V value = valueIterator.current; 401 V value = valueIterator.current;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 ObjectToListTaskInput(this.baseInput, this.mapper); 439 ObjectToListTaskInput(this.baseInput, this.mapper);
438 440
439 @override 441 @override
440 TaskInputBuilder<List<E>> createBuilder() => 442 TaskInputBuilder<List<E>> createBuilder() =>
441 new ObjectToListTaskInputBuilder<E>(this); 443 new ObjectToListTaskInputBuilder<E>(this);
442 444
443 @override 445 @override
444 ListTaskInput/*<V>*/ toFlattenListOf/*<V>*/( 446 ListTaskInput/*<V>*/ toFlattenListOf/*<V>*/(
445 ListResultDescriptor/*<V>*/ subListResult) { 447 ListResultDescriptor/*<V>*/ subListResult) {
446 return new ListToFlattenListTaskInput<E, dynamic/*=V*/ >( 448 return new ListToFlattenListTaskInput<E, dynamic/*=V*/ >(
447 this, subListResult.of as dynamic); 449 this,
450 (E element) =>
451 subListResult.of(element as AnalysisTarget) as TaskInput/*<V>*/);
448 } 452 }
449 453
450 @override 454 @override
451 ListTaskInput/*<V>*/ toListOf/*<V>*/(ResultDescriptor/*<V>*/ valueResult) { 455 ListTaskInput/*<V>*/ toListOf/*<V>*/(ResultDescriptor/*<V>*/ valueResult) {
452 return new ListToListTaskInput<E, dynamic/*=V*/ >( 456 return new ListToListTaskInput<E, dynamic/*=V*/ >(
453 this, valueResult.of as dynamic); 457 this, (E element) => valueResult.of(element as AnalysisTarget));
454 } 458 }
455 459
456 @override 460 @override
457 MapTaskInput<AnalysisTarget, dynamic/*=V*/ > toMapOf/*<V>*/( 461 MapTaskInput<AnalysisTarget, dynamic/*=V*/ > toMapOf/*<V>*/(
458 ResultDescriptor/*<V>*/ valueResult) { 462 ResultDescriptor/*<V>*/ valueResult) {
459 return new ListToMapTaskInput<AnalysisTarget, dynamic/*=V*/ >( 463 return new ListToMapTaskInput<AnalysisTarget, dynamic/*=V*/ >(
460 this as dynamic, valueResult.of); 464 this as dynamic/*=TaskInput<List<AnalysisTarget>>*/, valueResult.of);
461 } 465 }
462 } 466 }
463 467
464 /** 468 /**
465 * A [TaskInputBuilder] used to build an input based on a [SimpleTaskInput]. 469 * A [TaskInputBuilder] used to build an input based on a [SimpleTaskInput].
466 */ 470 */
467 class ObjectToListTaskInputBuilder<E> implements TaskInputBuilder<List<E>> { 471 class ObjectToListTaskInputBuilder<E> implements TaskInputBuilder<List<E>> {
468 /** 472 /**
469 * The input being built. 473 * The input being built.
470 */ 474 */
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 693 }
690 _state = _AFTER; 694 _state = _AFTER;
691 return false; 695 return false;
692 } 696 }
693 } 697 }
694 } 698 }
695 699
696 abstract class TaskInputImpl<V> implements TaskInput<V> { 700 abstract class TaskInputImpl<V> implements TaskInput<V> {
697 @override 701 @override
698 ListTaskInput/*<E>*/ mappedToList/*<E>*/(List/*<E>*/ mapper(V value)) { 702 ListTaskInput/*<E>*/ mappedToList/*<E>*/(List/*<E>*/ mapper(V value)) {
699 return new ObjectToListTaskInput(this, mapper); 703 return new ObjectToListTaskInput(
704 this, (Object element) => mapper(element as V));
700 } 705 }
701 } 706 }
702 707
703 /** 708 /**
704 * A [TaskInputBuilder] used to build an input based on one or more other task 709 * A [TaskInputBuilder] used to build an input based on one or more other task
705 * inputs. The task inputs to be built are specified by a table mapping the name 710 * inputs. The task inputs to be built are specified by a table mapping the name
706 * of the input to the task used to access the input's value. 711 * of the input to the task used to access the input's value.
707 */ 712 */
708 class TopLevelTaskInputBuilder 713 class TopLevelTaskInputBuilder
709 implements TaskInputBuilder<Map<String, Object>> { 714 implements TaskInputBuilder<Map<String, Object>> {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 // We have already computed all of the results, so just return false. 965 // We have already computed all of the results, so just return false.
961 return false; 966 return false;
962 } 967 }
963 } 968 }
964 if (currentBuilder.moveNext()) { 969 if (currentBuilder.moveNext()) {
965 return true; 970 return true;
966 } 971 }
967 if (_resultValue == null) { 972 if (_resultValue == null) {
968 // We have finished computing the list of values from which the results 973 // We have finished computing the list of values from which the results
969 // will be derived. 974 // will be derived.
970 _baseList = currentBuilder.inputValue; 975 _baseList = currentBuilder.inputValue as dynamic/*=List<B>*/;
971 if (_baseList == null) { 976 if (_baseList == null) {
972 // No base list could be computed due to a circular dependency. Use an 977 // No base list could be computed due to a circular dependency. Use an
973 // empty list so that no further results will be computed. 978 // empty list so that no further results will be computed.
974 _baseList = []; 979 _baseList = [];
975 } 980 }
976 _baseListIndex = 0; 981 _baseListIndex = 0;
977 _initResultValue(); 982 _initResultValue();
978 } else { 983 } else {
979 // We have finished computing one of the elements in the result list. 984 // We have finished computing one of the elements in the result list.
980 if (currentBuilder.inputValue != null) { 985 if (currentBuilder.inputValue != null) {
981 _addResultElement(_baseListElement, currentBuilder.inputValue); 986 _addResultElement(
987 _baseListElement, currentBuilder.inputValue as dynamic/*=E*/);
982 } 988 }
983 _baseListIndex++; 989 _baseListIndex++;
984 } 990 }
985 if (_baseListIndex >= _baseList.length) { 991 if (_baseListIndex >= _baseList.length) {
986 currentBuilder = null; 992 currentBuilder = null;
987 return false; 993 return false;
988 } 994 }
989 _baseListElement = _baseList[_baseListIndex]; 995 _baseListElement = _baseList[_baseListIndex];
990 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder(); 996 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder();
991 return currentBuilder.moveNext(); 997 return currentBuilder.moveNext();
992 } 998 }
993 999
994 void _addResultElement(B baseElement, E resultElement); 1000 void _addResultElement(B baseElement, E resultElement);
995 void _initResultValue(); 1001 void _initResultValue();
996 } 1002 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/generated/sdk_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698