Skip to content

Conversation

@rcosta358
Copy link
Collaborator

@rcosta358 rcosta358 commented Nov 5, 2025

This PR adds a class for each type of error, instead of mapping all errors to strings. Warnings were also introduced. This change will make diagnostics more structured, extensible and easier to manage, which the VS Code extension will benefit from.

Changes

  • Each error and warning has its own class with their respective information and toString implementation
    • LJError
      • RefinementError - when a refinement is violated
      • StateRefinementError - when a state refinement is violated
      • NotFoundError - when an element is not found
      • SyntaxError - when the syntax is invalid
      • GhostInvocationError - when a ghost call as wrong arguments
      • StateConflictError - when states are disjoint
      • IllegalConstructorTransitionError - when state refinement in constructor has from transition
      • InvalidRefinementError - when refinement is semantically invalid (e.g., not a boolean expression)
      • CustomError - any other error
    • LJWarning
      • ExternalClassNotFoundWarning - when class in external refinement is not found
      • ExternalMethodNotFoundWarning - when method in class of external refinement is not found
  • Renamed the errors folder to diagnostics

Next Steps

  • Integrate these new diagnostic classes throughout the codebase
  • LJDiagnostics will replace the ErrorEmitter
  • ErrorHandler will no longer be needed

Copy link
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and the next steps seem great - thanks for splitting the change in multiple PRs!
Lets just add some javadoc to the multiple types of errors you created so everyone can understand when to use each type of error

import spoon.reflect.cu.SourcePosition;
import spoon.reflect.declaration.CtElement;

// base class for all LiquidJava errors
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can have this comment as proper javadoc


import spoon.reflect.declaration.CtElement;

// e.g. when a variable used in a refinement is not found
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, lets specify when we are supposed to use each type of error like what you had in the PR description

@rcosta358
Copy link
Collaborator Author

Will do!

@rcosta358 rcosta358 merged commit 31b657d into liquid-java:main Nov 5, 2025
1 check passed
@rcosta358 rcosta358 deleted the diagnostics branch November 8, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants