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 Details

    • SemanticResult

      public SemanticResult(Optional<SemanticModel> model, List<SemanticError> errors)
      Creates an instance of a SemanticResult record class.
      Parameters:
      model - the value for the model record component
      errors - the value for the errors record component
  • Method Details

    • hasErrors

      public boolean hasErrors()
      Returns true if any Severity.ERROR-level diagnostics were collected.
    • hasDiagnostics

      public boolean hasDiagnostics()
      Returns true if any diagnostics were collected (errors or warnings).
    • hasModel

      public boolean hasModel()
      Returns true if a model is present.
    • isFullyValid

      public boolean isFullyValid()
      Returns true if analysis completed with no diagnostics and a full model.
    • success

      public static SemanticResult success(SemanticModel model)
      Creates a fully-successful result: model present, no diagnostics.
      Parameters:
      model - the completed semantic model; must not be null
      Returns:
      a successful result
    • failure

      public static SemanticResult failure(List<SemanticError> errors)
      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

      public static SemanticResult partial(SemanticModel model, List<SemanticError> errors)
      Creates a partial result: a best-effort model together with the errors found during analysis.
      Parameters:
      model - the partial semantic model; must not be null
      errors - the collected diagnostics; must not be null
      Returns:
      a partial result
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • model

      public Optional<SemanticModel> model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • errors

      public List<SemanticError> errors()
      Returns the value of the errors record component.
      Returns:
      the value of the errors record component