Class AbstractAST

java.lang.Object
org.variantsync.boosting.parsing.AbstractAST
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JavaAST, LineAST

public abstract class AbstractAST extends Object implements Serializable
AbstractAST is an abstract class representing an Abstract Syntax Tree (AST) with a root node and a set of AST nodes. This class provides constructors to create an AST with optional filtering based on file types.
See Also:
  • Field Details

  • Constructor Details

    • AbstractAST

      public AbstractAST(String... fileTypes)
      Constructs an AbstractAST with no filtering based on file types.
      Parameters:
      fileTypes - an array of file types to filter the AST nodes by
    • AbstractAST

      public AbstractAST(File rootFile, String... fileTypes)
      Constructs an AbstractAST with filtering based on file types.
      Parameters:
      rootFile - the root file to build the AST from
      fileTypes - an array of file types to filter the AST nodes by
    • AbstractAST

      public AbstractAST(ASTNode root, CustomHashSet<ASTNode> astNodes, String... fileTypes)
      Constructs an AbstractAST with a specified root node, set of AST nodes, and optional filtering based on file types.
      Parameters:
      root - the root node of the AST
      astNodes - the set of AST nodes in the tree
      fileTypes - an array of file types to filter the AST nodes by
  • Method Details

    • collectAstNodes

      public CustomHashSet<ASTNode> collectAstNodes()
      Collects all nodes (except the root node) of the Abstract Syntax Tree (AST) in one set to simplify their access.
      Returns:
      a set containing all nodes of the AST
    • visitFileContent

      protected abstract void visitFileContent(ASTNode fileNode, File fileToVisit)
      This method is responsible for visiting the content of a file represented by the given ASTNode and File object.
      Parameters:
      fileNode - The ASTNode representing the content of the file to be visited.
      fileToVisit - The File object representing the file to be visited.
      Throws:
      NullPointerException - if either fileNode or fileToVisit is null.
      IllegalArgumentException - if the fileToVisit does not exist or is not a valid file.
    • getRoot

      public ASTNode getRoot()
      Returns the root node of the Abstract Syntax Tree (AST).
      Returns:
      the root node of the AST
    • getAstNodes

      public CustomHashSet<ASTNode> getAstNodes()
      Returns a set of all AST nodes in the tree.
      Returns:
      a set of all AST nodes