alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (FrontEnds.scala)

This example Scala source code file (FrontEnds.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Scala source code examples by using tags.

All credit for the original source code belongs to scala-lang.org; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Scala tags/keywords

boolean, frontends, nothing, position, string, unit

The FrontEnds.scala Scala example source code

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 labeled 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
}

Other Scala source code examples

Here is a short list of links related to this Scala FrontEnds.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.