GtBridge.Analysis.CallSites (gt_bridge v0.19.2)

Copy Markdown View Source

I resolve call sites for GT's inline |> expander: which calls in a source buffer point at real functions or types, resolved through the context module's aliases, imports, and its own defs. Name-set and alias/import lookups are md5-cached per module.

Summary

Functions

I parse Elixir source and return uniquely resolvable remote call sites.

I am true when mod defines a function (or macro-generated export) named name. Used by GT-side C-n to decide whether an unqualified reference should be searched in mod (true) or fall back to cross-module implementors search (false).

I return mod's alias declarations as a list of [short_name, full_name] pairs.

I check whether each name in names (dotted Elixir module name strings, e.g. "GtBridge.Eval") is a currently-loaded module, and return a %{name => boolean()} map.

I resolve an alias name using a context module's alias declarations.

Functions

call_sites(source, context_module \\ nil)

@spec call_sites(String.t(), module() | nil) :: [map()]

I parse Elixir source and return uniquely resolvable remote call sites.

Each result has :target_module, :function, :arity, :line, and :column. Only fully qualified and alias-resolved remote calls are returned.

function_in_module?(mod, name)

@spec function_in_module?(module(), String.t() | atom()) :: boolean()

I am true when mod defines a function (or macro-generated export) named name. Used by GT-side C-n to decide whether an unqualified reference should be searched in mod (true) or fall back to cross-module implementors search (false).

module_aliases(mod)

@spec module_aliases(module()) :: [[String.t()]]

I return mod's alias declarations as a list of [short_name, full_name] pairs.

GT-side wrench detection in inline function editors (the |> expander, the Meta browser's Functions tab) shows only a function body — the surrounding alias lines aren't visible in source, so bare references like ColumnedList look unresolved even when the enclosing module aliases them. The styler calls me to merge the module's aliases into its local map before classifying.

I return a list (rather than a map) so the Smalltalk side can iterate via asList without needing attributeAt: per name — Maps come back as opaque proxies on the GT side.

modules_loaded?(names)

@spec modules_loaded?([String.t()]) :: %{required(String.t()) => boolean()}

I check whether each name in names (dotted Elixir module name strings, e.g. "GtBridge.Eval") is a currently-loaded module, and return a %{name => boolean()} map.

Backed by the Analysis.LoadedModules ETS-backed set, which is populated initially from :application.get_key/2 and maintained additively by EventBroker %ModuleEvent{} events — so each lookup is O(1) and stays fresh without recompute.

Used by GT-side BeamModuleResolution: the styler walks source locally with the SmaCC ElixirParser, finds module-name candidates, batches the unknowns, and asks me once per source change for their resolution status. After warm-up the GT cache holds answers for every name in the user's workspace and bridge calls go to zero.

resolve_alias(context_module, alias_name)

@spec resolve_alias(module(), String.t()) :: String.t()

I resolve an alias name using a context module's alias declarations.