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

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

Issue 1847633002: Fix more strong mode errors in analyzer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix copied comment Created 4 years, 8 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.dart; 5 library analyzer.src.task.dart;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 27 matching lines...) Expand all
38 import 'package:analyzer/src/task/model.dart'; 38 import 'package:analyzer/src/task/model.dart';
39 import 'package:analyzer/src/task/strong/checker.dart'; 39 import 'package:analyzer/src/task/strong/checker.dart';
40 import 'package:analyzer/src/task/strong_mode.dart'; 40 import 'package:analyzer/src/task/strong_mode.dart';
41 import 'package:analyzer/task/dart.dart'; 41 import 'package:analyzer/task/dart.dart';
42 import 'package:analyzer/task/general.dart'; 42 import 'package:analyzer/task/general.dart';
43 import 'package:analyzer/task/model.dart'; 43 import 'package:analyzer/task/model.dart';
44 44
45 /** 45 /**
46 * The [ResultCachingPolicy] for ASTs. 46 * The [ResultCachingPolicy] for ASTs.
47 */ 47 */
48 const ResultCachingPolicy AST_CACHING_POLICY = 48 const ResultCachingPolicy<CompilationUnit> AST_CACHING_POLICY =
49 const SimpleResultCachingPolicy(16384, 16384); 49 const SimpleResultCachingPolicy(16384, 16384);
50 50
51 /** 51 /**
52 * The [ResultCachingPolicy] for [Element]s. 52 * The [ResultCachingPolicy] for [Element]s.
53 */ 53 */
54 const ResultCachingPolicy ELEMENT_CACHING_POLICY = 54 const ResultCachingPolicy ELEMENT_CACHING_POLICY =
55 const SimpleResultCachingPolicy(-1, -1); 55 const SimpleResultCachingPolicy(-1, -1);
56 56
57 /** 57 /**
58 * The [ResultCachingPolicy] for [TOKEN_STREAM]. 58 * The [ResultCachingPolicy] for [TOKEN_STREAM].
59 */ 59 */
60 const ResultCachingPolicy TOKEN_STREAM_CACHING_POLICY = 60 const ResultCachingPolicy<Token> TOKEN_STREAM_CACHING_POLICY =
61 const SimpleResultCachingPolicy(1, 1); 61 const SimpleResultCachingPolicy(1, 1);
62 62
63 /** 63 /**
64 * The errors produced while resolving a library directives. 64 * The errors produced while resolving a library directives.
65 * 65 *
66 * The list will be empty if there were no errors, but will not be `null`. 66 * The list will be empty if there were no errors, but will not be `null`.
67 * 67 *
68 * The result is only available for [Source]s representing a library. 68 * The result is only available for [Source]s representing a library.
69 */ 69 */
70 final ListResultDescriptor<AnalysisError> BUILD_DIRECTIVES_ERRORS = 70 final ListResultDescriptor<AnalysisError> BUILD_DIRECTIVES_ERRORS =
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 // did not cause it to be erased). In summary, task model dependencies 1979 // did not cause it to be erased). In summary, task model dependencies
1980 // on the import/export source closure ensure that this method will be 1980 // on the import/export source closure ensure that this method will be
1981 // re-run if anything reachable from this target has been invalidated, 1981 // re-run if anything reachable from this target has been invalidated,
1982 // and the invalidation code (invalidateLibraryCycles) will ensure that 1982 // and the invalidation code (invalidateLibraryCycles) will ensure that
1983 // element model results will be re-used here only if they are still valid. 1983 // element model results will be re-used here only if they are still valid.
1984 if (context.analysisOptions.strongMode) { 1984 if (context.analysisOptions.strongMode) {
1985 LibraryElement library = getRequiredInput(LIBRARY_ELEMENT_INPUT); 1985 LibraryElement library = getRequiredInput(LIBRARY_ELEMENT_INPUT);
1986 List<LibraryElement> component = library.libraryCycle; 1986 List<LibraryElement> component = library.libraryCycle;
1987 Set<LibraryElement> filter = new Set<LibraryElement>.from(component); 1987 Set<LibraryElement> filter = new Set<LibraryElement>.from(component);
1988 Set<CompilationUnitElement> deps = new Set<CompilationUnitElement>(); 1988 Set<CompilationUnitElement> deps = new Set<CompilationUnitElement>();
1989 void addLibrary(l) { 1989 void addLibrary(LibraryElement l) {
1990 if (!filter.contains(l)) { 1990 if (!filter.contains(l)) {
1991 deps.addAll(l.units); 1991 deps.addAll(l.units);
1992 } 1992 }
1993 } 1993 }
1994 for (LibraryElement l in component) { 1994 for (LibraryElement l in component) {
1995 l.importedLibraries.forEach(addLibrary); 1995 l.importedLibraries.forEach(addLibrary);
1996 l.exportedLibraries.forEach(addLibrary); 1996 l.exportedLibraries.forEach(addLibrary);
1997 } 1997 }
1998 // 1998 //
1999 // Record outputs. 1999 // Record outputs.
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 LibrarySpecificUnit unit = target; 2926 LibrarySpecificUnit unit = target;
2927 return <String, TaskInput>{ 2927 return <String, TaskInput>{
2928 UNIT_INPUT: RESOLVED_UNIT8.of(unit), 2928 UNIT_INPUT: RESOLVED_UNIT8.of(unit),
2929 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 2929 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
2930 // In strong mode, add additional dependencies to enforce inference 2930 // In strong mode, add additional dependencies to enforce inference
2931 // ordering. 2931 // ordering.
2932 2932
2933 // Require that field re-resolution be complete for all units in the 2933 // Require that field re-resolution be complete for all units in the
2934 // current library cycle. 2934 // current library cycle.
2935 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( 2935 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList(
2936 (CompilationUnitElementImpl unit) => CREATED_RESOLVED_UNIT8 2936 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT8.of(
2937 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))), 2937 new LibrarySpecificUnit(
2938 (unit as CompilationUnitElementImpl).librarySource,
2939 unit.source))),
2938 // Require that full inference be complete for all dependencies of the 2940 // Require that full inference be complete for all dependencies of the
2939 // current library cycle. 2941 // current library cycle.
2940 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( 2942 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList(
2941 (CompilationUnitElementImpl unit) => CREATED_RESOLVED_UNIT9 2943 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT9.of(
2942 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) 2944 new LibrarySpecificUnit(
2945 (unit as CompilationUnitElementImpl).librarySource,
2946 unit.source)))
2943 }; 2947 };
2944 } 2948 }
2945 2949
2946 /** 2950 /**
2947 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in 2951 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in
2948 * the given [context]. 2952 * the given [context].
2949 */ 2953 */
2950 static InferInstanceMembersInUnitTask createTask( 2954 static InferInstanceMembersInUnitTask createTask(
2951 AnalysisContext context, AnalysisTarget target) { 2955 AnalysisContext context, AnalysisTarget target) {
2952 return new InferInstanceMembersInUnitTask(context, target); 2956 return new InferInstanceMembersInUnitTask(context, target);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 .of(variable) 3190 .of(variable)
3187 .toListOf(INFERRED_STATIC_VARIABLE), 3191 .toListOf(INFERRED_STATIC_VARIABLE),
3188 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 3192 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
3189 UNIT_INPUT: RESOLVED_UNIT6.of(unit), 3193 UNIT_INPUT: RESOLVED_UNIT6.of(unit),
3190 // In strong mode, add additional dependencies to enforce inference 3194 // In strong mode, add additional dependencies to enforce inference
3191 // ordering. 3195 // ordering.
3192 3196
3193 // Require that full inference be complete for all dependencies of the 3197 // Require that full inference be complete for all dependencies of the
3194 // current library cycle. 3198 // current library cycle.
3195 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( 3199 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList(
3196 (CompilationUnitElementImpl unit) => CREATED_RESOLVED_UNIT9 3200 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT9.of(
3197 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) 3201 new LibrarySpecificUnit(
3202 (unit as CompilationUnitElementImpl).librarySource,
3203 unit.source)))
3198 }; 3204 };
3199 } 3205 }
3200 3206
3201 /** 3207 /**
3202 * Create a [InferStaticVariableTypeTask] based on the given [target] in the 3208 * Create a [InferStaticVariableTypeTask] based on the given [target] in the
3203 * given [context]. 3209 * given [context].
3204 */ 3210 */
3205 static InferStaticVariableTypeTask createTask( 3211 static InferStaticVariableTypeTask createTask(
3206 AnalysisContext context, AnalysisTarget target) { 3212 AnalysisContext context, AnalysisTarget target) {
3207 return new InferStaticVariableTypeTask(context, target); 3213 return new InferStaticVariableTypeTask(context, target);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 'fullyBuiltLibraryElements': READY_LIBRARY_ELEMENT5.of(unit.library), 3674 'fullyBuiltLibraryElements': READY_LIBRARY_ELEMENT5.of(unit.library),
3669 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), 3675 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library),
3670 UNIT_INPUT: RESOLVED_UNIT4.of(unit), 3676 UNIT_INPUT: RESOLVED_UNIT4.of(unit),
3671 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 3677 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
3672 // In strong mode, add additional dependencies to enforce inference 3678 // In strong mode, add additional dependencies to enforce inference
3673 // ordering. 3679 // ordering.
3674 3680
3675 // Require that full inference be complete for all dependencies of the 3681 // Require that full inference be complete for all dependencies of the
3676 // current library cycle. 3682 // current library cycle.
3677 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( 3683 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList(
3678 (CompilationUnitElementImpl unit) => CREATED_RESOLVED_UNIT9 3684 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT9.of(
3679 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) 3685 new LibrarySpecificUnit(
3686 (unit as CompilationUnitElementImpl).librarySource,
3687 unit.source)))
3680 }; 3688 };
3681 } 3689 }
3682 3690
3683 /** 3691 /**
3684 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target] 3692 * Create a [PartiallyResolveUnitReferencesTask] based on the given [target]
3685 * in the given [context]. 3693 * in the given [context].
3686 */ 3694 */
3687 static PartiallyResolveUnitReferencesTask createTask( 3695 static PartiallyResolveUnitReferencesTask createTask(
3688 AnalysisContext context, AnalysisTarget target) { 3696 AnalysisContext context, AnalysisTarget target) {
3689 return new PartiallyResolveUnitReferencesTask(context, target); 3697 return new PartiallyResolveUnitReferencesTask(context, target);
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
4391 return <String, TaskInput>{ 4399 return <String, TaskInput>{
4392 UNIT_INPUT: RESOLVED_UNIT7.of(unit), 4400 UNIT_INPUT: RESOLVED_UNIT7.of(unit),
4393 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), 4401 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library),
4394 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 4402 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
4395 // In strong mode, add additional dependencies to enforce inference 4403 // In strong mode, add additional dependencies to enforce inference
4396 // ordering. 4404 // ordering.
4397 4405
4398 // Require that static variable inference be complete for all units in 4406 // Require that static variable inference be complete for all units in
4399 // the current library cycle. 4407 // the current library cycle.
4400 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( 4408 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList(
4401 (CompilationUnitElementImpl unit) => CREATED_RESOLVED_UNIT7 4409 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT7.of(
4402 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))), 4410 new LibrarySpecificUnit(
4411 (unit as CompilationUnitElementImpl).librarySource,
4412 unit.source))),
4403 // Require that full inference be complete for all dependencies of the 4413 // Require that full inference be complete for all dependencies of the
4404 // current library cycle. 4414 // current library cycle.
4405 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList( 4415 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList(
4406 (CompilationUnitElementImpl unit) => CREATED_RESOLVED_UNIT9 4416 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT9.of(
4407 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) 4417 new LibrarySpecificUnit(
4418 (unit as CompilationUnitElementImpl).librarySource,
4419 unit.source)))
4408 }; 4420 };
4409 } 4421 }
4410 4422
4411 /** 4423 /**
4412 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in 4424 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in
4413 * the given [context]. 4425 * the given [context].
4414 */ 4426 */
4415 static ResolveInstanceFieldsInUnitTask createTask( 4427 static ResolveInstanceFieldsInUnitTask createTask(
4416 AnalysisContext context, AnalysisTarget target) { 4428 AnalysisContext context, AnalysisTarget target) {
4417 return new ResolveInstanceFieldsInUnitTask(context, target); 4429 return new ResolveInstanceFieldsInUnitTask(context, target);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
4714 return <String, TaskInput>{ 4726 return <String, TaskInput>{
4715 LIBRARY_INPUT: LIBRARY_ELEMENT7.of(unit.library), 4727 LIBRARY_INPUT: LIBRARY_ELEMENT7.of(unit.library),
4716 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 4728 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
4717 UNIT_INPUT: RESOLVED_UNIT9.of(unit), 4729 UNIT_INPUT: RESOLVED_UNIT9.of(unit),
4718 // In strong mode, add additional dependencies to enforce inference 4730 // In strong mode, add additional dependencies to enforce inference
4719 // ordering. 4731 // ordering.
4720 4732
4721 // Require that inference be complete for all units in the 4733 // Require that inference be complete for all units in the
4722 // current library cycle. 4734 // current library cycle.
4723 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( 4735 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList(
4724 (CompilationUnitElementImpl unit) => CREATED_RESOLVED_UNIT9 4736 (CompilationUnitElement unit) => CREATED_RESOLVED_UNIT9.of(
4725 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) 4737 new LibrarySpecificUnit(
4738 (unit as CompilationUnitElementImpl).librarySource,
4739 unit.source)))
4726 }; 4740 };
4727 } 4741 }
4728 4742
4729 /** 4743 /**
4730 * Create a [ResolveUnitTask] based on the given [target] in 4744 * Create a [ResolveUnitTask] based on the given [target] in
4731 * the given [context]. 4745 * the given [context].
4732 */ 4746 */
4733 static ResolveUnitTask createTask( 4747 static ResolveUnitTask createTask(
4734 AnalysisContext context, AnalysisTarget target) { 4748 AnalysisContext context, AnalysisTarget target) {
4735 return new ResolveUnitTask(context, target); 4749 return new ResolveUnitTask(context, target);
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
5354 5368
5355 @override 5369 @override
5356 bool moveNext() { 5370 bool moveNext() {
5357 if (_newSources.isEmpty) { 5371 if (_newSources.isEmpty) {
5358 return false; 5372 return false;
5359 } 5373 }
5360 currentTarget = _newSources.removeLast(); 5374 currentTarget = _newSources.removeLast();
5361 return true; 5375 return true;
5362 } 5376 }
5363 } 5377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698