Package org.codehaus.groovy.control.messages

# Class LocatedMessage

java.lang.Object
org.codehaus.groovy.control.messages.Message
org.codehaus.groovy.control.messages.SimpleMessage
org.codehaus.groovy.control.messages.LocatedMessage

Direct Known Subclasses:
  `WarningMessage`

public class LocatedMessage extends SimpleMessage
A base class for compilation messages.

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.control.messages.SimpleMessage

  `data, message, owner`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LocatedMessage(String message, Object data, CSTNode context, SourceUnit source)`
  Creates a located message with supplemental data.
  `LocatedMessage(String message, CSTNode context, SourceUnit source)`
  Creates a located message with the supplied text.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CSTNode`
  `getContext()`
  Returns the CST node that identifies the message location.
  `Diagnostic`
  `toDiagnostic()`
  Returns a format-neutral view of this message: its text and, when known, the source and position it applies to.
  `void`
  `write(PrintWriter writer, Janitor janitor)`
  Writes the message together with source-location information.

  ### Methods inherited from class org.codehaus.groovy.control.messages.SimpleMessage

  `getMessage`

  ### Methods inherited from class org.codehaus.groovy.control.messages.Message

  `create, create, create, write`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LocatedMessage

    public LocatedMessage(String message, CSTNode context, SourceUnit source)
    Creates a located message with the supplied text.
    Parameters:
      `message` - the message text
      `context` - the source location
      `source` - the owning source unit

  - ### LocatedMessage

    public LocatedMessage(String message, Object data, CSTNode context, SourceUnit source)
    Creates a located message with supplemental data.
    Parameters:
      `message` - the message text
      `data` - supplemental message data
      `context` - the source location
      `source` - the owning source unit

- ## Method Details

  - ### getContext

    public CSTNode getContext()
    Returns the CST node that identifies the message location.
    Returns:
      the source location node

  - ### toDiagnostic

    public Diagnostic toDiagnostic()
    Description copied from class: `Message`
    Returns a format-neutral view of this message: its text and, when known, the source and position it applies to. Layouts other than the full one are rendered from this rather than from the message classes (GROOVY-12312).

    The default captures the output of `Message.write(PrintWriter)` as the text, with no file or position, so that a subclass which does not override this still renders in every format.

    Overrides:
      `toDiagnostic` in class `SimpleMessage`
    Returns:
      the diagnostic view, never `null`

  - ### write

    public void write(PrintWriter writer, Janitor janitor)
    Writes the message together with source-location information.
    Overrides:
      `write` in class `SimpleMessage`
    Parameters:
      `writer` - the destination writer
      `janitor` - the cleanup helper for temporary source access