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

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

Issue 2977013002: Report messages instead of just printing. (Closed)
Patch Set: Update expectations. 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/deprecated_problems.dart
diff --git a/pkg/front_end/lib/src/fasta/deprecated_problems.dart b/pkg/front_end/lib/src/fasta/deprecated_problems.dart
index 90897d9eeae9ec76da1194649b12facc80bcceed..6c6fad3be63bf3b3203d08941950c75d300c55a8 100644
--- a/pkg/front_end/lib/src/fasta/deprecated_problems.dart
+++ b/pkg/front_end/lib/src/fasta/deprecated_problems.dart
@@ -11,9 +11,11 @@ import 'dart:convert' show JSON;
import 'dart:io'
show ContentType, HttpClient, HttpClientRequest, SocketException, stderr;
-import 'colors.dart' show red;
+import 'command_line_reporting.dart' show isFatal;
-import 'messages.dart' show errorsAreFatal, deprecated_format, isVerbose;
+import 'messages.dart' show LocatedMessage, isVerbose, templateUnspecified;
+
+import 'severity.dart' show Severity;
const String defaultServerAddress = "http://127.0.0.1:59410/";
@@ -36,34 +38,12 @@ Uri firstSourceUri;
/// handled correctly, the user will never see a stack trace that says "user
/// error".
dynamic deprecated_inputError(Uri uri, int charOffset, Object error) {
- if (errorsAreFatal && isVerbose) {
+ if (isFatal(Severity.error) && isVerbose) {
print(StackTrace.current);
}
throw new deprecated_InputError(uri, charOffset, error);
}
-String deprecated_printUnexpected(Uri uri, int charOffset, String message) {
- String formattedMessage =
- deprecated_formatUnexpected(uri, charOffset, message);
- if (errorsAreFatal) {
- print(formattedMessage);
- if (isVerbose) print(StackTrace.current);
- throw new deprecated_InputError(uri, charOffset, message);
- }
- print(formattedMessage);
- return formattedMessage;
-}
-
-String deprecated_formatUnexpected(Uri uri, int charOffset, String message) {
- return deprecated_format(uri, charOffset, colorError("Error: $message"));
-}
-
-String colorError(String message) {
- // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on
- // Windows.
- return red(message);
-}
-
class deprecated_InputError {
final Uri uri;
@@ -76,8 +56,16 @@ class deprecated_InputError {
toString() => "deprecated_InputError: $error";
- String deprecated_format() =>
- deprecated_formatUnexpected(uri, charOffset, safeToString(error));
+ /// Converts [error] to a [LocatedMessage] using [templateUnspecified]. Using
+ /// [templateUnspecified] is deprecated behavior.
+ ///
+ /// Static method to discourage use and requiring call-sites to include the
+ /// text `deprecated_`.
+ static LocatedMessage toMessage(deprecated_InputError error) {
+ return templateUnspecified
+ .withArguments(safeToString(error.error))
+ .withLocation(error.uri, error.charOffset);
+ }
}
class Crash {

Powered by Google App Engine
This is Rietveld 408576698