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.dart; | 5 library analyzer.src.task.dart; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
9 | 9 |
10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 cachingPolicy: ELEMENT_CACHING_POLICY); | 398 cachingPolicy: ELEMENT_CACHING_POLICY); |
399 | 399 |
400 /** | 400 /** |
401 * The [UsedLocalElements] of a [LibrarySpecificUnit]. | 401 * The [UsedLocalElements] of a [LibrarySpecificUnit]. |
402 */ | 402 */ |
403 final ResultDescriptor<UsedLocalElements> USED_LOCAL_ELEMENTS = | 403 final ResultDescriptor<UsedLocalElements> USED_LOCAL_ELEMENTS = |
404 new ResultDescriptor<UsedLocalElements>('USED_LOCAL_ELEMENTS', null, | 404 new ResultDescriptor<UsedLocalElements>('USED_LOCAL_ELEMENTS', null, |
405 cachingPolicy: ELEMENT_CACHING_POLICY); | 405 cachingPolicy: ELEMENT_CACHING_POLICY); |
406 | 406 |
407 /** | 407 /** |
| 408 * The errors produced while resolving variable references in a compilation unit
. |
| 409 * |
| 410 * The list will be empty if there were no errors, but will not be `null`. |
| 411 * |
| 412 * The result is only available for [LibrarySpecificUnit]s. |
| 413 */ |
| 414 final ListResultDescriptor<AnalysisError> VARIABLE_REFERENCE_ERRORS = |
| 415 new ListResultDescriptor<AnalysisError>( |
| 416 'VARIABLE_REFERENCE_ERRORS', AnalysisError.NO_ERRORS); |
| 417 |
| 418 /** |
408 * The errors produced while verifying a compilation unit. | 419 * The errors produced while verifying a compilation unit. |
409 * | 420 * |
410 * The list will be empty if there were no errors, but will not be `null`. | 421 * The list will be empty if there were no errors, but will not be `null`. |
411 * | 422 * |
412 * The result is only available for [LibrarySpecificUnit]s. | 423 * The result is only available for [LibrarySpecificUnit]s. |
413 */ | 424 */ |
414 final ListResultDescriptor<AnalysisError> VERIFY_ERRORS = | 425 final ListResultDescriptor<AnalysisError> VERIFY_ERRORS = |
415 new ListResultDescriptor<AnalysisError>( | 426 new ListResultDescriptor<AnalysisError>( |
416 'VERIFY_ERRORS', AnalysisError.NO_ERRORS); | 427 'VERIFY_ERRORS', AnalysisError.NO_ERRORS); |
417 | 428 |
418 /** | 429 /** |
419 * Remove [CompileTimeErrorCode.DUPLICATE_DEFINITION] errors from the given | 430 * Return a list of errors containing the errors from the given [errors] list |
420 * [errors] list. | 431 * but with duplications removed. |
421 */ | 432 */ |
422 void removeDuplicateDefinitionErrors(List<AnalysisError> errors) { | 433 List<AnalysisError> removeDuplicateErrors(List<AnalysisError> errors) { |
423 if (errors.isNotEmpty) { | 434 if (errors.isEmpty) { |
424 errors.removeWhere((error) { | 435 return errors; |
425 ErrorCode errorCode = error.errorCode; | |
426 return errorCode == CompileTimeErrorCode.DUPLICATE_DEFINITION || | |
427 errorCode == CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME || | |
428 errorCode == CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME || | |
429 errorCode == | |
430 CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER; | |
431 }); | |
432 } | 436 } |
| 437 return errors.toSet().toList(); |
433 } | 438 } |
434 | 439 |
435 /** | 440 /** |
436 * A task that builds implicit constructors for a [ClassElement], or keeps | 441 * A task that builds implicit constructors for a [ClassElement], or keeps |
437 * the existing explicit constructors if the class has them. | 442 * the existing explicit constructors if the class has them. |
438 */ | 443 */ |
439 class BuildClassConstructorsTask extends SourceBasedAnalysisTask { | 444 class BuildClassConstructorsTask extends SourceBasedAnalysisTask { |
440 /** | 445 /** |
441 * The name of the [CONSTRUCTORS] input for the superclass. | 446 * The name of the [CONSTRUCTORS] input for the superclass. |
442 */ | 447 */ |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 // Resolve FunctionTypeAlias declarations. | 1177 // Resolve FunctionTypeAlias declarations. |
1173 // | 1178 // |
1174 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( | 1179 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( |
1175 libraryElement, source, typeProvider, errorListener); | 1180 libraryElement, source, typeProvider, errorListener); |
1176 for (CompilationUnitMember member in unit.declarations) { | 1181 for (CompilationUnitMember member in unit.declarations) { |
1177 if (member is FunctionTypeAlias) { | 1182 if (member is FunctionTypeAlias) { |
1178 member.accept(visitor); | 1183 member.accept(visitor); |
1179 } | 1184 } |
1180 } | 1185 } |
1181 // | 1186 // |
1182 // Prepare errors. | |
1183 // | |
1184 List<AnalysisError> errors = errorListener.errors; | |
1185 removeDuplicateDefinitionErrors(errors); | |
1186 // | |
1187 // Record outputs. | 1187 // Record outputs. |
1188 // | 1188 // |
1189 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = errors; | 1189 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = |
| 1190 removeDuplicateErrors(errorListener.errors); |
1190 outputs[RESOLVED_UNIT3] = unit; | 1191 outputs[RESOLVED_UNIT3] = unit; |
1191 } | 1192 } |
1192 | 1193 |
1193 /** | 1194 /** |
1194 * Return a map from the names of the inputs of this kind of task to the task | 1195 * Return a map from the names of the inputs of this kind of task to the task |
1195 * input descriptors describing those inputs for a task with the | 1196 * input descriptors describing those inputs for a task with the |
1196 * given [target]. | 1197 * given [target]. |
1197 */ | 1198 */ |
1198 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 1199 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { |
1199 return <String, TaskInput>{ | 1200 return <String, TaskInput>{ |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 static const String RESOLVE_REFERENCES_ERRORS_INPUT = | 2545 static const String RESOLVE_REFERENCES_ERRORS_INPUT = |
2545 'RESOLVE_REFERENCES_ERRORS'; | 2546 'RESOLVE_REFERENCES_ERRORS'; |
2546 | 2547 |
2547 /** | 2548 /** |
2548 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. | 2549 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. |
2549 */ | 2550 */ |
2550 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = | 2551 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = |
2551 'RESOLVE_TYPE_NAMES_ERRORS'; | 2552 'RESOLVE_TYPE_NAMES_ERRORS'; |
2552 | 2553 |
2553 /** | 2554 /** |
| 2555 * The name of the [VARIABLE_REFERENCE_ERRORS] input. |
| 2556 */ |
| 2557 static const String VARIABLE_REFERENCE_ERRORS_INPUT = |
| 2558 'VARIABLE_REFERENCE_ERRORS'; |
| 2559 |
| 2560 /** |
2554 * The name of the [VERIFY_ERRORS] input. | 2561 * The name of the [VERIFY_ERRORS] input. |
2555 */ | 2562 */ |
2556 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; | 2563 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; |
2557 | 2564 |
2558 /** | 2565 /** |
2559 * The name of the [CONSTRUCTORS_ERRORS] input. | 2566 * The name of the [CONSTRUCTORS_ERRORS] input. |
2560 */ | 2567 */ |
2561 static const String CONSTRUCTORS_ERRORS_INPUT = 'CONSTRUCTORS_ERRORS'; | 2568 static const String CONSTRUCTORS_ERRORS_INPUT = 'CONSTRUCTORS_ERRORS'; |
2562 | 2569 |
2563 /** | 2570 /** |
(...skipping 13 matching lines...) Expand all Loading... |
2577 void internalPerform() { | 2584 void internalPerform() { |
2578 // | 2585 // |
2579 // Prepare inputs. | 2586 // Prepare inputs. |
2580 // | 2587 // |
2581 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; | 2588 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; |
2582 errorLists.add(getRequiredInput(BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT)); | 2589 errorLists.add(getRequiredInput(BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT)); |
2583 errorLists.addAll(getRequiredInput(CONSTRUCTORS_ERRORS_INPUT)); | 2590 errorLists.addAll(getRequiredInput(CONSTRUCTORS_ERRORS_INPUT)); |
2584 errorLists.add(getRequiredInput(HINTS_INPUT)); | 2591 errorLists.add(getRequiredInput(HINTS_INPUT)); |
2585 errorLists.add(getRequiredInput(RESOLVE_REFERENCES_ERRORS_INPUT)); | 2592 errorLists.add(getRequiredInput(RESOLVE_REFERENCES_ERRORS_INPUT)); |
2586 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); | 2593 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); |
| 2594 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); |
2587 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); | 2595 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); |
2588 // | 2596 // |
2589 // Record outputs. | 2597 // Record outputs. |
2590 // | 2598 // |
2591 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); | 2599 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); |
2592 } | 2600 } |
2593 | 2601 |
2594 /** | 2602 /** |
2595 * Return a map from the names of the inputs of this kind of task to the task | 2603 * Return a map from the names of the inputs of this kind of task to the task |
2596 * input descriptors describing those inputs for a task with the | 2604 * input descriptors describing those inputs for a task with the |
2597 * given [unit]. | 2605 * given [unit]. |
2598 */ | 2606 */ |
2599 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit unit) { | 2607 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit unit) { |
2600 return <String, TaskInput>{ | 2608 return <String, TaskInput>{ |
2601 BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT: | 2609 BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT: |
2602 BUILD_FUNCTION_TYPE_ALIASES_ERRORS.of(unit), | 2610 BUILD_FUNCTION_TYPE_ALIASES_ERRORS.of(unit), |
2603 CONSTRUCTORS_ERRORS_INPUT: COMPILATION_UNIT_ELEMENT | 2611 CONSTRUCTORS_ERRORS_INPUT: COMPILATION_UNIT_ELEMENT |
2604 .of(unit) | 2612 .of(unit) |
2605 .mappedToList((CompilationUnitElement element) => element.types) | 2613 .mappedToList((CompilationUnitElement element) => element.types) |
2606 .toListOf(CONSTRUCTORS_ERRORS), | 2614 .toListOf(CONSTRUCTORS_ERRORS), |
2607 HINTS_INPUT: HINTS.of(unit), | 2615 HINTS_INPUT: HINTS.of(unit), |
2608 RESOLVE_REFERENCES_ERRORS_INPUT: RESOLVE_REFERENCES_ERRORS.of(unit), | 2616 RESOLVE_REFERENCES_ERRORS_INPUT: RESOLVE_REFERENCES_ERRORS.of(unit), |
2609 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), | 2617 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), |
| 2618 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), |
2610 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) | 2619 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) |
2611 }; | 2620 }; |
2612 } | 2621 } |
2613 | 2622 |
2614 /** | 2623 /** |
2615 * Create a [LibraryUnitErrorsTask] based on the given [target] in the given | 2624 * Create a [LibraryUnitErrorsTask] based on the given [target] in the given |
2616 * [context]. | 2625 * [context]. |
2617 */ | 2626 */ |
2618 static LibraryUnitErrorsTask createTask( | 2627 static LibraryUnitErrorsTask createTask( |
2619 AnalysisContext context, AnalysisTarget target) { | 2628 AnalysisContext context, AnalysisTarget target) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 sourceKind = SourceKind.PART; | 2737 sourceKind = SourceKind.PART; |
2729 } | 2738 } |
2730 // | 2739 // |
2731 // Record outputs. | 2740 // Record outputs. |
2732 // | 2741 // |
2733 List<Source> explicitlyImportedSources = | 2742 List<Source> explicitlyImportedSources = |
2734 explicitlyImportedSourceSet.toList(); | 2743 explicitlyImportedSourceSet.toList(); |
2735 List<Source> exportedSources = exportedSourceSet.toList(); | 2744 List<Source> exportedSources = exportedSourceSet.toList(); |
2736 List<Source> importedSources = importedSourceSet.toList(); | 2745 List<Source> importedSources = importedSourceSet.toList(); |
2737 List<Source> includedSources = includedSourceSet.toList(); | 2746 List<Source> includedSources = includedSourceSet.toList(); |
2738 List<AnalysisError> parseErrors = errorListener.errors; | 2747 List<AnalysisError> parseErrors = |
| 2748 removeDuplicateErrors(errorListener.errors); |
2739 List<Source> unitSources = <Source>[source]..addAll(includedSourceSet); | 2749 List<Source> unitSources = <Source>[source]..addAll(includedSourceSet); |
2740 outputs[EXPLICITLY_IMPORTED_LIBRARIES] = explicitlyImportedSources; | 2750 outputs[EXPLICITLY_IMPORTED_LIBRARIES] = explicitlyImportedSources; |
2741 outputs[EXPORTED_LIBRARIES] = exportedSources; | 2751 outputs[EXPORTED_LIBRARIES] = exportedSources; |
2742 outputs[IMPORTED_LIBRARIES] = importedSources; | 2752 outputs[IMPORTED_LIBRARIES] = importedSources; |
2743 outputs[INCLUDED_PARTS] = includedSources; | 2753 outputs[INCLUDED_PARTS] = includedSources; |
2744 outputs[PARSE_ERRORS] = parseErrors; | 2754 outputs[PARSE_ERRORS] = parseErrors; |
2745 outputs[PARSED_UNIT] = unit; | 2755 outputs[PARSED_UNIT] = unit; |
2746 outputs[SOURCE_KIND] = sourceKind; | 2756 outputs[SOURCE_KIND] = sourceKind; |
2747 outputs[UNITS] = unitSources; | 2757 outputs[UNITS] = unitSources; |
2748 } | 2758 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 // Resolve references. | 2962 // Resolve references. |
2953 // | 2963 // |
2954 InheritanceManager inheritanceManager = | 2964 InheritanceManager inheritanceManager = |
2955 new InheritanceManager(libraryElement); | 2965 new InheritanceManager(libraryElement); |
2956 AstVisitor visitor = new ResolverVisitor.con2(libraryElement, | 2966 AstVisitor visitor = new ResolverVisitor.con2(libraryElement, |
2957 unitElement.source, typeProvider, inheritanceManager, errorListener); | 2967 unitElement.source, typeProvider, inheritanceManager, errorListener); |
2958 unit.accept(visitor); | 2968 unit.accept(visitor); |
2959 // | 2969 // |
2960 // Record outputs. | 2970 // Record outputs. |
2961 // | 2971 // |
2962 outputs[RESOLVE_REFERENCES_ERRORS] = errorListener.errors; | 2972 outputs[RESOLVE_REFERENCES_ERRORS] = |
| 2973 removeDuplicateErrors(errorListener.errors); |
2963 outputs[RESOLVED_UNIT6] = unit; | 2974 outputs[RESOLVED_UNIT6] = unit; |
2964 } | 2975 } |
2965 | 2976 |
2966 /** | 2977 /** |
2967 * Return a map from the names of the inputs of this kind of task to the task | 2978 * Return a map from the names of the inputs of this kind of task to the task |
2968 * input descriptors describing those inputs for a task with the | 2979 * input descriptors describing those inputs for a task with the |
2969 * given [target]. | 2980 * given [target]. |
2970 */ | 2981 */ |
2971 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 2982 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { |
2972 return <String, TaskInput>{ | 2983 return <String, TaskInput>{ |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3042 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
3032 CompilationUnitElement unitElement = unit.element; | 3043 CompilationUnitElement unitElement = unit.element; |
3033 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 3044 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
3034 // | 3045 // |
3035 // Resolve TypeName nodes. | 3046 // Resolve TypeName nodes. |
3036 // | 3047 // |
3037 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( | 3048 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( |
3038 library, unitElement.source, typeProvider, errorListener); | 3049 library, unitElement.source, typeProvider, errorListener); |
3039 unit.accept(visitor); | 3050 unit.accept(visitor); |
3040 // | 3051 // |
3041 // Prepare errors. | |
3042 // | |
3043 List<AnalysisError> errors = errorListener.errors; | |
3044 removeDuplicateDefinitionErrors(errors); | |
3045 // | |
3046 // Record outputs. | 3052 // Record outputs. |
3047 // | 3053 // |
3048 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errors; | 3054 outputs[RESOLVE_TYPE_NAMES_ERRORS] = |
| 3055 removeDuplicateErrors(errorListener.errors); |
3049 outputs[RESOLVED_UNIT4] = unit; | 3056 outputs[RESOLVED_UNIT4] = unit; |
3050 } | 3057 } |
3051 | 3058 |
3052 /** | 3059 /** |
3053 * Return a map from the names of the inputs of this kind of task to the task | 3060 * Return a map from the names of the inputs of this kind of task to the task |
3054 * input descriptors describing those inputs for a task with the | 3061 * input descriptors describing those inputs for a task with the |
3055 * given [target]. | 3062 * given [target]. |
3056 */ | 3063 */ |
3057 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 3064 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { |
3058 return <String, TaskInput>{ | 3065 return <String, TaskInput>{ |
(...skipping 30 matching lines...) Expand all Loading... |
3089 /** | 3096 /** |
3090 * The name of the [TYPE_PROVIDER] input. | 3097 * The name of the [TYPE_PROVIDER] input. |
3091 */ | 3098 */ |
3092 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 3099 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
3093 | 3100 |
3094 /** | 3101 /** |
3095 * The task descriptor describing this kind of task. | 3102 * The task descriptor describing this kind of task. |
3096 */ | 3103 */ |
3097 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 3104 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
3098 'ResolveVariableReferencesTask', createTask, buildInputs, | 3105 'ResolveVariableReferencesTask', createTask, buildInputs, |
3099 <ResultDescriptor>[RESOLVED_UNIT5]); | 3106 <ResultDescriptor>[RESOLVED_UNIT5, VARIABLE_REFERENCE_ERRORS]); |
3100 | 3107 |
3101 ResolveVariableReferencesTask( | 3108 ResolveVariableReferencesTask( |
3102 InternalAnalysisContext context, AnalysisTarget target) | 3109 InternalAnalysisContext context, AnalysisTarget target) |
3103 : super(context, target); | 3110 : super(context, target); |
3104 | 3111 |
3105 @override | 3112 @override |
3106 TaskDescriptor get descriptor => DESCRIPTOR; | 3113 TaskDescriptor get descriptor => DESCRIPTOR; |
3107 | 3114 |
3108 @override | 3115 @override |
3109 void internalPerform() { | 3116 void internalPerform() { |
3110 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3117 RecordingErrorListener errorListener = new RecordingErrorListener(); |
3111 // | 3118 // |
3112 // Prepare inputs. | 3119 // Prepare inputs. |
3113 // | 3120 // |
3114 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); | 3121 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); |
3115 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3122 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
3116 CompilationUnitElement unitElement = unit.element; | 3123 CompilationUnitElement unitElement = unit.element; |
3117 // | 3124 // |
3118 // Resolve local variables. | 3125 // Resolve local variables. |
3119 // | 3126 // |
3120 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 3127 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
3121 Scope nameScope = new LibraryScope(libraryElement, errorListener); | 3128 Scope nameScope = new LibraryScope(libraryElement, errorListener); |
3122 AstVisitor visitor = new VariableResolverVisitor.con2(libraryElement, | 3129 AstVisitor visitor = new VariableResolverVisitor.con2(libraryElement, |
3123 unitElement.source, typeProvider, nameScope, errorListener); | 3130 unitElement.source, typeProvider, nameScope, errorListener); |
3124 unit.accept(visitor); | 3131 unit.accept(visitor); |
3125 // | 3132 // |
3126 // Record outputs. | 3133 // Record outputs. |
3127 // | 3134 // |
3128 outputs[RESOLVED_UNIT5] = unit; | 3135 outputs[RESOLVED_UNIT5] = unit; |
| 3136 outputs[VARIABLE_REFERENCE_ERRORS] = |
| 3137 removeDuplicateErrors(errorListener.errors); |
3129 } | 3138 } |
3130 | 3139 |
3131 /** | 3140 /** |
3132 * Return a map from the names of the inputs of this kind of task to the task | 3141 * Return a map from the names of the inputs of this kind of task to the task |
3133 * input descriptors describing those inputs for a task with the | 3142 * input descriptors describing those inputs for a task with the |
3134 * given [target]. | 3143 * given [target]. |
3135 */ | 3144 */ |
3136 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 3145 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { |
3137 return <String, TaskInput>{ | 3146 return <String, TaskInput>{ |
3138 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE | 3147 'fullyBuiltLibraryElements': IMPORT_EXPORT_SOURCE_CLOSURE |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3188 Source source = getRequiredSource(); | 3197 Source source = getRequiredSource(); |
3189 String content = getRequiredInput(CONTENT_INPUT_NAME); | 3198 String content = getRequiredInput(CONTENT_INPUT_NAME); |
3190 | 3199 |
3191 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3200 RecordingErrorListener errorListener = new RecordingErrorListener(); |
3192 Scanner scanner = | 3201 Scanner scanner = |
3193 new Scanner(source, new CharSequenceReader(content), errorListener); | 3202 new Scanner(source, new CharSequenceReader(content), errorListener); |
3194 scanner.preserveComments = context.analysisOptions.preserveComments; | 3203 scanner.preserveComments = context.analysisOptions.preserveComments; |
3195 scanner.enableNullAwareOperators = | 3204 scanner.enableNullAwareOperators = |
3196 context.analysisOptions.enableNullAwareOperators; | 3205 context.analysisOptions.enableNullAwareOperators; |
3197 | 3206 |
3198 Token tokenStream = scanner.tokenize(); | 3207 outputs[TOKEN_STREAM] = scanner.tokenize(); |
3199 LineInfo lineInfo = new LineInfo(scanner.lineStarts); | 3208 outputs[LINE_INFO] = new LineInfo(scanner.lineStarts); |
3200 List<AnalysisError> errors = errorListener.errors; | 3209 outputs[SCAN_ERRORS] = removeDuplicateErrors(errorListener.errors); |
3201 outputs[TOKEN_STREAM] = tokenStream; | |
3202 outputs[LINE_INFO] = lineInfo; | |
3203 outputs[SCAN_ERRORS] = errors; | |
3204 } | 3210 } |
3205 | 3211 |
3206 /** | 3212 /** |
3207 * Return a map from the names of the inputs of this kind of task to the task | 3213 * Return a map from the names of the inputs of this kind of task to the task |
3208 * input descriptors describing those inputs for a task with the given | 3214 * input descriptors describing those inputs for a task with the given |
3209 * [source]. | 3215 * [source]. |
3210 */ | 3216 */ |
3211 static Map<String, TaskInput> buildInputs(Source source) { | 3217 static Map<String, TaskInput> buildInputs(Source source) { |
3212 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)}; | 3218 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)}; |
3213 } | 3219 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 unit.accept(errorVerifier); | 3282 unit.accept(errorVerifier); |
3277 // | 3283 // |
3278 // Use the ConstantVerifier to compute errors. | 3284 // Use the ConstantVerifier to compute errors. |
3279 // | 3285 // |
3280 ConstantVerifier constantVerifier = new ConstantVerifier( | 3286 ConstantVerifier constantVerifier = new ConstantVerifier( |
3281 errorReporter, libraryElement, typeProvider, context.declaredVariables); | 3287 errorReporter, libraryElement, typeProvider, context.declaredVariables); |
3282 unit.accept(constantVerifier); | 3288 unit.accept(constantVerifier); |
3283 // | 3289 // |
3284 // Record outputs. | 3290 // Record outputs. |
3285 // | 3291 // |
3286 outputs[VERIFY_ERRORS] = errorListener.errors; | 3292 outputs[VERIFY_ERRORS] = removeDuplicateErrors(errorListener.errors); |
3287 } | 3293 } |
3288 | 3294 |
3289 /** | 3295 /** |
3290 * Check each directive in the given [unit] to see if the referenced source | 3296 * Check each directive in the given [unit] to see if the referenced source |
3291 * exists and report an error if it does not. | 3297 * exists and report an error if it does not. |
3292 */ | 3298 */ |
3293 void validateDirectives(CompilationUnit unit) { | 3299 void validateDirectives(CompilationUnit unit) { |
3294 for (Directive directive in unit.directives) { | 3300 for (Directive directive in unit.directives) { |
3295 if (directive is UriBasedDirective) { | 3301 if (directive is UriBasedDirective) { |
3296 validateReferencedSource(directive); | 3302 validateReferencedSource(directive); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3441 @override | 3447 @override |
3442 bool moveNext() { | 3448 bool moveNext() { |
3443 if (_newSources.isEmpty) { | 3449 if (_newSources.isEmpty) { |
3444 return false; | 3450 return false; |
3445 } | 3451 } |
3446 currentTarget = _newSources.first; | 3452 currentTarget = _newSources.first; |
3447 _newSources.remove(currentTarget); | 3453 _newSources.remove(currentTarget); |
3448 return true; | 3454 return true; |
3449 } | 3455 } |
3450 } | 3456 } |
OLD | NEW |