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 | 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 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 return errors; | 2590 return errors; |
2591 } | 2591 } |
2592 | 2592 |
2593 IgnoreInfo ignoreInfo = getRequiredInput(IGNORE_INFO_INPUT); | 2593 IgnoreInfo ignoreInfo = getRequiredInput(IGNORE_INFO_INPUT); |
2594 if (!ignoreInfo.hasIgnores) { | 2594 if (!ignoreInfo.hasIgnores) { |
2595 return errors; | 2595 return errors; |
2596 } | 2596 } |
2597 | 2597 |
2598 LineInfo lineInfo = getRequiredInput(LINE_INFO_INPUT); | 2598 LineInfo lineInfo = getRequiredInput(LINE_INFO_INPUT); |
2599 | 2599 |
2600 bool isIgnored(AnalysisError error) { | 2600 return filterIgnored(errors, ignoreInfo, lineInfo); |
2601 int errorLine = lineInfo.getLocation(error.offset).lineNumber; | |
2602 String errorCode = error.errorCode.name.toLowerCase(); | |
2603 // Ignores can be on the line or just preceding the error. | |
2604 return ignoreInfo.ignoredAt(errorCode, errorLine) || | |
2605 ignoreInfo.ignoredAt(errorCode, errorLine - 1); | |
2606 } | |
2607 | |
2608 return errors.where((AnalysisError e) => !isIgnored(e)).toList(); | |
2609 } | 2601 } |
2610 | 2602 |
2611 /** | 2603 /** |
2612 * Return a map from the names of the inputs of this kind of task to the task | 2604 * Return a map from the names of the inputs of this kind of task to the task |
2613 * input descriptors describing those inputs for a task with the | 2605 * input descriptors describing those inputs for a task with the |
2614 * given [target]. | 2606 * given [target]. |
2615 */ | 2607 */ |
2616 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2608 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
2617 Source source = target; | 2609 Source source = target; |
2618 Map<String, TaskInput> inputs = <String, TaskInput>{}; | 2610 Map<String, TaskInput> inputs = <String, TaskInput>{}; |
(...skipping 24 matching lines...) Expand all Loading... |
2643 } | 2635 } |
2644 | 2636 |
2645 /** | 2637 /** |
2646 * Create a [DartErrorsTask] based on the given [target] in the given | 2638 * Create a [DartErrorsTask] based on the given [target] in the given |
2647 * [context]. | 2639 * [context]. |
2648 */ | 2640 */ |
2649 static DartErrorsTask createTask( | 2641 static DartErrorsTask createTask( |
2650 AnalysisContext context, AnalysisTarget target) { | 2642 AnalysisContext context, AnalysisTarget target) { |
2651 return new DartErrorsTask(context, target); | 2643 return new DartErrorsTask(context, target); |
2652 } | 2644 } |
| 2645 |
| 2646 /** |
| 2647 * Return a new list with items from [errors] which are not filtered out by |
| 2648 * the [ignoreInfo]. |
| 2649 */ |
| 2650 static List<AnalysisError> filterIgnored( |
| 2651 List<AnalysisError> errors, IgnoreInfo ignoreInfo, LineInfo lineInfo) { |
| 2652 if (errors.isEmpty || !ignoreInfo.hasIgnores) { |
| 2653 return errors; |
| 2654 } |
| 2655 |
| 2656 bool isIgnored(AnalysisError error) { |
| 2657 int errorLine = lineInfo.getLocation(error.offset).lineNumber; |
| 2658 String errorCode = error.errorCode.name.toLowerCase(); |
| 2659 // Ignores can be on the line or just preceding the error. |
| 2660 return ignoreInfo.ignoredAt(errorCode, errorLine) || |
| 2661 ignoreInfo.ignoredAt(errorCode, errorLine - 1); |
| 2662 } |
| 2663 |
| 2664 return errors.where((AnalysisError e) => !isIgnored(e)).toList(); |
| 2665 } |
2653 } | 2666 } |
2654 | 2667 |
2655 /** | 2668 /** |
2656 * A task that builds [RESOLVED_UNIT13] for a unit. | 2669 * A task that builds [RESOLVED_UNIT13] for a unit. |
2657 */ | 2670 */ |
2658 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { | 2671 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { |
2659 /** | 2672 /** |
2660 * The name of the [RESOLVED_UNIT12] input. | 2673 * The name of the [RESOLVED_UNIT12] input. |
2661 */ | 2674 */ |
2662 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2675 static const String UNIT_INPUT = 'UNIT_INPUT'; |
(...skipping 3274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5937 | 5950 |
5938 @override | 5951 @override |
5939 bool moveNext() { | 5952 bool moveNext() { |
5940 if (_newSources.isEmpty) { | 5953 if (_newSources.isEmpty) { |
5941 return false; | 5954 return false; |
5942 } | 5955 } |
5943 currentTarget = _newSources.removeLast(); | 5956 currentTarget = _newSources.removeLast(); |
5944 return true; | 5957 return true; |
5945 } | 5958 } |
5946 } | 5959 } |
OLD | NEW |