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

Unified Diff: pkg/front_end/lib/src/fasta/messages.dart

Issue 2965393002: Use FastaMessage instead of String. Part 1. (Closed)
Patch Set: Add type variable to Code. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/messages.dart
diff --git a/pkg/front_end/lib/src/fasta/messages.dart b/pkg/front_end/lib/src/fasta/messages.dart
index 938fe4403193adc7f98edce1af9554b2931f6781..5f3f7675370c1275bfff116bfe65e58df400d0d9 100644
--- a/pkg/front_end/lib/src/fasta/messages.dart
+++ b/pkg/front_end/lib/src/fasta/messages.dart
@@ -14,6 +14,10 @@ import 'deprecated_problems.dart' show deprecated_InputError;
import 'colors.dart' show cyan, magenta;
+import 'fasta_codes.dart' show Message;
+
+export 'fasta_codes.dart';
+
const bool hideWarnings = false;
bool get errorsAreFatal => CompilerContext.current.options.errorsAreFatal;
@@ -26,6 +30,28 @@ bool get isVerbose => CompilerContext.current.options.verbose;
bool get hideNits => !isVerbose;
+void warning(Message message, int charOffset, Uri uri) {
+ if (hideWarnings) return;
+ print(deprecated_format(
+ uri, charOffset, colorWarning("Warning: ${message.message}")));
+ if (warningsAreFatal) {
+ if (isVerbose) print(StackTrace.current);
+ throw new deprecated_InputError(
+ uri, charOffset, "Compilation aborted due to fatal warnings.");
+ }
+}
+
+void nit(Message message, int charOffset, Uri uri) {
+ if (hideNits) return;
+ print(
+ deprecated_format(uri, charOffset, colorNit("Nit: ${message.message}")));
+ if (nitsAreFatal) {
+ if (isVerbose) print(StackTrace.current);
+ throw new deprecated_InputError(
+ uri, charOffset, "Compilation aborted due to fatal nits.");
+ }
+}
+
void deprecated_warning(Uri uri, int charOffset, String message) {
if (hideWarnings) return;
print(deprecated_format(uri, charOffset, colorWarning("Warning: $message")));
« no previous file with comments | « pkg/front_end/lib/src/fasta/loader.dart ('k') | pkg/front_end/lib/src/fasta/parser/class_member_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698