| 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 72f2a09531509fd199417e874bed6d499a02fb49..1a2fb648ba28bff65eaeeb9023916b9a8a8cb8da 100644
|
| --- a/pkg/front_end/lib/src/fasta/messages.dart
|
| +++ b/pkg/front_end/lib/src/fasta/messages.dart
|
| @@ -4,91 +4,28 @@
|
|
|
| library fasta.messages;
|
|
|
| -import 'dart:io' show exitCode;
|
| -
|
| import 'package:kernel/ast.dart' show Library, Location, Program, TreeNode;
|
|
|
| import 'util/relativize.dart' show relativizeUri;
|
|
|
| import 'compiler_context.dart' show CompilerContext;
|
|
|
| -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;
|
| +import 'severity.dart' show Severity;
|
|
|
| -bool get nitsAreFatal => CompilerContext.current.options.nitsAreFatal;
|
| -
|
| -bool get warningsAreFatal => CompilerContext.current.options.warningsAreFatal;
|
| +export 'fasta_codes.dart';
|
|
|
| bool get isVerbose => CompilerContext.current.options.verbose;
|
|
|
| -bool get hideNits => !isVerbose;
|
| -
|
| -bool get setExitCodeOnProblem {
|
| - return CompilerContext.current.options.setExitCodeOnProblem;
|
| -}
|
| -
|
| 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.");
|
| - }
|
| + CompilerContext.current
|
| + .report(message.withLocation(uri, charOffset), Severity.warning);
|
| }
|
|
|
| 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.");
|
| - }
|
| -}
|
| -
|
| -String colorWarning(String message) {
|
| - // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on
|
| - // Windows.
|
| - return magenta(message);
|
| -}
|
| -
|
| -String colorNit(String message) {
|
| - // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on
|
| - // Windows.
|
| - return cyan(message);
|
| -}
|
| -
|
| -String deprecated_format(Uri uri, int charOffset, String message) {
|
| - if (setExitCodeOnProblem) {
|
| - exitCode = 1;
|
| - }
|
| - if (uri != null) {
|
| - String path = relativizeUri(uri);
|
| - Location location = charOffset == -1 ? null : getLocation(path, charOffset);
|
| - String sourceLine = getSourceLine(location);
|
| - if (sourceLine == null) {
|
| - sourceLine = "";
|
| - } else {
|
| - sourceLine = "\n$sourceLine\n"
|
| - "${' ' * (location.column - 1)}^";
|
| - }
|
| - String position = location?.toString() ?? path;
|
| - return "$position: $message$sourceLine";
|
| - } else {
|
| - return message;
|
| - }
|
| + CompilerContext.current
|
| + .report(message.withLocation(uri, charOffset), Severity.nit);
|
| }
|
|
|
| Location getLocation(String path, int charOffset) {
|
|
|