MCPcopy Index your code
hub / github.com/tirth8205/code-review-graph / _resolve_call_targets

Method _resolve_call_targets

code_review_graph/parser.py:2163–2200  ·  view source on GitHub ↗

Resolve bare call targets to qualified names using same-file definitions. After parsing, CALLS edges store bare function names (e.g. ``FirebaseAuth``) as targets. This method builds a symbol table from the parsed nodes and qualifies any bare target that matches a local defin

(
        self,
        nodes: list[NodeInfo],
        edges: list[EdgeInfo],
        file_path: str,
    )

Source from the content-addressed store, hash-verified

2161 ))
2162
2163 def _resolve_call_targets(
2164 self,
2165 nodes: list[NodeInfo],
2166 edges: list[EdgeInfo],
2167 file_path: str,
2168 ) -> list[EdgeInfo]:
2169 """Resolve bare call targets to qualified names using same-file definitions.
2170
2171 After parsing, CALLS edges store bare function names (e.g. ``FirebaseAuth``)
2172 as targets. This method builds a symbol table from the parsed nodes and
2173 qualifies any bare target that matches a local definition, so that
2174 ``callers_of`` / ``callees_of`` queries produce correct results.
2175
2176 External calls (names not defined in this file) remain bare.
2177 """
2178 # Build symbol table: bare_name -> qualified_name
2179 symbols: dict[str, str] = {}
2180 for node in nodes:
2181 if node.kind in ("Function", "Class", "Type", "Test"):
2182 bare = node.name
2183 qualified = self._qualify(bare, file_path, node.parent_name)
2184 if bare not in symbols:
2185 symbols[bare] = qualified
2186
2187 resolved: list[EdgeInfo] = []
2188 for edge in edges:
2189 if edge.kind in ("CALLS", "REFERENCES") and "::" not in edge.target:
2190 if edge.target in symbols:
2191 edge = EdgeInfo(
2192 kind=edge.kind,
2193 source=edge.source,
2194 target=symbols[edge.target],
2195 file_path=edge.file_path,
2196 line=edge.line,
2197 extra=edge.extra,
2198 )
2199 resolved.append(edge)
2200 return resolved
2201
2202 _MAX_AST_DEPTH = 180 # Guard against pathologically nested source files
2203 _MAX_TEST_DESCRIPTION_LEN = 200 # Cap test description length in node names

Callers 3

parse_bytesMethod · 0.95
_parse_notebook_cellsMethod · 0.95
_parse_rescriptMethod · 0.95

Calls 2

_qualifyMethod · 0.95
EdgeInfoClass · 0.85

Tested by

no test coverage detected