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 engine.error; | 5 library engine.error; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart' show AstNode; |
| 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/java_core.dart'; |
| 12 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 13 import 'package:analyzer/src/generated/scanner.dart' |
| 14 show ScannerErrorCode, Token; |
| 15 import 'package:analyzer/src/generated/source.dart'; |
9 import 'package:analyzer/src/task/model.dart'; | 16 import 'package:analyzer/src/task/model.dart'; |
10 import 'package:analyzer/task/model.dart'; | 17 import 'package:analyzer/task/model.dart'; |
11 import 'package:source_span/source_span.dart'; | 18 import 'package:source_span/source_span.dart'; |
12 | 19 |
13 import 'ast.dart' show AstNode; | |
14 import 'element.dart'; | |
15 import 'java_core.dart'; | |
16 import 'scanner.dart' show Token; | |
17 import 'source.dart'; | |
18 | |
19 /** | 20 /** |
20 * The descriptor used to associate error filters with analysis contexts in | 21 * The descriptor used to associate error filters with analysis contexts in |
21 * configuration data. | 22 * configuration data. |
22 */ | 23 */ |
23 final ListResultDescriptor<List<ErrorFilter>> CONFIGURED_ERROR_FILTERS = | 24 final ListResultDescriptor<List<ErrorFilter>> CONFIGURED_ERROR_FILTERS = |
24 new ListResultDescriptorImpl('configured.errors', const <ErrorFilter>[]); | 25 new ListResultDescriptorImpl('configured.errors', const <ErrorFilter>[]); |
25 | 26 |
26 /** | 27 /** |
27 * A predicate used to potentially filter an [error]. | 28 * A predicate used to potentially filter an [error]. |
28 * | 29 * |
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 * [correction]. | 2543 * [correction]. |
2543 */ | 2544 */ |
2544 abstract class ErrorCode { | 2545 abstract class ErrorCode { |
2545 /** | 2546 /** |
2546 * Engine error code values. | 2547 * Engine error code values. |
2547 */ | 2548 */ |
2548 static const List<ErrorCode> values = const [ | 2549 static const List<ErrorCode> values = const [ |
2549 // | 2550 // |
2550 // Manually generated. FWIW, this get's you most of the way there: | 2551 // Manually generated. FWIW, this get's you most of the way there: |
2551 // | 2552 // |
2552 // > grep 'static const .*Code' error.dart | awk '{print $3"."$4","}' | 2553 // > grep 'static const .*Code' (error.dart|parser|scanner.dart) |
| 2554 // | awk '{print $3"."$4","}' |
| 2555 // |
| 2556 // error.dart: |
2553 // | 2557 // |
2554 AnalysisOptionsErrorCode.PARSE_ERROR, | 2558 AnalysisOptionsErrorCode.PARSE_ERROR, |
2555 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE, | 2559 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE, |
2556 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES, | 2560 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES, |
2557 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, | 2561 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, |
2558 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, | 2562 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, |
2559 CheckedModeCompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE, | 2563 CheckedModeCompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE, |
2560 CheckedModeCompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE, | 2564 CheckedModeCompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE, |
2561 CheckedModeCompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE, | 2565 CheckedModeCompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE, |
2562 CheckedModeCompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE, | 2566 CheckedModeCompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE, |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2886 StaticWarningCode.UNDEFINED_CLASS, | 2890 StaticWarningCode.UNDEFINED_CLASS, |
2887 StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, | 2891 StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, |
2888 StaticWarningCode.UNDEFINED_GETTER, | 2892 StaticWarningCode.UNDEFINED_GETTER, |
2889 StaticWarningCode.UNDEFINED_IDENTIFIER, | 2893 StaticWarningCode.UNDEFINED_IDENTIFIER, |
2890 StaticWarningCode.UNDEFINED_NAMED_PARAMETER, | 2894 StaticWarningCode.UNDEFINED_NAMED_PARAMETER, |
2891 StaticWarningCode.UNDEFINED_SETTER, | 2895 StaticWarningCode.UNDEFINED_SETTER, |
2892 StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER, | 2896 StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER, |
2893 StaticWarningCode.UNDEFINED_SUPER_GETTER, | 2897 StaticWarningCode.UNDEFINED_SUPER_GETTER, |
2894 StaticWarningCode.UNDEFINED_SUPER_SETTER, | 2898 StaticWarningCode.UNDEFINED_SUPER_SETTER, |
2895 StaticWarningCode.VOID_RETURN_FOR_GETTER, | 2899 StaticWarningCode.VOID_RETURN_FOR_GETTER, |
2896 TodoCode.TODO | 2900 TodoCode.TODO, |
| 2901 |
| 2902 // |
| 2903 // parser.dart: |
| 2904 // |
| 2905 ParserErrorCode.ABSTRACT_CLASS_MEMBER, |
| 2906 ParserErrorCode.ABSTRACT_ENUM, |
| 2907 ParserErrorCode.ABSTRACT_STATIC_METHOD, |
| 2908 ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, |
| 2909 ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, |
| 2910 ParserErrorCode.ABSTRACT_TYPEDEF, |
| 2911 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT, |
| 2912 ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, |
| 2913 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, |
| 2914 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, |
| 2915 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, |
| 2916 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER, |
| 2917 ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, |
| 2918 ParserErrorCode.CLASS_IN_CLASS, |
| 2919 ParserErrorCode.COLON_IN_PLACE_OF_IN, |
| 2920 ParserErrorCode.CONST_AND_FINAL, |
| 2921 ParserErrorCode.CONST_AND_VAR, |
| 2922 ParserErrorCode.CONST_CLASS, |
| 2923 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, |
| 2924 ParserErrorCode.CONST_ENUM, |
| 2925 ParserErrorCode.CONST_FACTORY, |
| 2926 ParserErrorCode.CONST_METHOD, |
| 2927 ParserErrorCode.CONST_TYPEDEF, |
| 2928 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, |
| 2929 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, |
| 2930 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, |
| 2931 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, |
| 2932 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, |
| 2933 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, |
| 2934 ParserErrorCode.DUPLICATED_MODIFIER, |
| 2935 ParserErrorCode.EMPTY_ENUM_BODY, |
| 2936 ParserErrorCode.ENUM_IN_CLASS, |
| 2937 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, |
| 2938 ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, |
| 2939 ParserErrorCode.EXPECTED_CLASS_MEMBER, |
| 2940 ParserErrorCode.EXPECTED_EXECUTABLE, |
| 2941 ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, |
| 2942 ParserErrorCode.EXPECTED_STRING_LITERAL, |
| 2943 ParserErrorCode.EXPECTED_TOKEN, |
| 2944 ParserErrorCode.EXPECTED_TYPE_NAME, |
| 2945 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, |
| 2946 ParserErrorCode.EXTERNAL_AFTER_CONST, |
| 2947 ParserErrorCode.EXTERNAL_AFTER_FACTORY, |
| 2948 ParserErrorCode.EXTERNAL_AFTER_STATIC, |
| 2949 ParserErrorCode.EXTERNAL_CLASS, |
| 2950 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, |
| 2951 ParserErrorCode.EXTERNAL_ENUM, |
| 2952 ParserErrorCode.EXTERNAL_FIELD, |
| 2953 ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, |
| 2954 ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, |
| 2955 ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, |
| 2956 ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, |
| 2957 ParserErrorCode.EXTERNAL_TYPEDEF, |
| 2958 ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, |
| 2959 ParserErrorCode.FACTORY_WITH_INITIALIZERS, |
| 2960 ParserErrorCode.FACTORY_WITHOUT_BODY, |
| 2961 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, |
| 2962 ParserErrorCode.FINAL_AND_VAR, |
| 2963 ParserErrorCode.FINAL_CLASS, |
| 2964 ParserErrorCode.FINAL_CONSTRUCTOR, |
| 2965 ParserErrorCode.FINAL_ENUM, |
| 2966 ParserErrorCode.FINAL_METHOD, |
| 2967 ParserErrorCode.FINAL_TYPEDEF, |
| 2968 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, |
| 2969 ParserErrorCode.GETTER_IN_FUNCTION, |
| 2970 ParserErrorCode.GETTER_WITH_PARAMETERS, |
| 2971 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, |
| 2972 ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, |
| 2973 ParserErrorCode.IMPLEMENTS_BEFORE_WITH, |
| 2974 ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, |
| 2975 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, |
| 2976 ParserErrorCode.INVALID_AWAIT_IN_FOR, |
| 2977 ParserErrorCode.INVALID_CODE_POINT, |
| 2978 ParserErrorCode.INVALID_COMMENT_REFERENCE, |
| 2979 ParserErrorCode.INVALID_HEX_ESCAPE, |
| 2980 ParserErrorCode.INVALID_OPERATOR, |
| 2981 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, |
| 2982 ParserErrorCode.INVALID_STAR_AFTER_ASYNC, |
| 2983 ParserErrorCode.INVALID_SYNC, |
| 2984 ParserErrorCode.INVALID_UNICODE_ESCAPE, |
| 2985 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, |
| 2986 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER, |
| 2987 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, |
| 2988 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER, |
| 2989 ParserErrorCode.MISSING_CATCH_OR_FINALLY, |
| 2990 ParserErrorCode.MISSING_CLASS_BODY, |
| 2991 ParserErrorCode.MISSING_CLOSING_PARENTHESIS, |
| 2992 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, |
| 2993 ParserErrorCode.MISSING_ENUM_BODY, |
| 2994 ParserErrorCode.MISSING_EXPRESSION_IN_INITIALIZER, |
| 2995 ParserErrorCode.MISSING_EXPRESSION_IN_THROW, |
| 2996 ParserErrorCode.MISSING_FUNCTION_BODY, |
| 2997 ParserErrorCode.MISSING_FUNCTION_PARAMETERS, |
| 2998 ParserErrorCode.MISSING_METHOD_PARAMETERS, |
| 2999 ParserErrorCode.MISSING_GET, |
| 3000 ParserErrorCode.MISSING_IDENTIFIER, |
| 3001 ParserErrorCode.MISSING_INITIALIZER, |
| 3002 ParserErrorCode.MISSING_KEYWORD_OPERATOR, |
| 3003 ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE, |
| 3004 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE, |
| 3005 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT, |
| 3006 ParserErrorCode.MISSING_STAR_AFTER_SYNC, |
| 3007 ParserErrorCode.MISSING_STATEMENT, |
| 3008 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, |
| 3009 ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, |
| 3010 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, |
| 3011 ParserErrorCode.MIXED_PARAMETER_GROUPS, |
| 3012 ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, |
| 3013 ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, |
| 3014 ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, |
| 3015 ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, |
| 3016 ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, |
| 3017 ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, |
| 3018 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, |
| 3019 ParserErrorCode.MULTIPLE_WITH_CLAUSES, |
| 3020 ParserErrorCode.NAMED_FUNCTION_EXPRESSION, |
| 3021 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, |
| 3022 ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE, |
| 3023 ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE, |
| 3024 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, |
| 3025 ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, |
| 3026 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, |
| 3027 ParserErrorCode.NON_STRING_LITERAL_AS_URI, |
| 3028 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, |
| 3029 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, |
| 3030 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, |
| 3031 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, |
| 3032 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, |
| 3033 ParserErrorCode.SETTER_IN_FUNCTION, |
| 3034 ParserErrorCode.STATIC_AFTER_CONST, |
| 3035 ParserErrorCode.STATIC_AFTER_FINAL, |
| 3036 ParserErrorCode.STATIC_AFTER_VAR, |
| 3037 ParserErrorCode.STATIC_CONSTRUCTOR, |
| 3038 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, |
| 3039 ParserErrorCode.STATIC_OPERATOR, |
| 3040 ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, |
| 3041 ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, |
| 3042 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, |
| 3043 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, |
| 3044 ParserErrorCode.TOP_LEVEL_OPERATOR, |
| 3045 ParserErrorCode.TYPEDEF_IN_CLASS, |
| 3046 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, |
| 3047 ParserErrorCode.UNEXPECTED_TOKEN, |
| 3048 ParserErrorCode.WITH_BEFORE_EXTENDS, |
| 3049 ParserErrorCode.WITH_WITHOUT_EXTENDS, |
| 3050 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, |
| 3051 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, |
| 3052 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, |
| 3053 ParserErrorCode.VAR_AND_TYPE, |
| 3054 ParserErrorCode.VAR_AS_TYPE_NAME, |
| 3055 ParserErrorCode.VAR_CLASS, |
| 3056 ParserErrorCode.VAR_ENUM, |
| 3057 ParserErrorCode.VAR_RETURN_TYPE, |
| 3058 ParserErrorCode.VAR_TYPEDEF, |
| 3059 ParserErrorCode.VOID_PARAMETER, |
| 3060 ParserErrorCode.VOID_VARIABLE, |
| 3061 |
| 3062 // |
| 3063 // scanner.dart: |
| 3064 // |
| 3065 ScannerErrorCode.ILLEGAL_CHARACTER, |
| 3066 ScannerErrorCode.MISSING_DIGIT, |
| 3067 ScannerErrorCode.MISSING_HEX_DIGIT, |
| 3068 ScannerErrorCode.MISSING_QUOTE, |
| 3069 ScannerErrorCode.UNABLE_GET_CONTENT, |
| 3070 ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, |
| 3071 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
2897 ]; | 3072 ]; |
2898 | 3073 |
2899 /** | 3074 /** |
2900 * An empty list of error codes. | 3075 * An empty list of error codes. |
2901 */ | 3076 */ |
2902 static const List<ErrorCode> EMPTY_LIST = const <ErrorCode>[]; | 3077 static const List<ErrorCode> EMPTY_LIST = const <ErrorCode>[]; |
2903 | 3078 |
2904 /** | 3079 /** |
2905 * The name of the error code. | 3080 * The name of the error code. |
2906 */ | 3081 */ |
(...skipping 2591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5498 * Initialize a newly created error code to have the given [name]. | 5673 * Initialize a newly created error code to have the given [name]. |
5499 */ | 5674 */ |
5500 const TodoCode(String name) : super(name, "{0}"); | 5675 const TodoCode(String name) : super(name, "{0}"); |
5501 | 5676 |
5502 @override | 5677 @override |
5503 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; | 5678 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; |
5504 | 5679 |
5505 @override | 5680 @override |
5506 ErrorType get type => ErrorType.TODO; | 5681 ErrorType get type => ErrorType.TODO; |
5507 } | 5682 } |
OLD | NEW |