| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 5 |
| 6 /** | 6 /** |
| 7 * The messages in this file should meet the following guide lines: | 7 * The messages in this file should meet the following guide lines: |
| 8 * | 8 * |
| 9 * 1. The message should be a complete sentence starting with an uppercase | 9 * 1. The message should be a complete sentence starting with an uppercase |
| 10 * letter, and ending with a period. | 10 * letter, and ending with a period. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 library dart2js.messages; | 64 library dart2js.messages; |
| 65 | 65 |
| 66 import '../tokens/token.dart' show | 66 import '../tokens/token.dart' show |
| 67 ErrorToken, | 67 ErrorToken, |
| 68 Token; | 68 Token; |
| 69 | 69 |
| 70 import 'invariant.dart' show | 70 import 'invariant.dart' show |
| 71 invariant; | 71 invariant; |
| 72 import 'spannable.dart' show | 72 import 'spannable.dart' show |
| 73 CURRENT_ELEMENT_SPANNABLE; | 73 CURRENT_ELEMENT_SPANNABLE; |
| 74 import '../constants/expressions.dart' show |
| 75 ConstantExpression; |
| 74 | 76 |
| 75 const DONT_KNOW_HOW_TO_FIX = "Computer says no!"; | 77 const DONT_KNOW_HOW_TO_FIX = "Computer says no!"; |
| 76 | 78 |
| 77 /// Keys for the [MessageTemplate]s. | 79 /// Keys for the [MessageTemplate]s. |
| 78 enum MessageKind { | 80 enum MessageKind { |
| 79 ABSTRACT_CLASS_INSTANTIATION, | 81 ABSTRACT_CLASS_INSTANTIATION, |
| 80 ABSTRACT_GETTER, | 82 ABSTRACT_GETTER, |
| 81 ABSTRACT_METHOD, | 83 ABSTRACT_METHOD, |
| 82 ABSTRACT_SETTER, | 84 ABSTRACT_SETTER, |
| 83 ACCESSED_IN_CLOSURE, | 85 ACCESSED_IN_CLOSURE, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 INHERITED_IMPLICIT_GETTER, | 240 INHERITED_IMPLICIT_GETTER, |
| 239 INHERITED_METHOD, | 241 INHERITED_METHOD, |
| 240 INIT_STATIC_FIELD, | 242 INIT_STATIC_FIELD, |
| 241 INITIALIZING_FORMAL_NOT_ALLOWED, | 243 INITIALIZING_FORMAL_NOT_ALLOWED, |
| 242 INSTANCE_STATIC_SAME_NAME, | 244 INSTANCE_STATIC_SAME_NAME, |
| 243 INSTANCE_STATIC_SAME_NAME_CONT, | 245 INSTANCE_STATIC_SAME_NAME_CONT, |
| 244 INTERNAL_LIBRARY, | 246 INTERNAL_LIBRARY, |
| 245 INTERNAL_LIBRARY_FROM, | 247 INTERNAL_LIBRARY_FROM, |
| 246 INVALID_ARGUMENT_AFTER_NAMED, | 248 INVALID_ARGUMENT_AFTER_NAMED, |
| 247 INVALID_AWAIT_FOR, | 249 INVALID_AWAIT_FOR, |
| 250 INVALID_BOOL_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE, |
| 248 INVALID_BREAK, | 251 INVALID_BREAK, |
| 249 INVALID_CASE_DEFAULT, | 252 INVALID_CASE_DEFAULT, |
| 253 INVALID_CONSTANT_ADD_TYPES, |
| 254 INVALID_CONSTANT_BINARY_INT_TYPE, |
| 255 INVALID_CONSTANT_BINARY_NUM_TYPE, |
| 256 INVALID_CONSTANT_BINARY_PRIMITIVE_TYPE, |
| 257 INVALID_CONSTANT_COMPLEMENT_TYPE, |
| 258 INVALID_CONSTANT_CONDITIONAL_TYPE, |
| 259 INVALID_CONSTANT_IF_NULL, |
| 260 INVALID_CONSTANT_INDEX, |
| 261 INVALID_CONSTANT_INTERPOLATION_TYPE, |
| 262 INVALID_CONSTANT_NEGATE_TYPE, |
| 263 INVALID_CONSTANT_NOT_TYPE, |
| 264 INVALID_CONSTANT_NUM_ADD_TYPE, |
| 265 INVALID_CONSTANT_STRING_ADD_TYPE, |
| 250 INVALID_CONSTRUCTOR_ARGUMENTS, | 266 INVALID_CONSTRUCTOR_ARGUMENTS, |
| 251 INVALID_CONSTRUCTOR_NAME, | 267 INVALID_CONSTRUCTOR_NAME, |
| 252 INVALID_CONTINUE, | 268 INVALID_CONTINUE, |
| 253 INVALID_FOR_IN, | 269 INVALID_FOR_IN, |
| 270 INVALID_FROM_ENVIRONMENT_NAME_TYPE, |
| 254 INVALID_INITIALIZER, | 271 INVALID_INITIALIZER, |
| 272 INVALID_INT_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE, |
| 273 INVALID_LOGICAL_AND_OPERAND_TYPE, |
| 274 INVALID_LOGICAL_OR_OPERAND_TYPE, |
| 255 INVALID_OVERRIDDEN_FIELD, | 275 INVALID_OVERRIDDEN_FIELD, |
| 256 INVALID_OVERRIDDEN_GETTER, | 276 INVALID_OVERRIDDEN_GETTER, |
| 257 INVALID_OVERRIDDEN_METHOD, | 277 INVALID_OVERRIDDEN_METHOD, |
| 258 INVALID_OVERRIDDEN_SETTER, | 278 INVALID_OVERRIDDEN_SETTER, |
| 259 INVALID_OVERRIDE_FIELD, | 279 INVALID_OVERRIDE_FIELD, |
| 260 INVALID_OVERRIDE_FIELD_WITH_GETTER, | 280 INVALID_OVERRIDE_FIELD_WITH_GETTER, |
| 261 INVALID_OVERRIDE_FIELD_WITH_SETTER, | 281 INVALID_OVERRIDE_FIELD_WITH_SETTER, |
| 262 INVALID_OVERRIDE_GETTER, | 282 INVALID_OVERRIDE_GETTER, |
| 263 INVALID_OVERRIDE_GETTER_WITH_FIELD, | 283 INVALID_OVERRIDE_GETTER_WITH_FIELD, |
| 264 INVALID_OVERRIDE_METHOD, | 284 INVALID_OVERRIDE_METHOD, |
| 265 INVALID_OVERRIDE_SETTER, | 285 INVALID_OVERRIDE_SETTER, |
| 266 INVALID_OVERRIDE_SETTER_WITH_FIELD, | 286 INVALID_OVERRIDE_SETTER_WITH_FIELD, |
| 267 INVALID_PACKAGE_CONFIG, | 287 INVALID_PACKAGE_CONFIG, |
| 268 INVALID_PACKAGE_URI, | 288 INVALID_PACKAGE_URI, |
| 269 INVALID_PARAMETER, | 289 INVALID_PARAMETER, |
| 270 INVALID_RECEIVER_IN_INITIALIZER, | 290 INVALID_RECEIVER_IN_INITIALIZER, |
| 271 INVALID_SOURCE_FILE_LOCATION, | 291 INVALID_SOURCE_FILE_LOCATION, |
| 292 INVALID_STRING_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE, |
| 272 INVALID_SYMBOL, | 293 INVALID_SYMBOL, |
| 273 INVALID_SYNC_MODIFIER, | 294 INVALID_SYNC_MODIFIER, |
| 274 INVALID_TYPE_VARIABLE_BOUND, | 295 INVALID_TYPE_VARIABLE_BOUND, |
| 275 INVALID_UNNAMED_CONSTRUCTOR_NAME, | 296 INVALID_UNNAMED_CONSTRUCTOR_NAME, |
| 276 INVALID_URI, | 297 INVALID_URI, |
| 277 INVALID_USE_OF_SUPER, | 298 INVALID_USE_OF_SUPER, |
| 278 LIBRARY_NAME_MISMATCH, | 299 LIBRARY_NAME_MISMATCH, |
| 279 LIBRARY_NOT_FOUND, | 300 LIBRARY_NOT_FOUND, |
| 280 LIBRARY_NOT_SUPPORTED, | 301 LIBRARY_NOT_SUPPORTED, |
| 281 LIBRARY_TAG_MUST_BE_FIRST, | 302 LIBRARY_TAG_MUST_BE_FIRST, |
| (...skipping 2887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3169 library test.main; | 3190 library test.main; |
| 3170 part 'part.dart'; | 3191 part 'part.dart'; |
| 3171 export 'dart:core'; | 3192 export 'dart:core'; |
| 3172 main() {} | 3193 main() {} |
| 3173 """, | 3194 """, |
| 3174 'part.dart': """ | 3195 'part.dart': """ |
| 3175 part of test.main; | 3196 part of test.main; |
| 3176 """, | 3197 """, |
| 3177 }]), | 3198 }]), |
| 3178 | 3199 |
| 3200 MessageKind.INVALID_CONSTANT_CONDITIONAL_TYPE: |
| 3201 const MessageTemplate(MessageKind.INVALID_CONSTANT_CONDITIONAL_TYPE, |
| 3202 "`#{constant}` of type '#{type}' is not a valid constant condition. " |
| 3203 "Must be a value of type 'bool'."), |
| 3204 |
| 3205 MessageKind.INVALID_CONSTANT_INTERPOLATION_TYPE: |
| 3206 const MessageTemplate(MessageKind.INVALID_CONSTANT_INTERPOLATION_TYPE, |
| 3207 "`#{constant}` of type '#{type}' is not valid in constant string " |
| 3208 "interpolation. Must be a value of type 'bool', 'int', 'double', " |
| 3209 "or 'String'."), |
| 3210 |
| 3211 MessageKind.INVALID_CONSTANT_BINARY_PRIMITIVE_TYPE: |
| 3212 const MessageTemplate(MessageKind.INVALID_CONSTANT_BINARY_PRIMITIVE_TYPE
, |
| 3213 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3214 "constant binary #{operator} expression. Must be a value of type " |
| 3215 "'bool', 'int', 'double', 'String', or 'Null'."), |
| 3216 |
| 3217 MessageKind.INVALID_CONSTANT_STRING_ADD_TYPE: |
| 3218 const MessageTemplate(MessageKind.INVALID_CONSTANT_STRING_ADD_TYPE, |
| 3219 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3220 "constant binary + expression on 'String'. Must be a value of type " |
| 3221 "'String'."), |
| 3222 |
| 3223 MessageKind.INVALID_CONSTANT_NUM_ADD_TYPE: |
| 3224 const MessageTemplate(MessageKind.INVALID_CONSTANT_NUM_ADD_TYPE, |
| 3225 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3226 "constant binary + expression on 'num'. Must be a value of type " |
| 3227 "'int' or 'double'."), |
| 3228 |
| 3229 MessageKind.INVALID_CONSTANT_ADD_TYPES: |
| 3230 const MessageTemplate(MessageKind.INVALID_CONSTANT_ADD_TYPES, |
| 3231 "`#{leftConstant}` of type '#{leftType}' and " |
| 3232 "`#{rightConstant}` of type '#{rightType}' are not valid operands " |
| 3233 "of a constant binary + expression. Must both be either of " |
| 3234 "type 'String', or of types 'int' or 'double'."), |
| 3235 |
| 3236 MessageKind.INVALID_CONSTANT_BINARY_NUM_TYPE: |
| 3237 const MessageTemplate(MessageKind.INVALID_CONSTANT_BINARY_NUM_TYPE, |
| 3238 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3239 "constant binary #{operator} expression. Must be a value of type " |
| 3240 "'int' or 'double'."), |
| 3241 |
| 3242 MessageKind.INVALID_CONSTANT_BINARY_INT_TYPE: |
| 3243 const MessageTemplate(MessageKind.INVALID_CONSTANT_BINARY_INT_TYPE, |
| 3244 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3245 "constant binary #{operator} expression. Must be a value of type " |
| 3246 "'int'."), |
| 3247 |
| 3248 MessageKind.INVALID_CONSTANT_NOT_TYPE: |
| 3249 const MessageTemplate(MessageKind.INVALID_CONSTANT_NOT_TYPE, |
| 3250 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3251 "constant unary #{operator} expression. Must be a value of type " |
| 3252 "'bool'."), |
| 3253 |
| 3254 MessageKind.INVALID_CONSTANT_NEGATE_TYPE: |
| 3255 const MessageTemplate(MessageKind.INVALID_CONSTANT_NEGATE_TYPE, |
| 3256 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3257 "constant unary #{operator} expression. Must be a value of type " |
| 3258 "'int' or 'double'."), |
| 3259 |
| 3260 MessageKind.INVALID_CONSTANT_COMPLEMENT_TYPE: |
| 3261 const MessageTemplate(MessageKind.INVALID_CONSTANT_COMPLEMENT_TYPE, |
| 3262 "`#{constant}` of type '#{type}' is not a valid operand of a " |
| 3263 "constant unary #{operator} expression. Must be a value of type " |
| 3264 "'int'."), |
| 3265 |
| 3266 MessageKind.INVALID_CONSTANT_INDEX: |
| 3267 const MessageTemplate(MessageKind.INVALID_CONSTANT_INDEX, |
| 3268 "Index expressions are not allowed in constant expressions."), |
| 3269 |
| 3270 MessageKind.INVALID_CONSTANT_IF_NULL: |
| 3271 const MessageTemplate(MessageKind.INVALID_CONSTANT_IF_NULL, |
| 3272 "If null expressions are not allowed in constant expressions."), |
| 3273 |
| 3274 MessageKind.INVALID_FROM_ENVIRONMENT_NAME_TYPE: |
| 3275 const MessageTemplate(MessageKind.INVALID_FROM_ENVIRONMENT_NAME_TYPE, |
| 3276 "`#{constant}` of type '#{type}' is not a valid environment name " |
| 3277 "constant. Must be a value of type 'String'."), |
| 3278 |
| 3279 MessageKind.INVALID_BOOL_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE: |
| 3280 const MessageTemplate( |
| 3281 MessageKind.INVALID_BOOL_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE, |
| 3282 "`#{constant}` of type '#{type}' is not a valid " |
| 3283 "`bool.fromEnvironment` default value constant. " |
| 3284 "Must be a value of type 'bool' or `null`."), |
| 3285 |
| 3286 MessageKind.INVALID_INT_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE: |
| 3287 const MessageTemplate( |
| 3288 MessageKind.INVALID_INT_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE, |
| 3289 "`#{constant}` of type '#{type}' is not a valid " |
| 3290 "`int.fromEnvironment` default value constant. " |
| 3291 "Must be a value of type 'int' or `null`."), |
| 3292 |
| 3293 MessageKind.INVALID_STRING_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE: |
| 3294 const MessageTemplate( |
| 3295 MessageKind.INVALID_STRING_FROM_ENVIRONMENT_DEFAULT_VALUE_TYPE, |
| 3296 "`#{constant}` of type '#{type}' is not a valid " |
| 3297 "`String.fromEnvironment` default value constant. " |
| 3298 "Must be a value of type 'String' or `null`."), |
| 3299 |
| 3300 MessageKind.INVALID_LOGICAL_AND_OPERAND_TYPE: |
| 3301 const MessageTemplate(MessageKind.INVALID_LOGICAL_AND_OPERAND_TYPE, |
| 3302 "`#{constant}` of type '#{type}' is not a valid logical and operand. " |
| 3303 "Must be a value of type 'bool'."), |
| 3304 |
| 3305 MessageKind.INVALID_LOGICAL_OR_OPERAND_TYPE: |
| 3306 const MessageTemplate(MessageKind.INVALID_LOGICAL_OR_OPERAND_TYPE, |
| 3307 "`#{constant}` of type '#{type}' is not a valid logical and operand. " |
| 3308 "Must be a value of type 'bool'."), |
| 3309 |
| 3310 |
| 3179 ////////////////////////////////////////////////////////////////////////////// | 3311 ////////////////////////////////////////////////////////////////////////////// |
| 3180 // Patch errors start. | 3312 // Patch errors start. |
| 3181 ////////////////////////////////////////////////////////////////////////////// | 3313 ////////////////////////////////////////////////////////////////////////////// |
| 3182 | 3314 |
| 3183 MessageKind.PATCH_RETURN_TYPE_MISMATCH: | 3315 MessageKind.PATCH_RETURN_TYPE_MISMATCH: |
| 3184 const MessageTemplate(MessageKind.PATCH_RETURN_TYPE_MISMATCH, | 3316 const MessageTemplate(MessageKind.PATCH_RETURN_TYPE_MISMATCH, |
| 3185 "Patch return type '#{patchReturnType}' does not match " | 3317 "Patch return type '#{patchReturnType}' does not match " |
| 3186 "'#{originReturnType}' on origin method '#{methodName}'."), | 3318 "'#{originReturnType}' on origin method '#{methodName}'."), |
| 3187 | 3319 |
| 3188 MessageKind.PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH: | 3320 MessageKind.PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH: |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3457 } | 3589 } |
| 3458 | 3590 |
| 3459 int get hashCode => throw new UnsupportedError('Message.hashCode'); | 3591 int get hashCode => throw new UnsupportedError('Message.hashCode'); |
| 3460 | 3592 |
| 3461 static String convertToString(value) { | 3593 static String convertToString(value) { |
| 3462 if (value is ErrorToken) { | 3594 if (value is ErrorToken) { |
| 3463 // Shouldn't happen. | 3595 // Shouldn't happen. |
| 3464 return value.assertionMessage; | 3596 return value.assertionMessage; |
| 3465 } else if (value is Token) { | 3597 } else if (value is Token) { |
| 3466 value = value.value; | 3598 value = value.value; |
| 3599 } else if (value is ConstantExpression) { |
| 3600 value = value.getText(); |
| 3467 } | 3601 } |
| 3468 return '$value'; | 3602 return '$value'; |
| 3469 } | 3603 } |
| 3470 } | 3604 } |
| OLD | NEW |