Class CPGIndex


  • public class CPGIndex
    extends Object
    Secondary lookup structure over CPG nodes, keyed by node type, method signature, call target, instruction class, and property key/value pairs.
    • Constructor Detail

      • CPGIndex

        public CPGIndex()
    • Method Detail

      • index

        public void index​(CPGNode node)
        Adds a node to every applicable index.
        Parameters:
        node - the node to index
      • reindex

        public void reindex​(CPGNode node)
        Removes and re-adds a node, refreshing stale index entries.
        Parameters:
        node - the node to reindex
      • remove

        public void remove​(CPGNode node)
        Removes a node from every applicable index.
        Parameters:
        node - the node to remove
      • getByType

        public Set<CPGNode> getByType​(CPGNodeType type)
        Looks up all nodes of a given node type.
        Parameters:
        type - the node type
        Returns:
        the indexed nodes, or an empty set
      • getMethod

        public MethodNode getMethod​(String owner,
                                    String name,
                                    String descriptor)
        Looks up a method node by its exact signature.
        Parameters:
        owner - the declaring class internal name
        name - the method name
        descriptor - the method descriptor
        Returns:
        the method node, or null if not indexed
      • getAllMethods

        public Set<MethodNode> getAllMethods()
        Returns:
        a copy of all indexed method nodes
      • getCallsTo

        public Set<CallSiteNode> getCallsTo​(String owner,
                                            String name,
                                            String descriptor)
        Looks up call sites targeting an exact method signature.
        Parameters:
        owner - the target class internal name
        name - the target method name
        descriptor - the target method descriptor
        Returns:
        the matching call sites, or an empty set
      • getCallsTo

        public Set<CallSiteNode> getCallsTo​(String owner,
                                            String name)
        Looks up call sites targeting a method name regardless of descriptor.
        Parameters:
        owner - the target class internal name
        name - the target method name
        Returns:
        the matching call sites across all overloads
      • getInstructionsOfType

        public Set<InstructionNode> getInstructionsOfType​(Class<? extends IRInstruction> type)
        Looks up instruction nodes wrapping a specific IR instruction class.
        Parameters:
        type - the IR instruction class
        Returns:
        the matching instruction nodes, or an empty set
      • getByProperty

        public Set<CPGNode> getByProperty​(String key,
                                          Object value)
        Looks up nodes carrying a property with the given key and value.
        Parameters:
        key - the property key
        value - the property value
        Returns:
        the matching nodes, or an empty set
      • getNodeCount

        public int getNodeCount()
        Returns:
        the total number of indexed nodes across all node types
      • getMethodCount

        public int getMethodCount()
        Returns:
        the number of indexed methods
      • clear

        public void clear()
        Empties every index.