Class 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.
    • 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: CompilerPass
        Process the JS with root node root. Can modify the contents of each Node tree
        Specified by:
        process in interface CompilerPass
        Parameters:
        externs - Top of external JS tree
        root - 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)