Record Class Diagnostic
java.lang.Object
java.lang.Record
ca.mcscert.jpipe.compiler.model.Diagnostic
- Record Components:
level- severity of the diagnostic.code- stable kebab-case identifier, ornullwhen absent.source- path to the file that triggered it.line- 1-based source line, or0if unknown.column- 0-based column offset, or0if unknown.message- human-readable description, without the code.
public record Diagnostic(Diagnostic.Level level, String code, String source, int line, int column, String message)
extends Record
A single diagnostic message produced during compilation.
line and column carry the source location when known; both
are 0 when no location is available (ANTLR lines are 1-based, so
0 is a safe sentinel).
code is a stable, bare kebab-case identifier such as
"unknown-model" (see DiagnosticCodes) or a validation rule
name coming from Violation.rule(). It is
null when the diagnostic has no code. The code is data, not
text: renderers decide how to display it (the human-readable report prefixes
it as "[code] ", the JSON report emits it as a separate field).
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSentinel value forlineandcolumnwhen no location is known. -
Constructor Summary
ConstructorsConstructorDescriptionDiagnostic(Diagnostic.Level level, String code, String source, int line, int column, String message) Creates an instance of aDiagnosticrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.intcolumn()Returns the value of thecolumnrecord component.final booleanIndicates whether some other object is "equal to" this one.static Diagnosticstatic Diagnosticstatic DiagnosticA non-fatal ERROR carrying both a code and a source location.static DiagnosticA non-fatal ERROR carrying a code but no source location.static Diagnosticstatic DiagnosticbooleanhasCode()True if this diagnostic carries a code.final inthashCode()Returns a hash code value for this object.booleanTrue if this diagnostic carries a known source location.booleanisError()True for ERROR and FATAL.booleanisFatal()True only for FATAL.level()Returns the value of thelevelrecord component.intline()Returns the value of thelinerecord component.message()Returns the value of themessagerecord component.source()Returns the value of thesourcerecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
UNKNOWN_LOCATION
public static final int UNKNOWN_LOCATIONSentinel value forlineandcolumnwhen no location is known.- See Also:
-
-
Constructor Details
-
Diagnostic
public Diagnostic(Diagnostic.Level level, String code, String source, int line, int column, String message) Creates an instance of aDiagnosticrecord class.- Parameters:
level- the value for thelevelrecord componentcode- the value for thecoderecord componentsource- the value for thesourcerecord componentline- the value for thelinerecord componentcolumn- the value for thecolumnrecord componentmessage- the value for themessagerecord component
-
-
Method Details
-
hasLocation
public boolean hasLocation()True if this diagnostic carries a known source location. -
hasCode
public boolean hasCode()True if this diagnostic carries a code. -
error
-
fatal
-
error
A non-fatal ERROR carrying a code but no source location.- Parameters:
code- stable kebab-case identifier, ornull.source- path to the file that triggered it.message- human-readable description, without the code.- Returns:
- the diagnostic.
-
error
-
fatal
-
error
A non-fatal ERROR carrying both a code and a source location.- Parameters:
code- stable kebab-case identifier, ornull.source- path to the file that triggered it.line- 1-based source line.column- 0-based column offset.message- human-readable description, without the code.- Returns:
- the diagnostic.
-
isError
public boolean isError()True for ERROR and FATAL. -
isFatal
public boolean isFatal()True only for FATAL. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
level
-
code
-
source
-
line
-
column
-
message
-