| 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.src.generated.error; | 5 library analyzer.src.generated.error; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart' show AstNode; | 9 import 'package:analyzer/dart/ast/ast.dart' show AstNode; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| 11 import 'package:analyzer/dart/element/element.dart'; | 11 import 'package:analyzer/dart/element/element.dart'; |
| 12 import 'package:analyzer/dart/element/type.dart'; | 12 import 'package:analyzer/dart/element/type.dart'; |
| 13 import 'package:analyzer/source/error_processor.dart'; | 13 import 'package:analyzer/source/error_processor.dart'; |
| 14 import 'package:analyzer/src/dart/element/element.dart'; |
| 14 import 'package:analyzer/src/dart/element/type.dart'; | 15 import 'package:analyzer/src/dart/element/type.dart'; |
| 15 import 'package:analyzer/src/dart/scanner/scanner.dart' show ScannerErrorCode; | 16 import 'package:analyzer/src/dart/scanner/scanner.dart' show ScannerErrorCode; |
| 16 import 'package:analyzer/src/generated/generated/shared_messages.dart' | 17 import 'package:analyzer/src/generated/generated/shared_messages.dart' |
| 17 as shared_messages; | 18 as shared_messages; |
| 18 import 'package:analyzer/src/generated/java_core.dart'; | 19 import 'package:analyzer/src/generated/java_core.dart'; |
| 19 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 20 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 20 import 'package:analyzer/src/generated/source.dart'; | 21 import 'package:analyzer/src/generated/source.dart'; |
| 21 import 'package:analyzer/src/task/model.dart'; | 22 import 'package:analyzer/src/task/model.dart'; |
| 22 import 'package:analyzer/task/model.dart'; | 23 import 'package:analyzer/task/model.dart'; |
| 23 import 'package:source_span/source_span.dart'; | 24 import 'package:source_span/source_span.dart'; |
| 24 import 'package:analyzer/src/dart/element/element.dart'; | |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * The descriptor used to associate error processors with analysis contexts in | 27 * The descriptor used to associate error processors with analysis contexts in |
| 28 * configuration data. | 28 * configuration data. |
| 29 */ | 29 */ |
| 30 final ListResultDescriptor<ErrorProcessor> CONFIGURED_ERROR_PROCESSORS = | 30 final ListResultDescriptor<ErrorProcessor> CONFIGURED_ERROR_PROCESSORS = |
| 31 new ListResultDescriptorImpl('configured.errors', const <ErrorProcessor>[]); | 31 new ListResultDescriptorImpl('configured.errors', const <ErrorProcessor>[]); |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * An error discovered during the analysis of some Dart code. | 34 * An error discovered during the analysis of some Dart code. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 AnalysisError(this.source, this.offset, this.length, this.errorCode, | 116 AnalysisError(this.source, this.offset, this.length, this.errorCode, |
| 117 [List<Object> arguments]) { | 117 [List<Object> arguments]) { |
| 118 this._message = formatList(errorCode.message, arguments); | 118 this._message = formatList(errorCode.message, arguments); |
| 119 String correctionTemplate = errorCode.correction; | 119 String correctionTemplate = errorCode.correction; |
| 120 if (correctionTemplate != null) { | 120 if (correctionTemplate != null) { |
| 121 this._correction = formatList(correctionTemplate, arguments); | 121 this._correction = formatList(correctionTemplate, arguments); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * Initialize a newly created analysis error with given values. |
| 127 */ |
| 128 AnalysisError.forValues(this.source, this.offset, this.length, this.errorCode, |
| 129 this._message, this._correction); |
| 130 |
| 131 /** |
| 126 * Return the template used to create the correction to be displayed for this | 132 * Return the template used to create the correction to be displayed for this |
| 127 * error, or `null` if there is no correction information for this error. The | 133 * error, or `null` if there is no correction information for this error. The |
| 128 * correction should indicate how the user can fix the error. | 134 * correction should indicate how the user can fix the error. |
| 129 */ | 135 */ |
| 130 String get correction => _correction; | 136 String get correction => _correction; |
| 131 | 137 |
| 132 @override | 138 @override |
| 133 int get hashCode { | 139 int get hashCode { |
| 134 int hashCode = offset; | 140 int hashCode = offset; |
| 135 hashCode ^= (_message != null) ? _message.hashCode : 0; | 141 hashCode ^= (_message != null) ? _message.hashCode : 0; |
| (...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3016 ScannerErrorCode.ILLEGAL_CHARACTER, | 3022 ScannerErrorCode.ILLEGAL_CHARACTER, |
| 3017 ScannerErrorCode.MISSING_DIGIT, | 3023 ScannerErrorCode.MISSING_DIGIT, |
| 3018 ScannerErrorCode.MISSING_HEX_DIGIT, | 3024 ScannerErrorCode.MISSING_HEX_DIGIT, |
| 3019 ScannerErrorCode.MISSING_QUOTE, | 3025 ScannerErrorCode.MISSING_QUOTE, |
| 3020 ScannerErrorCode.UNABLE_GET_CONTENT, | 3026 ScannerErrorCode.UNABLE_GET_CONTENT, |
| 3021 ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, | 3027 ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, |
| 3022 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, | 3028 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
| 3023 ]; | 3029 ]; |
| 3024 | 3030 |
| 3025 /** | 3031 /** |
| 3032 * The lazy initialized map from [uniqueName] to the [ErrorCode] instance. |
| 3033 */ |
| 3034 static HashMap<String, ErrorCode> _uniqueNameToCodeMap; |
| 3035 |
| 3036 /** |
| 3026 * An empty list of error codes. | 3037 * An empty list of error codes. |
| 3027 */ | 3038 */ |
| 3028 static const List<ErrorCode> EMPTY_LIST = const <ErrorCode>[]; | 3039 static const List<ErrorCode> EMPTY_LIST = const <ErrorCode>[]; |
| 3029 | 3040 |
| 3030 /** | 3041 /** |
| 3031 * The name of the error code. | 3042 * The name of the error code. |
| 3032 */ | 3043 */ |
| 3033 final String name; | 3044 final String name; |
| 3034 | 3045 |
| 3035 /** | 3046 /** |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3063 */ | 3074 */ |
| 3064 ErrorType get type; | 3075 ErrorType get type; |
| 3065 | 3076 |
| 3066 /** | 3077 /** |
| 3067 * The unique name of this error code. | 3078 * The unique name of this error code. |
| 3068 */ | 3079 */ |
| 3069 String get uniqueName => "$runtimeType.$name"; | 3080 String get uniqueName => "$runtimeType.$name"; |
| 3070 | 3081 |
| 3071 @override | 3082 @override |
| 3072 String toString() => uniqueName; | 3083 String toString() => uniqueName; |
| 3084 |
| 3085 /** |
| 3086 * Return the [ErrorCode] with the given [uniqueName], or `null` if not |
| 3087 * found. |
| 3088 */ |
| 3089 static ErrorCode byUniqueName(String uniqueName) { |
| 3090 if (_uniqueNameToCodeMap == null) { |
| 3091 _uniqueNameToCodeMap = new HashMap<String, ErrorCode>(); |
| 3092 for (ErrorCode errorCode in values) { |
| 3093 _uniqueNameToCodeMap[errorCode.uniqueName] = errorCode; |
| 3094 } |
| 3095 } |
| 3096 return _uniqueNameToCodeMap[uniqueName]; |
| 3097 } |
| 3073 } | 3098 } |
| 3074 | 3099 |
| 3075 /** | 3100 /** |
| 3076 * The properties that can be associated with an [AnalysisError]. | 3101 * The properties that can be associated with an [AnalysisError]. |
| 3077 */ | 3102 */ |
| 3078 class ErrorProperty<V> extends Enum<ErrorProperty> { | 3103 class ErrorProperty<V> extends Enum<ErrorProperty> { |
| 3079 /** | 3104 /** |
| 3080 * A property whose value is a list of [FieldElement]s that are final, but | 3105 * A property whose value is a list of [FieldElement]s that are final, but |
| 3081 * not initialized by a constructor. | 3106 * not initialized by a constructor. |
| 3082 */ | 3107 */ |
| (...skipping 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5811 * Initialize a newly created error code to have the given [name]. | 5836 * Initialize a newly created error code to have the given [name]. |
| 5812 */ | 5837 */ |
| 5813 const TodoCode(String name) : super(name, "{0}"); | 5838 const TodoCode(String name) : super(name, "{0}"); |
| 5814 | 5839 |
| 5815 @override | 5840 @override |
| 5816 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; | 5841 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; |
| 5817 | 5842 |
| 5818 @override | 5843 @override |
| 5819 ErrorType get type => ErrorType.TODO; | 5844 ErrorType get type => ErrorType.TODO; |
| 5820 } | 5845 } |
| OLD | NEW |