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 library dart2js.messages; | 5 library dart2js.messages; |
6 | 6 |
7 import '../tokens/token.dart' show ErrorToken, Token; | 7 import '../tokens/token.dart' show ErrorToken, Token; |
8 | 8 |
9 import 'invariant.dart' show invariant; | 9 import 'invariant.dart' show invariant; |
10 import 'spannable.dart' show CURRENT_ELEMENT_SPANNABLE; | 10 import 'spannable.dart' show CURRENT_ELEMENT_SPANNABLE; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 INHERITED_IMPLICIT_GETTER, | 179 INHERITED_IMPLICIT_GETTER, |
180 INHERITED_METHOD, | 180 INHERITED_METHOD, |
181 INJECTED_PUBLIC_MEMBER, | 181 INJECTED_PUBLIC_MEMBER, |
182 INIT_STATIC_FIELD, | 182 INIT_STATIC_FIELD, |
183 INITIALIZING_FORMAL_NOT_ALLOWED, | 183 INITIALIZING_FORMAL_NOT_ALLOWED, |
184 INSTANCE_STATIC_SAME_NAME, | 184 INSTANCE_STATIC_SAME_NAME, |
185 INSTANCE_STATIC_SAME_NAME_CONT, | 185 INSTANCE_STATIC_SAME_NAME_CONT, |
186 INTERNAL_LIBRARY, | 186 INTERNAL_LIBRARY, |
187 INTERNAL_LIBRARY_FROM, | 187 INTERNAL_LIBRARY_FROM, |
188 INVALID_ARGUMENT_AFTER_NAMED, | 188 INVALID_ARGUMENT_AFTER_NAMED, |
| 189 INVALID_AWAIT, |
189 INVALID_AWAIT_FOR, | 190 INVALID_AWAIT_FOR, |
| 191 INVALID_AWAIT_FOR_IN, |
190 INVALID_BREAK, | 192 INVALID_BREAK, |
191 INVALID_CASE_DEFAULT, | 193 INVALID_CASE_DEFAULT, |
192 INVALID_CONSTRUCTOR_ARGUMENTS, | 194 INVALID_CONSTRUCTOR_ARGUMENTS, |
193 INVALID_CONSTRUCTOR_NAME, | 195 INVALID_CONSTRUCTOR_NAME, |
194 INVALID_CONTINUE, | 196 INVALID_CONTINUE, |
195 INVALID_FOR_IN, | 197 INVALID_FOR_IN, |
196 INVALID_INITIALIZER, | 198 INVALID_INITIALIZER, |
197 INVALID_METADATA, | 199 INVALID_METADATA, |
198 INVALID_METADATA_GENERIC, | 200 INVALID_METADATA_GENERIC, |
199 INVALID_OVERRIDDEN_FIELD, | 201 INVALID_OVERRIDDEN_FIELD, |
(...skipping 12 matching lines...) Expand all Loading... |
212 INVALID_PACKAGE_URI, | 214 INVALID_PACKAGE_URI, |
213 INVALID_PARAMETER, | 215 INVALID_PARAMETER, |
214 INVALID_RECEIVER_IN_INITIALIZER, | 216 INVALID_RECEIVER_IN_INITIALIZER, |
215 INVALID_SOURCE_FILE_LOCATION, | 217 INVALID_SOURCE_FILE_LOCATION, |
216 INVALID_SYMBOL, | 218 INVALID_SYMBOL, |
217 INVALID_SYNC_MODIFIER, | 219 INVALID_SYNC_MODIFIER, |
218 INVALID_TYPE_VARIABLE_BOUND, | 220 INVALID_TYPE_VARIABLE_BOUND, |
219 INVALID_UNNAMED_CONSTRUCTOR_NAME, | 221 INVALID_UNNAMED_CONSTRUCTOR_NAME, |
220 INVALID_URI, | 222 INVALID_URI, |
221 INVALID_USE_OF_SUPER, | 223 INVALID_USE_OF_SUPER, |
| 224 INVALID_YIELD, |
222 JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, | 225 JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, |
223 JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER, | 226 JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER, |
224 JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS, | 227 JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS, |
225 JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS, | 228 JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS, |
226 JS_PLACEHOLDER_CAPTURE, | 229 JS_PLACEHOLDER_CAPTURE, |
227 LIBRARY_NAME_MISMATCH, | 230 LIBRARY_NAME_MISMATCH, |
228 LIBRARY_NOT_FOUND, | 231 LIBRARY_NOT_FOUND, |
229 LIBRARY_NOT_SUPPORTED, | 232 LIBRARY_NOT_SUPPORTED, |
230 LIBRARY_TAG_MUST_BE_FIRST, | 233 LIBRARY_TAG_MUST_BE_FIRST, |
231 MAIN_NOT_A_FUNCTION, | 234 MAIN_NOT_A_FUNCTION, |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 MessageKind.INHERITED_METHOD: "INHERITED_METHOD", | 599 MessageKind.INHERITED_METHOD: "INHERITED_METHOD", |
597 MessageKind.INJECTED_PUBLIC_MEMBER: "INJECTED_PUBLIC_MEMBER", | 600 MessageKind.INJECTED_PUBLIC_MEMBER: "INJECTED_PUBLIC_MEMBER", |
598 MessageKind.INIT_STATIC_FIELD: "INIT_STATIC_FIELD", | 601 MessageKind.INIT_STATIC_FIELD: "INIT_STATIC_FIELD", |
599 MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED: | 602 MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED: |
600 "INITIALIZING_FORMAL_NOT_ALLOWED", | 603 "INITIALIZING_FORMAL_NOT_ALLOWED", |
601 MessageKind.INSTANCE_STATIC_SAME_NAME: "INSTANCE_STATIC_SAME_NAME", | 604 MessageKind.INSTANCE_STATIC_SAME_NAME: "INSTANCE_STATIC_SAME_NAME", |
602 MessageKind.INSTANCE_STATIC_SAME_NAME_CONT: "INSTANCE_STATIC_SAME_NAME_CONT", | 605 MessageKind.INSTANCE_STATIC_SAME_NAME_CONT: "INSTANCE_STATIC_SAME_NAME_CONT", |
603 MessageKind.INTERNAL_LIBRARY: "INTERNAL_LIBRARY", | 606 MessageKind.INTERNAL_LIBRARY: "INTERNAL_LIBRARY", |
604 MessageKind.INTERNAL_LIBRARY_FROM: "INTERNAL_LIBRARY_FROM", | 607 MessageKind.INTERNAL_LIBRARY_FROM: "INTERNAL_LIBRARY_FROM", |
605 MessageKind.INVALID_ARGUMENT_AFTER_NAMED: "INVALID_ARGUMENT_AFTER_NAMED", | 608 MessageKind.INVALID_ARGUMENT_AFTER_NAMED: "INVALID_ARGUMENT_AFTER_NAMED", |
| 609 MessageKind.INVALID_AWAIT: "INVALID_AWAIT", |
606 MessageKind.INVALID_AWAIT_FOR: "INVALID_AWAIT_FOR", | 610 MessageKind.INVALID_AWAIT_FOR: "INVALID_AWAIT_FOR", |
| 611 MessageKind.INVALID_AWAIT_FOR_IN: "INVALID_AWAIT_FOR_IN", |
607 MessageKind.INVALID_BREAK: "INVALID_BREAK", | 612 MessageKind.INVALID_BREAK: "INVALID_BREAK", |
608 MessageKind.INVALID_CASE_DEFAULT: "INVALID_CASE_DEFAULT", | 613 MessageKind.INVALID_CASE_DEFAULT: "INVALID_CASE_DEFAULT", |
609 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS: "INVALID_CONSTRUCTOR_ARGUMENTS", | 614 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS: "INVALID_CONSTRUCTOR_ARGUMENTS", |
610 MessageKind.INVALID_CONSTRUCTOR_NAME: "INVALID_CONSTRUCTOR_NAME", | 615 MessageKind.INVALID_CONSTRUCTOR_NAME: "INVALID_CONSTRUCTOR_NAME", |
611 MessageKind.INVALID_CONTINUE: "INVALID_CONTINUE", | 616 MessageKind.INVALID_CONTINUE: "INVALID_CONTINUE", |
612 MessageKind.INVALID_FOR_IN: "INVALID_FOR_IN", | 617 MessageKind.INVALID_FOR_IN: "INVALID_FOR_IN", |
613 MessageKind.INVALID_INITIALIZER: "INVALID_INITIALIZER", | 618 MessageKind.INVALID_INITIALIZER: "INVALID_INITIALIZER", |
614 MessageKind.INVALID_METADATA: "INVALID_METADATA", | 619 MessageKind.INVALID_METADATA: "INVALID_METADATA", |
615 MessageKind.INVALID_METADATA_GENERIC: "INVALID_METADATA_GENERIC", | 620 MessageKind.INVALID_METADATA_GENERIC: "INVALID_METADATA_GENERIC", |
616 MessageKind.INVALID_OVERRIDDEN_FIELD: "INVALID_OVERRIDDEN_FIELD", | 621 MessageKind.INVALID_OVERRIDDEN_FIELD: "INVALID_OVERRIDDEN_FIELD", |
(...skipping 18 matching lines...) Expand all Loading... |
635 MessageKind.INVALID_RECEIVER_IN_INITIALIZER: | 640 MessageKind.INVALID_RECEIVER_IN_INITIALIZER: |
636 "INVALID_RECEIVER_IN_INITIALIZER", | 641 "INVALID_RECEIVER_IN_INITIALIZER", |
637 MessageKind.INVALID_SOURCE_FILE_LOCATION: "INVALID_SOURCE_FILE_LOCATION", | 642 MessageKind.INVALID_SOURCE_FILE_LOCATION: "INVALID_SOURCE_FILE_LOCATION", |
638 MessageKind.INVALID_SYMBOL: "INVALID_SYMBOL", | 643 MessageKind.INVALID_SYMBOL: "INVALID_SYMBOL", |
639 MessageKind.INVALID_SYNC_MODIFIER: "INVALID_SYNC_MODIFIER", | 644 MessageKind.INVALID_SYNC_MODIFIER: "INVALID_SYNC_MODIFIER", |
640 MessageKind.INVALID_TYPE_VARIABLE_BOUND: "INVALID_TYPE_VARIABLE_BOUND", | 645 MessageKind.INVALID_TYPE_VARIABLE_BOUND: "INVALID_TYPE_VARIABLE_BOUND", |
641 MessageKind.INVALID_UNNAMED_CONSTRUCTOR_NAME: | 646 MessageKind.INVALID_UNNAMED_CONSTRUCTOR_NAME: |
642 "INVALID_UNNAMED_CONSTRUCTOR_NAME", | 647 "INVALID_UNNAMED_CONSTRUCTOR_NAME", |
643 MessageKind.INVALID_URI: "INVALID_URI", | 648 MessageKind.INVALID_URI: "INVALID_URI", |
644 MessageKind.INVALID_USE_OF_SUPER: "INVALID_USE_OF_SUPER", | 649 MessageKind.INVALID_USE_OF_SUPER: "INVALID_USE_OF_SUPER", |
| 650 MessageKind.INVALID_YIELD: "INVALID_YIELD", |
645 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS: | 651 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS: |
646 "JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS", | 652 "JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS", |
647 MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER: | 653 MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER: |
648 "JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER", | 654 "JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER", |
649 MessageKind.JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS: | 655 MessageKind.JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS: |
650 "JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS", | 656 "JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS", |
651 MessageKind.JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS: | 657 MessageKind.JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS: |
652 "JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS", | 658 "JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS", |
653 MessageKind.JS_PLACEHOLDER_CAPTURE: "JS_PLACEHOLDER_CAPTURE", | 659 MessageKind.JS_PLACEHOLDER_CAPTURE: "JS_PLACEHOLDER_CAPTURE", |
654 MessageKind.LIBRARY_NAME_MISMATCH: "LIBRARY_NAME_MISMATCH", | 660 MessageKind.LIBRARY_NAME_MISMATCH: "LIBRARY_NAME_MISMATCH", |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 static String get MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING => | 910 static String get MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING => |
905 dart2js_messages.MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING; | 911 dart2js_messages.MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING; |
906 | 912 |
907 static String get DISALLOWED_LIBRARY_IMPORT_PADDING => | 913 static String get DISALLOWED_LIBRARY_IMPORT_PADDING => |
908 dart2js_messages.DISALLOWED_LIBRARY_IMPORT_PADDING; | 914 dart2js_messages.DISALLOWED_LIBRARY_IMPORT_PADDING; |
909 | 915 |
910 static Map<MessageKind, MessageTemplate> _constructMessageTemplates() { | 916 static Map<MessageKind, MessageTemplate> _constructMessageTemplates() { |
911 Map<MessageKind, MessageTemplate> result = <MessageKind, MessageTemplate>{}; | 917 Map<MessageKind, MessageTemplate> result = <MessageKind, MessageTemplate>{}; |
912 for (MessageKind kind in MessageKind.values) { | 918 for (MessageKind kind in MessageKind.values) { |
913 String name = _KIND_TO_STRING_MAP[kind]; | 919 String name = _KIND_TO_STRING_MAP[kind]; |
| 920 if (name == null) { |
| 921 throw new ArgumentError("No mapping for $kind in _KIND_TO_STRING_MAP"); |
| 922 } |
914 Map data = | 923 Map data = |
915 shared_messages.MESSAGES[name] ?? dart2js_messages.MESSAGES[name]; | 924 shared_messages.MESSAGES[name] ?? dart2js_messages.MESSAGES[name]; |
916 if (data == null) throw new ArgumentError.value(name); | 925 if (data == null) throw new ArgumentError.value(name); |
917 | 926 |
918 String id = data['id']; | 927 String id = data['id']; |
919 String template = data['template']; | 928 String template = data['template']; |
920 String howToFix = data['howToFix']; | 929 String howToFix = data['howToFix']; |
921 List examples = data['examples']; | 930 List examples = data['examples']; |
922 List<String> options = data['options'] ?? const <String>[]; | 931 List<String> options = data['options'] ?? const <String>[]; |
923 result[kind] = | 932 result[kind] = |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 static String convertToString(value) { | 987 static String convertToString(value) { |
979 if (value is ErrorToken) { | 988 if (value is ErrorToken) { |
980 // Shouldn't happen. | 989 // Shouldn't happen. |
981 return value.assertionMessage; | 990 return value.assertionMessage; |
982 } else if (value is Token) { | 991 } else if (value is Token) { |
983 value = value.value; | 992 value = value.value; |
984 } | 993 } |
985 return '$value'; | 994 return '$value'; |
986 } | 995 } |
987 } | 996 } |
OLD | NEW |