public class CodeDiagnostic

  1. Object
  2. CodeDiagnostic

A diagnostic (error / warning / information) shown in a CodeEditor as a squiggly underline over a source range, a marker in the line-number gutter and a tooltip carrying the message.

Positions are 1-based: line 1 is the first line and column 1 is the first character of a line, matching the convention used by most compilers and language servers.

Fields

public static final String ERROR = "error"Severity for a problem that should block / is an error.
public static final String WARNING = "warning"Severity for a non-blocking warning.
public static final String INFO = "info"Severity for purely informational hints.

Constructors

public CodeDiagnostic(int line, int column, String message)Creates a single-position diagnostic that underlines from the given column to the end of the token / line.
public CodeDiagnostic(int line, int column, int endLine, int endColumn, String message)Creates a diagnostic spanning an explicit range.

Methods

public int getLine()The 1-based start line.
public int getColumn()The 1-based start column.
public int getEndLine()The 1-based end line.
public int getEndColumn()The 1-based end column (exclusive).
public String getSeverity()The severity, one of #ERROR, #WARNING or #INFO.
public CodeDiagnostic setSeverity(String severity)Sets the severity.
public String getMessage()The message shown in the tooltip.

Inherited methods

Field details

ERROR

public static final String ERROR = "error"
Severity for a problem that should block / is an error.

WARNING

public static final String WARNING = "warning"
Severity for a non-blocking warning.

INFO

public static final String INFO = "info"
Severity for purely informational hints.

Constructor details

CodeDiagnostic

public CodeDiagnostic(int line, int column, String message)
Creates a single-position diagnostic that underlines from the given column to the end of the token / line.

Parameters

line int
the 1-based line
column int
the 1-based start column
message String
the human readable message

CodeDiagnostic

public CodeDiagnostic(int line, int column, int endLine, int endColumn, String message)
Creates a diagnostic spanning an explicit range.

Parameters

line int
the 1-based start line
column int
the 1-based start column
endLine int
the 1-based end line
endColumn int
the 1-based end column (exclusive)
message String
the human readable message

Method details

getLine

public int getLine()
The 1-based start line.

getColumn

public int getColumn()
The 1-based start column.

getEndLine

public int getEndLine()
The 1-based end line.

getEndColumn

public int getEndColumn()
The 1-based end column (exclusive).

getSeverity

public String getSeverity()
The severity, one of #ERROR, #WARNING or #INFO.

setSeverity

public CodeDiagnostic setSeverity(String severity)
Sets the severity. Returns this for chaining.

Parameters

severity String
one of #ERROR, #WARNING, #INFO

getMessage

public String getMessage()
The message shown in the tooltip.