Class ASTValidator
- java.lang.Object
-
- com.tonic.analysis.source.ast.validation.ASTValidator
-
public final class ASTValidator extends Object
Coordinator that runs structural, type, and null validation strategies over an AST tree.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classASTValidator.ValidationResultImmutable outcome of a validation run, holding all reported issues.
-
Constructor Summary
Constructors Constructor Description ASTValidator()Creates a validator with all validation strategies enabled.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ASTValidatorstopOnFirstError(boolean enabled)Stops validating after the first strategy that reports an error-severity issue.ASTValidator.ValidationResultvalidate(ASTNode root)Runs the enabled validation strategies over a tree.ASTValidatorwithNullValidation(boolean enabled)Toggles null checks on required node fields.ASTValidatorwithStructureValidation(boolean enabled)Toggles structural (parent-child consistency) validation.ASTValidatorwithTypeValidation(boolean enabled)Toggles type validation of expressions and declarations.
-
-
-
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
-
-