Package com.darkcollective.relix.embed
Record Class Diagnostic
java.lang.Object
java.lang.Record
com.darkcollective.relix.embed.Diagnostic
- Record Components:
message- what is wrong, in the analyser's own wordslocation- where, when the analyser knewseverity- whether this stops the query or merely remarks on it
public record Diagnostic(String message, Optional<SourceLocation> location, Severity severity)
extends Record
One thing wrong with a query, as data rather than as an exception.
What Relix.validate returns. The rest of the API throws, which is right when
the author of the query is the author of the program; a caller building a query from
user input needs to render the problem instead, and cannot do that from a stack trace.
It carries a Severity because not everything the analyser reports is fatal.
A caller that treats every diagnostic as a refusal would stop on a warning, which is
the analyser saying "this is odd" rather than "this cannot run".
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDiagnostic(String message, Optional<SourceLocation> location, Severity severity) Validates the components. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisError()Returns whether this diagnostic stops the query from running.location()Returns the value of thelocationrecord component.message()Returns the value of themessagerecord component.static Diagnosticof(SemanticError error) The diagnostic for a semantic error.static DiagnosticA diagnostic with no location — an error nothing could attribute to a position.static Diagnosticof(String message, SourceLocation location) A diagnostic at a known position — a syntax error the frontend could place.severity()Returns the value of theseverityrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
Diagnostic
Validates the components.- Since:
- 1.0
-
-
Method Details
-
isError
public boolean isError()Returns whether this diagnostic stops the query from running.- Returns:
- whether this diagnostic stops the query from running
- Since:
- 1.0
-
of
A diagnostic with no location — an error nothing could attribute to a position. A syntax error is not normally one of those: seeof(String, SourceLocation).- Parameters:
message- what is wrong- Returns:
- the diagnostic
- Since:
- 1.0
-
of
A diagnostic at a known position — a syntax error the frontend could place.- Parameters:
message- what is wronglocation- where; must not be null- Returns:
- the diagnostic
- Since:
- 1.0
-
of
The diagnostic for a semantic error.- Parameters:
error- the analyser's error; must not be null- Returns:
- the diagnostic
- Since:
- 1.0
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
location
Returns the value of thelocationrecord component.- Returns:
- the value of the
locationrecord component
-
severity
Returns the value of theseverityrecord component.- Returns:
- the value of the
severityrecord component
-