GtBridge.Analysis (gt_bridge v0.19.2)

Copy Markdown View Source

I provide static analysis data for GT visualization.

I use :xref to extract module-level call graphs from compiled BEAM files and GtBridge.Beam.docs/1 for documentation coverage. I return raw data — GT builds the views.

Sibling modules cover related subsystems split out from this one: GtBridge.HotReload (hot_reload + compile dep edges), GtBridge.DepGraph (app dep trees + root_apps), GtBridge.Mnesia (table introspection), GtBridge.Supervision (process tree), and GtBridge.Eval.Preamble (editor session import-loading).

Summary

Functions

I return all function definitions with complete line ranges.

I return per-module doc coverage with function-level detail for an app.

I return example dependency data for a module that uses ExExample.

I return exported functions for a module (works for both Elixir and Erlang).

I answer whether the Functions view should show a tab for mod, without building or serializing the full function list.

I return per-module metadata for an application.

I return application names matching a substring query.

I return exported functions matching a query within an app.

I return module names matching a substring query, limited to max results.

I return documentation coverage grouped by application.

I return system info for the Overview view.

I return aggregate stats across all loaded applications.

Functions

all_functions(mod)

@spec all_functions(module()) :: [map()]

I return all function definitions with complete line ranges.

Each entry includes :start (extended back to include @doc/@spec), :end_line, :name, :arity, :kind, :sig, and :source (the source text for that function including annotations).

AST entries are merged with runtime exports from __info__(:functions) so macro-generated functions (e.g. defview, defstruct field accessors, etc.) are visible. Runtime-only entries get default start: 0, end_line: 0, kind: :def, and a placeholder source.

Type rows come from the source alone: a module with no readable source (an OTP beam compiled elsewhere) lists only its exported functions.

app_doc_coverage(app)

@spec app_doc_coverage(atom()) :: [map()]

I return per-module doc coverage with function-level detail for an app.

Each entry has :module, :has_mod_doc, and :functions (list of %{name: String.t(), has_doc: boolean()}).

append_function(source, module, new_text)

See GtBridge.Analysis.Source.append_function/3.

call_sites(source, context_module \\ nil)

See GtBridge.Analysis.CallSites.call_sites/2.

callees(mod, app)

See GtBridge.Analysis.Graph.callees/2.

callers(mod, app)

See GtBridge.Analysis.Graph.callers/2.

example_deps(mod)

@spec example_deps(module()) :: [{String.t(), [String.t()]}]

I return example dependency data for a module that uses ExExample.

exported_functions(mod)

@spec exported_functions(module()) :: [map()]

I return exported functions for a module (works for both Elixir and Erlang).

function_in_module?(mod, name)

See GtBridge.Analysis.CallSites.function_in_module?/2.

function_references(mod, name, arity \\ nil)

See GtBridge.Analysis.Graph.function_references/3.

functions_in_source(source)

See GtBridge.Analysis.Source.functions_in_source/1.

has_functions?(mod)

@spec has_functions?(module()) :: boolean()

I answer whether the Functions view should show a tab for mod, without building or serializing the full function list.

A public (non-__) function guarantees all_functions/1 is non-empty: its runtime-export branch reads the same __info__(:functions), so any such function ends up in the result. That check settles the common module in ~1ms. Only when there's no public function do I fall back to the source-parsing all_functions/1, which also finds defp-only, macro-only, and struct modules. So the answer is identical to all_functions(mod) != [] — just cheaper for the common case.

implementors(name, arity \\ nil)

See GtBridge.Analysis.Graph.implementors/2.

module_aliases(mod)

See GtBridge.Analysis.CallSites.module_aliases/1.

module_details(app)

@spec module_details(atom()) :: [map()]

I return per-module metadata for an application.

module_graph(app)

See GtBridge.Analysis.Graph.module_graph/1.

module_in_source(source)

See GtBridge.Analysis.Source.module_in_source/1.

modules_in_source(source)

See GtBridge.Analysis.Source.modules_in_source/1.

modules_loaded?(names)

See GtBridge.Analysis.CallSites.modules_loaded?/1.

replace_function(source, module, name, arity, new_text)

See GtBridge.Analysis.Source.replace_function/5.

resolve_alias(context_module, alias_name)

See GtBridge.Analysis.CallSites.resolve_alias/2.

search_apps(query, max \\ 30)

@spec search_apps(String.t(), pos_integer()) :: [String.t()]

I return application names matching a substring query.

search_functions(app, query, max \\ 30)

@spec search_functions(atom(), String.t(), pos_integer()) :: [map()]

I return exported functions matching a query within an app.

search_modules(query, max \\ 30)

@spec search_modules(String.t(), pos_integer()) :: [String.t()]

I return module names matching a substring query, limited to max results.

swap_functions(source, module, name_a, arity_a, name_b, arity_b)

See GtBridge.Analysis.Source.swap_functions/6.

system_doc_coverage()

@spec system_doc_coverage() :: [map()]

I return documentation coverage grouped by application.

Each entry has :app (string name) and :modules (list of %{name: String.t(), has_doc: boolean()}). Used by the GT-side doc coverage heatmap.

system_info()

@spec system_info() :: map()

I return system info for the Overview view.

system_stats()

@spec system_stats() :: map()

I return aggregate stats across all loaded applications.

Returns a map with :apps, :modules, :functions, :with_docs, and :with_source counts.