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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 * | 408 * |
409 * The list will be empty if there were no errors, but will not be `null`. | 409 * The list will be empty if there were no errors, but will not be `null`. |
410 * | 410 * |
411 * The result is only available for [LibrarySpecificUnit]s. | 411 * The result is only available for [LibrarySpecificUnit]s. |
412 */ | 412 */ |
413 final ListResultDescriptor<AnalysisError> VERIFY_ERRORS = | 413 final ListResultDescriptor<AnalysisError> VERIFY_ERRORS = |
414 new ListResultDescriptor<AnalysisError>( | 414 new ListResultDescriptor<AnalysisError>( |
415 'VERIFY_ERRORS', AnalysisError.NO_ERRORS); | 415 'VERIFY_ERRORS', AnalysisError.NO_ERRORS); |
416 | 416 |
417 /** | 417 /** |
| 418 * Remove [CompileTimeErrorCode.DUPLICATE_DEFINITION] errors from the given |
| 419 * [errors] list. |
| 420 */ |
| 421 void removeDuplicateDefinitionErrors(List<AnalysisError> errors) { |
| 422 if (errors.isNotEmpty) { |
| 423 errors.removeWhere((error) { |
| 424 ErrorCode errorCode = error.errorCode; |
| 425 return errorCode == CompileTimeErrorCode.DUPLICATE_DEFINITION; |
| 426 }); |
| 427 } |
| 428 } |
| 429 |
| 430 /** |
418 * A task that builds implicit constructors for a [ClassElement], or keeps | 431 * A task that builds implicit constructors for a [ClassElement], or keeps |
419 * the existing explicit constructors if the class has them. | 432 * the existing explicit constructors if the class has them. |
420 */ | 433 */ |
421 class BuildClassConstructorsTask extends SourceBasedAnalysisTask { | 434 class BuildClassConstructorsTask extends SourceBasedAnalysisTask { |
422 /** | 435 /** |
423 * The name of the [CONSTRUCTORS] input for the superclass. | 436 * The name of the [CONSTRUCTORS] input for the superclass. |
424 */ | 437 */ |
425 static const String SUPER_CONSTRUCTORS = 'SUPER_CONSTRUCTORS'; | 438 static const String SUPER_CONSTRUCTORS = 'SUPER_CONSTRUCTORS'; |
426 | 439 |
427 /** | 440 /** |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 // Resolve FunctionTypeAlias declarations. | 1167 // Resolve FunctionTypeAlias declarations. |
1155 // | 1168 // |
1156 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( | 1169 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( |
1157 libraryElement, source, typeProvider, errorListener); | 1170 libraryElement, source, typeProvider, errorListener); |
1158 for (CompilationUnitMember member in unit.declarations) { | 1171 for (CompilationUnitMember member in unit.declarations) { |
1159 if (member is FunctionTypeAlias) { | 1172 if (member is FunctionTypeAlias) { |
1160 member.accept(visitor); | 1173 member.accept(visitor); |
1161 } | 1174 } |
1162 } | 1175 } |
1163 // | 1176 // |
| 1177 // Prepare errors. |
| 1178 // |
| 1179 List<AnalysisError> errors = errorListener.errors; |
| 1180 removeDuplicateDefinitionErrors(errors); |
| 1181 // |
1164 // Record outputs. | 1182 // Record outputs. |
1165 // | 1183 // |
1166 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = errorListener.errors; | 1184 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = errors; |
1167 outputs[RESOLVED_UNIT3] = unit; | 1185 outputs[RESOLVED_UNIT3] = unit; |
1168 } | 1186 } |
1169 | 1187 |
1170 /** | 1188 /** |
1171 * Return a map from the names of the inputs of this kind of task to the task | 1189 * Return a map from the names of the inputs of this kind of task to the task |
1172 * input descriptors describing those inputs for a task with the | 1190 * input descriptors describing those inputs for a task with the |
1173 * given [target]. | 1191 * given [target]. |
1174 */ | 1192 */ |
1175 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 1193 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { |
1176 return <String, TaskInput>{ | 1194 return <String, TaskInput>{ |
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2990 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3008 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
2991 CompilationUnitElement unitElement = unit.element; | 3009 CompilationUnitElement unitElement = unit.element; |
2992 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 3010 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
2993 // | 3011 // |
2994 // Resolve TypeName nodes. | 3012 // Resolve TypeName nodes. |
2995 // | 3013 // |
2996 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( | 3014 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( |
2997 library, unitElement.source, typeProvider, errorListener); | 3015 library, unitElement.source, typeProvider, errorListener); |
2998 unit.accept(visitor); | 3016 unit.accept(visitor); |
2999 // | 3017 // |
| 3018 // Prepare errors. |
| 3019 // |
| 3020 List<AnalysisError> errors = errorListener.errors; |
| 3021 removeDuplicateDefinitionErrors(errors); |
| 3022 // |
3000 // Record outputs. | 3023 // Record outputs. |
3001 // | 3024 // |
3002 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors; | 3025 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errors; |
3003 outputs[RESOLVED_UNIT4] = unit; | 3026 outputs[RESOLVED_UNIT4] = unit; |
3004 } | 3027 } |
3005 | 3028 |
3006 /** | 3029 /** |
3007 * Return a map from the names of the inputs of this kind of task to the task | 3030 * Return a map from the names of the inputs of this kind of task to the task |
3008 * input descriptors describing those inputs for a task with the | 3031 * input descriptors describing those inputs for a task with the |
3009 * given [target]. | 3032 * given [target]. |
3010 */ | 3033 */ |
3011 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { | 3034 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { |
3012 return <String, TaskInput>{ | 3035 return <String, TaskInput>{ |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3386 @override | 3409 @override |
3387 bool moveNext() { | 3410 bool moveNext() { |
3388 if (_newSources.isEmpty) { | 3411 if (_newSources.isEmpty) { |
3389 return false; | 3412 return false; |
3390 } | 3413 } |
3391 currentTarget = _newSources.first; | 3414 currentTarget = _newSources.first; |
3392 _newSources.remove(currentTarget); | 3415 _newSources.remove(currentTarget); |
3393 return true; | 3416 return true; |
3394 } | 3417 } |
3395 } | 3418 } |
OLD | NEW |