OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.error.error; | 5 library analyzer.error.error; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/error/listener.dart'; | 10 import 'package:analyzer/error/listener.dart'; |
11 import 'package:analyzer/src/dart/scanner/scanner.dart' show ScannerErrorCode; | 11 import 'package:analyzer/src/dart/scanner/scanner.dart' show ScannerErrorCode; |
12 import 'package:analyzer/src/error/codes.dart'; | 12 import 'package:analyzer/src/error/codes.dart'; |
13 import 'package:analyzer/src/generated/java_core.dart'; | 13 import 'package:analyzer/src/generated/java_core.dart'; |
14 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 14 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
15 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
16 import 'package:front_end/compilation_error.dart'; | |
17 import 'package:front_end/src/base/errors.dart'; | 16 import 'package:front_end/src/base/errors.dart'; |
18 import 'package:front_end/src/scanner/errors.dart'; | 17 import 'package:front_end/src/scanner/errors.dart'; |
19 import 'package:source_span/src/span.dart'; | |
20 | 18 |
21 export 'package:front_end/src/base/errors.dart' | 19 export 'package:front_end/src/base/errors.dart' |
22 show ErrorCode, ErrorSeverity, ErrorType; | 20 show ErrorCode, ErrorSeverity, ErrorType; |
23 | 21 |
24 const List<ErrorCode> errorCodeValues = const [ | 22 const List<ErrorCode> errorCodeValues = const [ |
25 // | 23 // |
26 // Manually generated. You can mostly reproduce this list by running the | 24 // Manually generated. You can mostly reproduce this list by running the |
27 // following command from the root of the analyzer package: | 25 // following command from the root of the analyzer package: |
28 // | 26 // |
29 // > cat | 27 // > cat |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 635 } |
638 } | 636 } |
639 return _uniqueNameToCodeMap[uniqueName]; | 637 return _uniqueNameToCodeMap[uniqueName]; |
640 } | 638 } |
641 | 639 |
642 /** | 640 /** |
643 * An error discovered during the analysis of some Dart code. | 641 * An error discovered during the analysis of some Dart code. |
644 * | 642 * |
645 * See [AnalysisErrorListener]. | 643 * See [AnalysisErrorListener]. |
646 */ | 644 */ |
647 class AnalysisError extends CompilationError { | 645 class AnalysisError { |
648 /** | 646 /** |
649 * An empty array of errors used when no errors are expected. | 647 * An empty array of errors used when no errors are expected. |
650 */ | 648 */ |
651 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[]; | 649 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[]; |
652 | 650 |
653 /** | 651 /** |
654 * A [Comparator] that sorts by the name of the file that the [AnalysisError] | 652 * A [Comparator] that sorts by the name of the file that the [AnalysisError] |
655 * was found. | 653 * was found. |
656 */ | 654 */ |
657 static Comparator<AnalysisError> FILE_COMPARATOR = | 655 static Comparator<AnalysisError> FILE_COMPARATOR = |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 String get correction => _correction; | 743 String get correction => _correction; |
746 | 744 |
747 @override | 745 @override |
748 int get hashCode { | 746 int get hashCode { |
749 int hashCode = offset; | 747 int hashCode = offset; |
750 hashCode ^= (_message != null) ? _message.hashCode : 0; | 748 hashCode ^= (_message != null) ? _message.hashCode : 0; |
751 hashCode ^= (source != null) ? source.hashCode : 0; | 749 hashCode ^= (source != null) ? source.hashCode : 0; |
752 return hashCode; | 750 return hashCode; |
753 } | 751 } |
754 | 752 |
755 @override | |
756 SourceSpan get span => source.sourceFile.span(offset, offset + length); | |
757 | |
758 /** | 753 /** |
759 * Return the message to be displayed for this error. The message should | 754 * Return the message to be displayed for this error. The message should |
760 * indicate what is wrong and why it is wrong. | 755 * indicate what is wrong and why it is wrong. |
761 */ | 756 */ |
762 String get message => _message; | 757 String get message => _message; |
763 | 758 |
764 @override | 759 @override |
765 bool operator ==(Object other) { | 760 bool operator ==(Object other) { |
766 if (identical(other, this)) { | 761 if (identical(other, this)) { |
767 return true; | 762 return true; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 | 899 |
905 @override | 900 @override |
906 int get hashCode => ordinal; | 901 int get hashCode => ordinal; |
907 | 902 |
908 @override | 903 @override |
909 int compareTo(ErrorProperty other) => ordinal - other.ordinal; | 904 int compareTo(ErrorProperty other) => ordinal - other.ordinal; |
910 | 905 |
911 @override | 906 @override |
912 String toString() => name; | 907 String toString() => name; |
913 } | 908 } |
OLD | NEW |