Record Class SemanticResult
java.lang.Object
java.lang.Record
com.darkcollective.relix.semantic.internal.SemanticResult
- Record Components:
model- the semantic model, if analysis produced one (possibly partial)errors- all diagnostics collected; empty on full success
public record SemanticResult(Optional<SemanticModel> model, List<SemanticError> errors)
extends Record
The outcome of a semantic analysis run.
A result always carries both a (possibly absent) model and a (possibly empty) list of errors. This allows callers to receive both a partially-valid model and the errors that were discovered — useful for tooling that wants to show diagnostics while still providing completion or navigation over the parts of the script that analysed cleanly.
Three factory methods cover the common cases:
SemanticResult.success(model) // no errors, full model SemanticResult.failure(errors) // errors only, no model SemanticResult.partial(model, errors) // errors + best-effort model
-
Constructor Summary
ConstructorsConstructorDescriptionSemanticResult(Optional<SemanticModel> model, List<SemanticError> errors) Creates an instance of aSemanticResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.errors()Returns the value of theerrorsrecord component.static SemanticResultfailure(List<SemanticError> errors) Creates a failure result: no model, one or more errors.booleanReturnstrueif any diagnostics were collected (errors or warnings).booleanReturnstrueif anySeverity.ERROR-level diagnostics were collected.final inthashCode()Returns a hash code value for this object.booleanhasModel()Returnstrueif a model is present.booleanReturnstrueif analysis completed with no diagnostics and a full model.model()Returns the value of themodelrecord component.static SemanticResultpartial(SemanticModel model, List<SemanticError> errors) Creates a partial result: a best-effort model together with the errors found during analysis.static SemanticResultsuccess(SemanticModel model) Creates a fully-successful result: model present, no diagnostics.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
hasErrors
public boolean hasErrors()Returnstrueif anySeverity.ERROR-level diagnostics were collected. -
hasDiagnostics
public boolean hasDiagnostics()Returnstrueif any diagnostics were collected (errors or warnings). -
hasModel
public boolean hasModel()Returnstrueif a model is present. -
isFullyValid
public boolean isFullyValid()Returnstrueif analysis completed with no diagnostics and a full model. -
success
Creates a fully-successful result: model present, no diagnostics.- Parameters:
model- the completed semantic model; must not be null- Returns:
- a successful result
-
failure
Creates a failure result: no model, one or more errors.- Parameters:
errors- the collected diagnostics; must not be null or empty- Returns:
- a failure result
-
partial
Creates a partial result: a best-effort model together with the errors found during analysis.- Parameters:
model- the partial semantic model; must not be nullerrors- the collected diagnostics; must not be null- Returns:
- a partial result
-
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). -
model
Returns the value of themodelrecord component.- Returns:
- the value of the
modelrecord component
-
errors
Returns the value of theerrorsrecord component.- Returns:
- the value of the
errorsrecord component
-