public final class Diagnostic extends Object
DiagnosticCode, centrally-derived DiagnosticCategory, a
Severity, the rendered user-visible message,
an optional primary SourceSpan, immutable secondary locations, and
optional exact vendor-error enrichment.
API status: read-only diagnostic getters are part of Join Analysis Consumption Profile v1. Consumers should treat code, category, severity, locations, and exact vendor enrichment as structured data. Construction and copy helpers are producer-oriented APIs.
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 | Class and Description |
|---|---|
static class |
Diagnostic.Builder
Mutable construction helper; the built
Diagnostic is immutable. |
| Modifier and Type | Method and Description |
|---|---|
static Diagnostic.Builder |
builder(DiagnosticCode code,
Severity severity,
String message)
Begin constructing a diagnostic.
|
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. |
DiagnosticCategory |
getCategory() |
DiagnosticCode |
getCode() |
String |
getMessage() |
List<RelatedLocation> |
getRelatedLocations() |
Severity |
getSeverity() |
SourceSpan |
getSpan() |
VendorError |
getVendorError() |
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. |
static Diagnostic |
warnWithSpan(DiagnosticCode code,
String message,
SourceSpan span)
Construct a
WARN-severity diagnostic with an
explicit (already-computed) source span — the WARN counterpart of
errorWithSpan(gudusoft.gsqlparser.ir.semantic.DiagnosticCode, java.lang.String, gudusoft.gsqlparser.ir.semantic.SourceSpan). |
Diagnostic |
withRelatedLocation(RelatedLocation location)
Return an immutable copy with one additional secondary location.
|
Diagnostic |
withSpan(SourceSpan newSpan)
Return an immutable copy with a new primary span.
|
Diagnostic |
withVendorError(VendorError error)
Return an immutable copy enriched with an exact vendor error.
|
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 static Diagnostic warnWithSpan(DiagnosticCode code, String message, SourceSpan span)
WARN-severity diagnostic with an
explicit (already-computed) source span — the WARN counterpart of
errorWithSpan(gudusoft.gsqlparser.ir.semantic.DiagnosticCode, java.lang.String, gudusoft.gsqlparser.ir.semantic.SourceSpan). Used by the builder's degrade paths, which
derive the span from a fallback anchor rather than a single node.public static Diagnostic.Builder builder(DiagnosticCode code, Severity severity, String message)
DiagnosticCode.public DiagnosticCode getCode()
public DiagnosticCategory getCategory()
public Severity getSeverity()
public String getMessage()
public SourceSpan getSpan()
null when no AST anchor was available.public List<RelatedLocation> getRelatedLocations()
null.public VendorError getVendorError()
null when not available.public Diagnostic withSpan(SourceSpan newSpan)
public Diagnostic withRelatedLocation(RelatedLocation location)
public Diagnostic withVendorError(VendorError error)