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

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

Issue 2965393002: Use FastaMessage instead of String. Part 1. (Closed)
Patch Set: 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..ec1b56d8a11b62fa07423cdcd1532777a9b19e66 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 FastaMessage;
+
+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(FastaMessage message) {
+ if (hideWarnings) return;
+ print(deprecated_format(message.uri, message.charOffset,
+ colorWarning("Warning: ${message.message}")));
+ if (warningsAreFatal) {
+ if (isVerbose) print(StackTrace.current);
+ throw new deprecated_InputError(message.uri, message.charOffset,
+ "Compilation aborted due to fatal warnings.");
+ }
+}
+
+void nit(FastaMessage message) {
+ if (hideNits) return;
+ print(deprecated_format(
+ message.uri, message.charOffset, colorNit("Nit: ${message.message}")));
+ if (nitsAreFatal) {
+ if (isVerbose) print(StackTrace.current);
+ throw new deprecated_InputError(message.uri, message.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")));

Powered by Google App Engine
This is Rietveld 408576698