Package proguard.util
Class CallGraphWalker
java.lang.Object
proguard.util.CallGraphWalker
Generic utilities to traverse the call graph.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<MethodSignature>getPredecessors(CallGraph callGraph, MethodSignature start, int maxDepth) Inverse ofgetSuccessors(CallGraph, MethodSignature, int): Starting from one particular method, all methods that can transitively reach it are collected in a single set.static Set<MethodSignature>getSuccessors(CallGraph callGraph, MethodSignature start, int maxDepth) Starting from one particular method, all methods that are transitively reachable are collected in a single set.static NodepredecessorPathsAccept(CallGraph callGraph, MethodSignature start, Predicate<Node> handler, int maxDepth) Interactively explore the incoming call graph (breadth-first) of a specific method.static NodesuccessorPathsAccept(CallGraph callGraph, MethodSignature start, Predicate<Node> handler, int maxDepth) Interactively explore the outgoing call graph (breadth-first) of a specific method.
-
Constructor Details
-
CallGraphWalker
public CallGraphWalker()
-
-
Method Details
-
getSuccessors
public static Set<MethodSignature> getSuccessors(CallGraph callGraph, MethodSignature start, int maxDepth) Starting from one particular method, all methods that are transitively reachable are collected in a single set. The exploration stops after no more reachable methods have been found, or the reachable call graph exceeds maxDepth.- Parameters:
callGraph- TheCallGraphto use as the basis for this exploration.start- The method that is to be used as the exploration root.maxDepth- Only explore to this depth. -1 explores the full depth.- Returns:
- A set of all transitively reachable methods.
-
getPredecessors
public static Set<MethodSignature> getPredecessors(CallGraph callGraph, MethodSignature start, int maxDepth) Inverse ofgetSuccessors(CallGraph, MethodSignature, int): Starting from one particular method, all methods that can transitively reach it are collected in a single set. The exploration stops after no more incoming methods have been found, or the inversely-reachable call graph exceeds maxDepth.- Parameters:
callGraph- TheCallGraphto use as the basis for this exploration.start- The method that is to be used as the exploration root.maxDepth- Only explore to this depth. -1 explores the full depth.- Returns:
- A set of all methods that can transitively reach the root.
-
successorPathsAccept
public static Node successorPathsAccept(CallGraph callGraph, MethodSignature start, Predicate<Node> handler, int maxDepth) Interactively explore the outgoing call graph (breadth-first) of a specific method.If you are only interested in which methods are reachable from a start method, but do not care about the individual paths that make this possible, you should use
getSuccessors(CallGraph, MethodSignature, int)instead.- Parameters:
callGraph- TheCallGraphto use as the basis of this exploration.start- The method that is to be used as the exploration root.handler- The callback function that is invoked for newly visited paths. If this returns false, this specific path is not explored any further, without marking it asNode.isTruncated.maxDepth- Only explore to this depth. -1 explores the full depth.- Returns:
- The
Noderepresenting the start method and all its successors.
-
predecessorPathsAccept
public static Node predecessorPathsAccept(CallGraph callGraph, MethodSignature start, Predicate<Node> handler, int maxDepth) Interactively explore the incoming call graph (breadth-first) of a specific method.If you are only interested in which methods are reaching a specific method, but do not care about the individual paths that make this possible, you should use
getPredecessors(CallGraph, MethodSignature, int)instead.- Parameters:
callGraph- TheCallGraphto use as the basis of this exploration.start- The method that is to be used as the exploration root.handler- The callback function that is invoked for newly visited paths. If this returns false, this specific path is not explored any further, without marking it asNode.isTruncated.maxDepth- Only explore to this depth. -1 explores the full depth.- Returns:
- The
Noderepresenting the start method and all its predecessors.
-