Class NodeIndex
java.lang.Object
io.github.douira.glsl_transformer.ast.query.NodeIndex
- Direct Known Subclasses:
SuperclassNodeIndex
Indexes nodes based on their ASTNode subclass and enables fast queries for
nodes by type. Only the exact class is added to the index which means
querying for the superclass Expression returns no results. Use
SuperclassNodeIndex to index nodes by the chain of their
superclasses.
Unchecked casts are used but they are safe because each set in the map only
has the right types of nodes.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMethod used internally to add a node to the index.Returns a set of all nodes with the given type.get(T node) Returns the set of nodes that have the same class as the given node.<T extends ASTNode>
TReturns an arbitrary node with the given type.<T extends ASTNode>
TgetOne(T node) Returns an arbitrary node that has the same class as the given node.Returns a stream of all nodes with the given type.booleanChecks if the index contains a node of the given type.booleanChecks if the index contains any nodes of the given type.booleanChecks if the index contains the given node itself.voidMerges the given node index into this one.voidMethod used internally to remove a node from the index.static NodeIndexstatic NodeIndex
-
Field Details
-
index
-
bucketConstructor
-
-
Constructor Details
-
NodeIndex
-
NodeIndex
public NodeIndex()
-
-
Method Details
-
withHashSetBuckets
-
withLinkedHashSetBuckets
-
add
Method used internally to add a node to the index. This is only meant to be called byRoot. -
remove
Method used internally to remove a node from the index. This is only meant to be called byRoot. -
get
Returns a set of all nodes with the given type.- Type Parameters:
T- the type of the class- Parameters:
clazz- the class of nodes to return- Returns:
- a set of nodes with the given type
-
getStream
Returns a stream of all nodes with the given type.- Type Parameters:
T- the type of the class- Parameters:
clazz- the class of nodes to return- Returns:
- a stream of nodes with the given type
-
getOne
Returns an arbitrary node with the given type.- Type Parameters:
T- the type of the class- Parameters:
clazz- the class of the node to return- Returns:
- an arbitrary node with the given type
-
has
Checks if the index contains any nodes of the given type.- Parameters:
clazz- the class of the nodes to check for- Returns:
- true if the index contains any nodes of the given type
-
get
Returns the set of nodes that have the same class as the given node.- Type Parameters:
T- The type of the nodes- Parameters:
node- The node to get the set of- Returns:
- The set of nodes that have the same class as the given node
-
getOne
Returns an arbitrary node that has the same class as the given node.- Type Parameters:
T- The type of the node- Parameters:
node- The node to get a node from the index for- Returns:
- An arbitrary node that has the same class as the given node
-
has
Checks if the index contains a node of the given type.- Parameters:
node- the node to check for- Returns:
- true if the index contains the node
-
hasExact
Checks if the index contains the given node itself.- Parameters:
node- the node to check for- Returns:
- true if the index contains the node
-
merge
Merges the given node index into this one.- Parameters:
other- the other index to merge
-