Class ASTValidator


  • public final class ASTValidator
    extends Object
    Coordinator that runs structural, type, and null validation strategies over an AST tree.
    • Constructor Detail

      • ASTValidator

        public ASTValidator()
        Creates a validator with all validation strategies enabled.
    • Method Detail

      • withStructureValidation

        public ASTValidator withStructureValidation​(boolean enabled)
        Toggles structural (parent-child consistency) validation.
        Parameters:
        enabled - true to run structural checks
        Returns:
        this validator
      • withTypeValidation

        public ASTValidator withTypeValidation​(boolean enabled)
        Toggles type validation of expressions and declarations.
        Parameters:
        enabled - true to run type checks
        Returns:
        this validator
      • withNullValidation

        public ASTValidator withNullValidation​(boolean enabled)
        Toggles null checks on required node fields.
        Parameters:
        enabled - true to run null checks
        Returns:
        this validator
      • stopOnFirstError

        public ASTValidator stopOnFirstError​(boolean enabled)
        Stops validating after the first strategy that reports an error-severity issue.
        Parameters:
        enabled - true to stop early
        Returns:
        this validator
      • validate

        public ASTValidator.ValidationResult validate​(ASTNode root)
        Runs the enabled validation strategies over a tree.
        Parameters:
        root - the tree to validate; may be null
        Returns:
        the combined result of all strategies that ran