| 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 'ast.dart' show AstNode; | 9 import 'ast.dart' show AstNode; |
| 10 import 'element.dart'; | 10 import 'element.dart'; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 * information for this error. | 66 * information for this error. |
| 67 */ | 67 */ |
| 68 String _correction; | 68 String _correction; |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * The source in which the error occurred, or `null` if unknown. | 71 * The source in which the error occurred, or `null` if unknown. |
| 72 */ | 72 */ |
| 73 Source source; | 73 Source source; |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * The character offset from the beginning of the source (zero based) where th
e error occurred. | 76 * The character offset from the beginning of the source (zero based) where |
| 77 * the error occurred. |
| 77 */ | 78 */ |
| 78 int _offset = 0; | 79 int offset = 0; |
| 79 | 80 |
| 80 /** | 81 /** |
| 81 * The number of characters from the offset to the end of the source which enc
ompasses the | 82 * The number of characters from the offset to the end of the source which enc
ompasses the |
| 82 * compilation error. | 83 * compilation error. |
| 83 */ | 84 */ |
| 84 int _length = 0; | 85 int _length = 0; |
| 85 | 86 |
| 86 /** | 87 /** |
| 87 * A flag indicating whether this error can be shown to be a non-issue because
of the result of | 88 * A flag indicating whether this error can be shown to be a non-issue because
of the result of |
| 88 * type propagation. | 89 * type propagation. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 103 | 104 |
| 104 /** | 105 /** |
| 105 * Initialize a newly created analysis error for the specified source at the g
iven location. | 106 * Initialize a newly created analysis error for the specified source at the g
iven location. |
| 106 * | 107 * |
| 107 * @param source the source for which the exception occurred | 108 * @param source the source for which the exception occurred |
| 108 * @param offset the offset of the location of the error | 109 * @param offset the offset of the location of the error |
| 109 * @param length the length of the location of the error | 110 * @param length the length of the location of the error |
| 110 * @param errorCode the error code to be associated with this error | 111 * @param errorCode the error code to be associated with this error |
| 111 * @param arguments the arguments used to build the error message | 112 * @param arguments the arguments used to build the error message |
| 112 */ | 113 */ |
| 113 AnalysisError.con2(this.source, int offset, int length, this.errorCode, | 114 AnalysisError.con2(this.source, this.offset, int length, this.errorCode, |
| 114 [List<Object> arguments]) { | 115 [List<Object> arguments]) { |
| 115 this._offset = offset; | |
| 116 this._length = length; | 116 this._length = length; |
| 117 this._message = formatList(errorCode.message, arguments); | 117 this._message = formatList(errorCode.message, arguments); |
| 118 String correctionTemplate = errorCode.correction; | 118 String correctionTemplate = errorCode.correction; |
| 119 if (correctionTemplate != null) { | 119 if (correctionTemplate != null) { |
| 120 this._correction = formatList(correctionTemplate, arguments); | 120 this._correction = formatList(correctionTemplate, arguments); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * Return the correction to be displayed for this error, or `null` if there is
no correction | 125 * Return the correction to be displayed for this error, or `null` if there is
no correction |
| 126 * information for this error. The correction should indicate how the user can
fix the error. | 126 * information for this error. The correction should indicate how the user can
fix the error. |
| 127 * | 127 * |
| 128 * @return the template used to create the correction to be displayed for this
error | 128 * @return the template used to create the correction to be displayed for this
error |
| 129 */ | 129 */ |
| 130 String get correction => _correction; | 130 String get correction => _correction; |
| 131 | 131 |
| 132 @override | 132 @override |
| 133 int get hashCode { | 133 int get hashCode { |
| 134 int hashCode = _offset; | 134 int hashCode = offset; |
| 135 hashCode ^= (_message != null) ? _message.hashCode : 0; | 135 hashCode ^= (_message != null) ? _message.hashCode : 0; |
| 136 hashCode ^= (source != null) ? source.hashCode : 0; | 136 hashCode ^= (source != null) ? source.hashCode : 0; |
| 137 return hashCode; | 137 return hashCode; |
| 138 } | 138 } |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Return the number of characters from the offset to the end of the source wh
ich encompasses the | 141 * Return the number of characters from the offset to the end of the source wh
ich encompasses the |
| 142 * compilation error. | 142 * compilation error. |
| 143 * | 143 * |
| 144 * @return the length of the error location | 144 * @return the length of the error location |
| 145 */ | 145 */ |
| 146 int get length => _length; | 146 int get length => _length; |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * Return the message to be displayed for this error. The message should indic
ate what is wrong | 149 * Return the message to be displayed for this error. The message should indic
ate what is wrong |
| 150 * and why it is wrong. | 150 * and why it is wrong. |
| 151 * | 151 * |
| 152 * @return the message to be displayed for this error | 152 * @return the message to be displayed for this error |
| 153 */ | 153 */ |
| 154 String get message => _message; | 154 String get message => _message; |
| 155 | 155 |
| 156 /** | |
| 157 * Return the character offset from the beginning of the source (zero based) w
here the error | |
| 158 * occurred. | |
| 159 * | |
| 160 * @return the offset to the start of the error location | |
| 161 */ | |
| 162 int get offset => _offset; | |
| 163 | |
| 164 @override | 156 @override |
| 165 bool operator ==(Object obj) { | 157 bool operator ==(Object obj) { |
| 166 if (identical(obj, this)) { | 158 if (identical(obj, this)) { |
| 167 return true; | 159 return true; |
| 168 } | 160 } |
| 169 // prepare other AnalysisError | 161 // prepare other AnalysisError |
| 170 if (obj is! AnalysisError) { | 162 if (obj is! AnalysisError) { |
| 171 return false; | 163 return false; |
| 172 } | 164 } |
| 173 AnalysisError other = obj as AnalysisError; | 165 AnalysisError other = obj as AnalysisError; |
| 174 // Quick checks. | 166 // Quick checks. |
| 175 if (!identical(errorCode, other.errorCode)) { | 167 if (!identical(errorCode, other.errorCode)) { |
| 176 return false; | 168 return false; |
| 177 } | 169 } |
| 178 if (_offset != other._offset || _length != other._length) { | 170 if (offset != other.offset || _length != other._length) { |
| 179 return false; | 171 return false; |
| 180 } | 172 } |
| 181 if (isStaticOnly != other.isStaticOnly) { | 173 if (isStaticOnly != other.isStaticOnly) { |
| 182 return false; | 174 return false; |
| 183 } | 175 } |
| 184 // Deep checks. | 176 // Deep checks. |
| 185 if (_message != other._message) { | 177 if (_message != other._message) { |
| 186 return false; | 178 return false; |
| 187 } | 179 } |
| 188 if (source != other.source) { | 180 if (source != other.source) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 199 * @param property the property whose value is to be returned | 191 * @param property the property whose value is to be returned |
| 200 * @return the value of the given property | 192 * @return the value of the given property |
| 201 */ | 193 */ |
| 202 Object getProperty(ErrorProperty property) => null; | 194 Object getProperty(ErrorProperty property) => null; |
| 203 | 195 |
| 204 @override | 196 @override |
| 205 String toString() { | 197 String toString() { |
| 206 StringBuffer buffer = new StringBuffer(); | 198 StringBuffer buffer = new StringBuffer(); |
| 207 buffer.write((source != null) ? source.fullName : "<unknown source>"); | 199 buffer.write((source != null) ? source.fullName : "<unknown source>"); |
| 208 buffer.write("("); | 200 buffer.write("("); |
| 209 buffer.write(_offset); | 201 buffer.write(offset); |
| 210 buffer.write(".."); | 202 buffer.write(".."); |
| 211 buffer.write(_offset + _length - 1); | 203 buffer.write(offset + _length - 1); |
| 212 buffer.write("): "); | 204 buffer.write("): "); |
| 213 //buffer.write("(" + lineNumber + ":" + columnNumber + "): "); | 205 //buffer.write("(" + lineNumber + ":" + columnNumber + "): "); |
| 214 buffer.write(_message); | 206 buffer.write(_message); |
| 215 return buffer.toString(); | 207 return buffer.toString(); |
| 216 } | 208 } |
| 217 } | 209 } |
| 218 | 210 |
| 219 /** | 211 /** |
| 220 * The interface `AnalysisErrorListener` defines the behavior of objects that li
sten for | 212 * The interface `AnalysisErrorListener` defines the behavior of objects that li
sten for |
| 221 * [AnalysisError] being produced by the analysis engine. | 213 * [AnalysisError] being produced by the analysis engine. |
| (...skipping 4784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5006 * Initialize a newly created error code to have the given [name]. | 4998 * Initialize a newly created error code to have the given [name]. |
| 5007 */ | 4999 */ |
| 5008 const TodoCode(String name) : super(name, "{0}"); | 5000 const TodoCode(String name) : super(name, "{0}"); |
| 5009 | 5001 |
| 5010 @override | 5002 @override |
| 5011 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; | 5003 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; |
| 5012 | 5004 |
| 5013 @override | 5005 @override |
| 5014 ErrorType get type => ErrorType.TODO; | 5006 ErrorType get type => ErrorType.TODO; |
| 5015 } | 5007 } |
| OLD | NEW |