Package com.google.javascript.jscomp
Class AstValidator
- java.lang.Object
-
- com.google.javascript.jscomp.AstValidator
-
- All Implemented Interfaces:
CompilerPass
public final class AstValidator extends java.lang.Object implements CompilerPass
This class walks the AST and validates that the structure is correct.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAstValidator.ViolationHandlerViolation handler
-
Constructor Summary
Constructors Constructor Description AstValidator(AbstractCompiler compiler)AstValidator(AbstractCompiler compiler, boolean validateScriptFeatures)AstValidator(AbstractCompiler compiler, AstValidator.ViolationHandler handler, boolean validateScriptFeatures)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidprocess(Node externs, Node root)Process the JS with root node root.AstValidatorsetTypeValidationEnabled(boolean isEnabled)Enable or disable validation of type information.voidvalidateCodeRoot(Node n)voidvalidateExpression(Node n)voidvalidateModuleContents(Node n)voidvalidateRoot(Node n)voidvalidateScript(Node n)voidvalidateStatement(Node n)voidvalidateStatement(Node n, boolean isAmbient)Validates a statement node and its children.voidvalidateStatements(Node n)
-
-
-
Constructor Detail
-
AstValidator
public AstValidator(AbstractCompiler compiler, AstValidator.ViolationHandler handler, boolean validateScriptFeatures)
-
AstValidator
public AstValidator(AbstractCompiler compiler)
-
AstValidator
public AstValidator(AbstractCompiler compiler, boolean validateScriptFeatures)
-
-
Method Detail
-
setTypeValidationEnabled
public AstValidator setTypeValidationEnabled(boolean isEnabled)
Enable or disable validation of type information. TODO(b/74537281): Currently only expressions are checked for type information. Do we need to do more?
-
process
public void process(Node externs, Node root)
Description copied from interface:CompilerPassProcess the JS with root node root. Can modify the contents of each Node tree- Specified by:
processin interfaceCompilerPass- Parameters:
externs- Top of external JS treeroot- Top of JS tree
-
validateRoot
public void validateRoot(Node n)
-
validateCodeRoot
public void validateCodeRoot(Node n)
-
validateScript
public void validateScript(Node n)
-
validateModuleContents
public void validateModuleContents(Node n)
-
validateStatements
public void validateStatements(Node n)
-
validateStatement
public void validateStatement(Node n)
-
validateStatement
public void validateStatement(Node n, boolean isAmbient)
Validates a statement node and its children.- Parameters:
isAmbient- whether this statement comes from TS ambient `declare [...]`
-
validateExpression
public void validateExpression(Node n)
-
-