Package org.variantsync.boosting.parsing
Class AbstractAST
java.lang.Object
org.variantsync.boosting.parsing.AbstractAST
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAST
(File rootFile, String... fileTypes) Constructs an AbstractAST with filtering based on file types.AbstractAST
(String... fileTypes) Constructs an AbstractAST with no filtering based on file types.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. -
Method Summary
Modifier and TypeMethodDescriptionCollects all nodes (except the root node) of the Abstract Syntax Tree (AST) in one set to simplify their access.Returns a set of all AST nodes in the tree.getRoot()
Returns the root node of the Abstract Syntax Tree (AST).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.
-
Field Details
-
root
-
astNodes
-
fileTypes
-
-
Constructor Details
-
AbstractAST
Constructs an AbstractAST with no filtering based on file types.- Parameters:
fileTypes
- an array of file types to filter the AST nodes by
-
AbstractAST
Constructs an AbstractAST with filtering based on file types.- Parameters:
rootFile
- the root file to build the AST fromfileTypes
- an array of file types to filter the AST nodes by
-
AbstractAST
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 ASTastNodes
- the set of AST nodes in the treefileTypes
- an array of file types to filter the AST nodes by
-
-
Method Details
-
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
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
Returns the root node of the Abstract Syntax Tree (AST).- Returns:
- the root node of the AST
-
getAstNodes
Returns a set of all AST nodes in the tree.- Returns:
- a set of all AST nodes
-