dart-sdk/pkg/front_end/lib/compilation_message.dart
Sigmund Cherem 1aa139bc94 Unifying compiler context
Changes in this CL:
 - Updated CompilerContext:
    - it now contains a ProcessedOptions object

    - it no longer depends on CompilerCommandLine/CommandLine

    - it delegates to ProcessedOptions.report so all error reporting
      goes to one single place.

    - use "withContext" term instead of "withGlobalOptions" to be
      more clear about the intent

 - Changes in public API
    - added more options that correspond to flags in command-line
      fasta tools

    - default onError is different: we now use the
      command_line_reporting report, which prints and throws
      on fatal messages, but doesn't throw eagerly on all messages
      as before.

    - introduced "printMessages" option: make it easy to have
      both onError + command_line_reporting  (kernel-service.dart
      is the main use case at this time, other ideas welcome!)

    - renamed CompilationError to CompilationMessage

 - Other changes

    - set exit code is done on report, not on format
    - fixed corner cases not covered in previous CL
        - error reporting with missing-main needs to happen with
          a context
        - missing error cases when inferring .packages and input
          URIs are not file:* URIs

Ideas for follow up after this CL:
 - combine ProcessedOptions and CompilerContext into a single class
   (or extend one from the other)
 - switch onError to a stream

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2982093003 .
2017-07-18 17:02:59 -07:00

39 lines
1.3 KiB
Dart

// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// Defines the API for the front end to communicate information about
/// compilation messages to clients.
library front_end.compilation_message;
import 'package:source_span/source_span.dart' show SourceSpan;
import 'package:front_end/src/fasta/severity.dart' show Severity;
export 'package:front_end/src/fasta/severity.dart' show Severity;
/// A single message, typically an error, reported during compilation, and
/// information about where it occurred and suggestions on how to fix it.
///
/// Not intended to be implemented or extended by clients.
abstract class CompilationMessage {
/// A text description of the problem.
String get message;
/// A suggestion for how to fix the problem. May be `null`.
String get tip;
/// The source span where the error occurred.
SourceSpan get span;
/// The severity level of the error.
Severity get severity;
/// The corresponding analyzer error code, or null if there is no
/// corresponding message in analyzer.
String get analyzerCode;
/// The corresponding dart2js error code, or null if there is no corresponding
/// message in dart2js.
String get dart2jsCode;
}