summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/macros/FrontEnds.scala
blob: 8ad41382a8051cec1fd288465647816571f3a3ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package scala
package reflect
package macros

/**
 * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
 *
 *  A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that
 *  provides facilities to communicate with the compiler's front end
 *  (emit warnings, errors and other sorts of messages).
 */
trait FrontEnds {
  self: blackbox.Context =>

  /** For sending a message which should not be labelled as a warning/error,
   *  but also shouldn't require -verbose to be visible.
   *  Use `enclosingPosition` if you're in doubt what position to pass to `pos`.
   */
  def echo(pos: Position, msg: String): Unit

  /** Emits an informational message, suppressed unless `-verbose` or `force=true`.
   *  Use `enclosingPosition` if you're in doubt what position to pass to `pos`.
   */
  def info(pos: Position, msg: String, force: Boolean): Unit

  /** Does the compilation session have any warnings?
   */
  def hasWarnings: Boolean

  /** Emits a warning.
   *  Use `enclosingPosition` if you're in doubt what position to pass to `pos`.
   */
  def warning(pos: Position, msg: String): Unit

  /** Does the compilation session have any errors?
   */
  def hasErrors: Boolean

  /** Emits a compilation error.
   *  Use `enclosingPosition` if you're in doubt what position to pass to `pos`.
   */
  def error(pos: Position, msg: String): Unit

  /** Abruptly terminates current macro expansion leaving a note about what happened.
   *  Use `enclosingPosition` if you're in doubt what position to pass to `pos`.
   */
  def abort(pos: Position, msg: String): Nothing
}