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 Details

  • 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)
      Wraps SubgraphWalker.IterativeGraphWalker to handle declaration scopes.
      Parameters:
      root - The node where AST descent is started
    • getCurrentClass

      public @Nullable RecordDeclaration 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)