Beamscope.Callgraph.Graph (Beamscope v0.1.2)

Copy Markdown View Source

Builds a libgraph-backed call graph from Extractor's defs/edges.

Nodes are "module:name" qualified strings — the same convention build_callgraph.py's FunctionDef.qualified_name/CallEdge.*_qualified use — so results stay directly diffable against the existing shared/mongooseim_callgraph.json baseline via to_node_link_json/1, which mirrors NetworkX's node_link_data shape (directed, multigraph, graph, nodes, edges with source/target/key).

Summary

Functions

Every function qualified_name calls, enriched with location like callers_with_locations/2.

Every function that calls qualified_name, enriched with its definition location (file_path/start_line/end_line) when known. A caller with no known def (e.g. an unresolved dynamic-dispatch node) comes back with just qualified_name — honest, not an error.

Every known function definition in the graph — qualified_name plus its file_path/start_line/end_line. Vertices added only as edge endpoints (e.g. unresolved/dynamic calls) have no location label and are excluded.

Rebuilds a graph from to_node_link_json/1's output — used to reload a persisted call graph (Beamscope.Callgraph.Store) without re-walking and re-parsing the repo from source.

Shortest call path from from to to, like shortest_path/3, but with each hop enriched with its definition location like callers_with_locations/2. nil if no path exists.

Functions

build(defs, edges)

@spec build([map()], [map()]) :: Graph.t()

callees(graph, qualified_name)

@spec callees(Graph.t(), String.t()) :: [String.t()]

callees_with_locations(graph, qualified_name)

@spec callees_with_locations(Graph.t(), String.t()) :: [map()]

Every function qualified_name calls, enriched with location like callers_with_locations/2.

callers(graph, qualified_name)

@spec callers(Graph.t(), String.t()) :: [String.t()]

callers_with_locations(graph, qualified_name)

@spec callers_with_locations(Graph.t(), String.t()) :: [map()]

Every function that calls qualified_name, enriched with its definition location (file_path/start_line/end_line) when known. A caller with no known def (e.g. an unresolved dynamic-dispatch node) comes back with just qualified_name — honest, not an error.

defs(graph)

@spec defs(Graph.t()) :: [map()]

Every known function definition in the graph — qualified_name plus its file_path/start_line/end_line. Vertices added only as edge endpoints (e.g. unresolved/dynamic calls) have no location label and are excluded.

qualified_name(module, name)

@spec qualified_name(String.t(), String.t()) :: String.t()

shortest_path(graph, from, to)

@spec shortest_path(Graph.t(), String.t(), String.t()) :: [String.t()] | nil

shortest_path_with_locations(graph, from, to)

@spec shortest_path_with_locations(Graph.t(), String.t(), String.t()) :: [map()] | nil

Shortest call path from from to to, like shortest_path/3, but with each hop enriched with its definition location like callers_with_locations/2. nil if no path exists.