public final class Diagnostic extends Object
DiagnosticCode, a Severity, the rendered
user-visible message, and an optional
SourceSpan pointing at the offending AST node.
Diagnostics are constructed via the error(gudusoft.gsqlparser.ir.semantic.DiagnosticCode, java.lang.String) factory
methods and wrapped in
SemanticIRBuilder.SemanticIRBuildException when the builder
cannot continue. External callers should pattern-match on
getCode() rather than parsing getMessage()
substrings — message text remains user-visible English and may
change without notice; the enum values are the public contract.
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
static Diagnostic |
error(DiagnosticCode code,
String message)
Construct an
ERROR-severity diagnostic
with no span anchor. |
static Diagnostic |
error(DiagnosticCode code,
String message,
TParseTreeNode anchor)
Construct an
ERROR-severity diagnostic
whose span is derived from anchor via
SourceSpan.of(TParseTreeNode). |
static Diagnostic |
errorWithSpan(DiagnosticCode code,
String message,
SourceSpan span)
Construct an
ERROR-severity diagnostic
with an explicit (already-computed) source span. |
DiagnosticCode |
getCode() |
String |
getMessage() |
Severity |
getSeverity() |
SourceSpan |
getSpan() |
int |
hashCode() |
String |
toString() |
static Diagnostic |
warn(DiagnosticCode code,
String message)
Slice 77 — construct a
WARN-severity
diagnostic with no span anchor. |
static Diagnostic |
warn(DiagnosticCode code,
String message,
TParseTreeNode anchor)
Slice 77 — construct a
WARN-severity
diagnostic whose span is derived from anchor. |
public static Diagnostic error(DiagnosticCode code, String message)
ERROR-severity diagnostic
with no span anchor.public static Diagnostic error(DiagnosticCode code, String message, TParseTreeNode anchor)
ERROR-severity diagnostic
whose span is derived from anchor via
SourceSpan.of(TParseTreeNode). Null-safe: when
anchor (or its boundary tokens) is null, the
resulting span is null.public static Diagnostic errorWithSpan(DiagnosticCode code, String message, SourceSpan span)
ERROR-severity diagnostic
with an explicit (already-computed) source span. Most callers
should prefer error(DiagnosticCode, String, TParseTreeNode)
which derives the span from an AST node.public static Diagnostic warn(DiagnosticCode code, String message)
WARN-severity
diagnostic with no span anchor. Warnings are advisory: the
analyzer continues, the IR is built, and
AnalysisResult.isSuccessful() still returns true.public static Diagnostic warn(DiagnosticCode code, String message, TParseTreeNode anchor)
WARN-severity
diagnostic whose span is derived from anchor.public DiagnosticCode getCode()
public Severity getSeverity()
public String getMessage()
public SourceSpan getSpan()
null when no AST anchor was available.