Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: pkg/compiler/lib/src/diagnostics/messages.dart

Issue 2904783002: Use failedAt in more places (misc) (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /// The messages in this file should follow the [Guide for Writing 5 /// The messages in this file should follow the [Guide for Writing
6 /// Diagnostics](../../../../front_end/lib/src/fasta/diagnostics.md). 6 /// Diagnostics](../../../../front_end/lib/src/fasta/diagnostics.md).
7 /// 7 ///
8 /// Other things to keep in mind: 8 /// Other things to keep in mind:
9 /// 9 ///
10 /// An INFO message should always be preceded by a non-INFO message, and the 10 /// An INFO message should always be preceded by a non-INFO message, and the
11 /// INFO messages are additional details about the preceding non-INFO 11 /// INFO messages are additional details about the preceding non-INFO
12 /// message. For example, consider duplicated elements. First report a WARNING 12 /// message. For example, consider duplicated elements. First report a WARNING
13 /// or ERROR about the duplicated element, and then report an INFO about the 13 /// or ERROR about the duplicated element, and then report an INFO about the
14 /// location of the existing element. 14 /// location of the existing element.
15 library dart2js.messages; 15 library dart2js.messages;
16 16
17 import 'package:front_end/src/fasta/scanner.dart' show ErrorToken, Token; 17 import 'package:front_end/src/fasta/scanner.dart' show ErrorToken, Token;
18 import 'generated/shared_messages.dart' as shared_messages; 18 import 'generated/shared_messages.dart' as shared_messages;
19 import 'invariant.dart' show invariant; 19 import 'invariant.dart' show failedAt;
20 import 'spannable.dart' show CURRENT_ELEMENT_SPANNABLE; 20 import 'spannable.dart' show CURRENT_ELEMENT_SPANNABLE;
21 21
22 const DONT_KNOW_HOW_TO_FIX = "Computer says no!"; 22 const DONT_KNOW_HOW_TO_FIX = "Computer says no!";
23 23
24 /// Keys for the [MessageTemplate]s. 24 /// Keys for the [MessageTemplate]s.
25 enum MessageKind { 25 enum MessageKind {
26 ABSTRACT_CLASS_INSTANTIATION, 26 ABSTRACT_CLASS_INSTANTIATION,
27 ABSTRACT_GETTER, 27 ABSTRACT_GETTER,
28 ABSTRACT_METHOD, 28 ABSTRACT_METHOD,
29 ABSTRACT_SETTER, 29 ABSTRACT_SETTER,
(...skipping 3725 matching lines...) Expand 10 before | Expand all | Expand 10 after
3755 } 3755 }
3756 3756
3757 MessageKind get kind => template.kind; 3757 MessageKind get kind => template.kind;
3758 3758
3759 String computeMessage() { 3759 String computeMessage() {
3760 if (message == null) { 3760 if (message == null) {
3761 message = template.template; 3761 message = template.template;
3762 arguments.forEach((key, value) { 3762 arguments.forEach((key, value) {
3763 message = message.replaceAll('#{${key}}', convertToString(value)); 3763 message = message.replaceAll('#{${key}}', convertToString(value));
3764 }); 3764 });
3765 assert(invariant( 3765 assert(
3766 CURRENT_ELEMENT_SPANNABLE,
3767 kind == MessageKind.GENERIC || 3766 kind == MessageKind.GENERIC ||
3768 !message.contains(new RegExp(r'#\{.+\}')), 3767 !message.contains(new RegExp(r'#\{.+\}')),
3769 message: 'Missing arguments in error message: "$message"')); 3768 failedAt(CURRENT_ELEMENT_SPANNABLE,
3769 'Missing arguments in error message: "$message"'));
3770 if (!terse && template.hasHowToFix) { 3770 if (!terse && template.hasHowToFix) {
3771 String howToFix = template.howToFix; 3771 String howToFix = template.howToFix;
3772 arguments.forEach((key, value) { 3772 arguments.forEach((key, value) {
3773 howToFix = howToFix.replaceAll('#{${key}}', convertToString(value)); 3773 howToFix = howToFix.replaceAll('#{${key}}', convertToString(value));
3774 }); 3774 });
3775 message = '$message\n$howToFix'; 3775 message = '$message\n$howToFix';
3776 } 3776 }
3777 } 3777 }
3778 return message; 3778 return message;
3779 } 3779 }
(...skipping 12 matching lines...) Expand all
3792 static String convertToString(value) { 3792 static String convertToString(value) {
3793 if (value is ErrorToken) { 3793 if (value is ErrorToken) {
3794 // Shouldn't happen. 3794 // Shouldn't happen.
3795 return value.assertionMessage; 3795 return value.assertionMessage;
3796 } else if (value is Token) { 3796 } else if (value is Token) {
3797 value = value.lexeme; 3797 value = value.lexeme;
3798 } 3798 }
3799 return '$value'; 3799 return '$value';
3800 } 3800 }
3801 } 3801 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/invariant.dart ('k') | pkg/compiler/lib/src/library_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698