Package de.fraunhofer.aisec.cpg.helpers
Class SubgraphWalker.ScopedWalker
java.lang.Object
de.fraunhofer.aisec.cpg.helpers.SubgraphWalker.ScopedWalker
- Enclosing class:
- SubgraphWalker
public static class SubgraphWalker.ScopedWalker
extends java.lang.Object
Handles declaration scope monitoring for iterative traversals. If this is not required, use
SubgraphWalker.IterativeGraphWalker for less overhead.
Declaration scopes are similar to ScopeManager
scopes: ValueDeclarations located inside a scope (i.e. are children of the scope root)
are visible to any children of the scope root. Scopes can be layered, where declarations from
parent scopes are visible to the children but not the other way around.
-
Constructor Summary
Constructors Constructor Description ScopedWalker(LanguageFrontend lang) -
Method Summary
Modifier and Type Method Description voidclearCallbacks()voidcollectDeclarations(de.fraunhofer.aisec.cpg.graph.Node current)java.util.List<ValueDeclaration>getAllDeclarationsForScope(de.fraunhofer.aisec.cpg.graph.Node scope)@Nullable RecordDeclarationgetCurrentClass()java.util.Optional<? extends ValueDeclaration>getDeclarationForScope(de.fraunhofer.aisec.cpg.graph.Node scope, java.util.function.Predicate<ValueDeclaration> predicate)voiditerate(de.fraunhofer.aisec.cpg.graph.Node root)WrapsSubgraphWalker.IterativeGraphWalkerto handle declaration scopes.voidregisterHandler(TriConsumer<RecordDeclaration,de.fraunhofer.aisec.cpg.graph.Node,de.fraunhofer.aisec.cpg.graph.Node> handler)voidregisterHandler(java.util.function.BiConsumer<de.fraunhofer.aisec.cpg.graph.Node,RecordDeclaration> handler)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ScopedWalker
-
-
Method Details
-
clearCallbacks
public void clearCallbacks() -
registerHandler
public void registerHandler(TriConsumer<RecordDeclaration,de.fraunhofer.aisec.cpg.graph.Node,de.fraunhofer.aisec.cpg.graph.Node> handler) -
registerHandler
public void registerHandler(java.util.function.BiConsumer<de.fraunhofer.aisec.cpg.graph.Node,RecordDeclaration> handler) -
iterate
public void iterate(de.fraunhofer.aisec.cpg.graph.Node root)WrapsSubgraphWalker.IterativeGraphWalkerto handle declaration scopes.- Parameters:
root- The node where AST descent is started
-
getCurrentClass
-
collectDeclarations
public void collectDeclarations(de.fraunhofer.aisec.cpg.graph.Node current) -
getAllDeclarationsForScope
public java.util.List<ValueDeclaration> getAllDeclarationsForScope(de.fraunhofer.aisec.cpg.graph.Node scope) -
getDeclarationForScope
public java.util.Optional<? extends ValueDeclaration> getDeclarationForScope(de.fraunhofer.aisec.cpg.graph.Node scope, java.util.function.Predicate<ValueDeclaration> predicate)
-