pub trait LanguageAdapter: Send + Sync {
// Required methods
fn language(&self) -> &str;
fn parse_symbols(
&self,
file: &str,
source: &str,
) -> Result<Vec<ParsedSymbol>>;
fn infer_effects(&self, source: &str, symbol: &ParsedSymbol) -> Vec<Effect>;
// Provided methods
fn file_extensions(&self) -> &'static [&'static str] { ... }
fn scan_dynamic_dispatch(
&self,
_file: &str,
_source: &str,
) -> Vec<DynamicDispatchHint> { ... }
fn report_unresolved_calls(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
_workspace: &WorkspaceSymbols,
) -> Vec<UnresolvedCall> { ... }
fn extract_call_edges(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
_workspace: &WorkspaceSymbols,
) -> Vec<CallEdge> { ... }
fn infer_service_endpoints(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
) -> Vec<DetectedEndpoint> { ... }
fn resolve_endpoint_prefixes(
&self,
_files: &[(String, String)],
_endpoints: &mut Vec<ServiceEndpoint>,
) { ... }
fn extract_dataflow(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
_workspace: &WorkspaceSymbols,
) -> Vec<DetectedDataFlow> { ... }
fn extract_property_types(
&self,
_symbols: &[ParsedSymbol],
) -> HashMap<String, String> { ... }
}Expand description
Language-specific parsing + effect inference. Implementations live in
sibling crates: agentstatedeveloper-python, -typescript, etc.
Required Methods§
Sourcefn parse_symbols(&self, file: &str, source: &str) -> Result<Vec<ParsedSymbol>>
fn parse_symbols(&self, file: &str, source: &str) -> Result<Vec<ParsedSymbol>>
Parse a file and return declared symbols.
Sourcefn infer_effects(&self, source: &str, symbol: &ParsedSymbol) -> Vec<Effect>
fn infer_effects(&self, source: &str, symbol: &ParsedSymbol) -> Vec<Effect>
Heuristic effect inference for a symbol. Returns an empty Vec when the adapter has no opinion (author must declare explicitly).
Provided Methods§
Sourcefn file_extensions(&self) -> &'static [&'static str]
fn file_extensions(&self) -> &'static [&'static str]
File extensions this adapter handles, without the leading dot. Used by the shared index pipeline for file dispatch. Default: empty (adapter is never auto-selected by extension).
Sourcefn scan_dynamic_dispatch(
&self,
_file: &str,
_source: &str,
) -> Vec<DynamicDispatchHint>
fn scan_dynamic_dispatch( &self, _file: &str, _source: &str, ) -> Vec<DynamicDispatchHint>
Plan L t-005: report dynamic-dispatch sites in the file’s source.
These are call patterns the static call-graph walker can’t resolve
(e.g. getattr(obj, attr_name)(args), callback-by-argument,
metaclass tricks). Returning a non-empty list signals to the
indexer that some call paths in this file won’t show up in the
graph; the indexer surfaces a one-line warning so agents/humans
know the missing edges aren’t a bug, they’re a known limit.
Default: empty. Adapters with no dynamic-dispatch story return nothing.
Sourcefn report_unresolved_calls(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
_workspace: &WorkspaceSymbols,
) -> Vec<UnresolvedCall>
fn report_unresolved_calls( &self, _file: &str, _source: &str, _symbols: &[ParsedSymbol], _workspace: &WorkspaceSymbols, ) -> Vec<UnresolvedCall>
Plan L t-006: report call sites in this file whose function position couldn’t be resolved to a workspace qname. Default: empty. Adapters that can compute this cheaply override.
Sourcefn extract_call_edges(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
_workspace: &WorkspaceSymbols,
) -> Vec<CallEdge>
fn extract_call_edges( &self, _file: &str, _source: &str, _symbols: &[ParsedSymbol], _workspace: &WorkspaceSymbols, ) -> Vec<CallEdge>
Extract call edges from a file’s parsed symbols. Returned pairs are (caller_qname, callee_qname). The adapter is free to use heuristics; resolution quality is best-effort.
workspace carries workspace-wide qname/kind context so adapters
can resolve cross-module calls (via imports). Adapters that only
care about intra-module edges may safely ignore it.
Sourcefn infer_service_endpoints(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
) -> Vec<DetectedEndpoint>
fn infer_service_endpoints( &self, _file: &str, _source: &str, _symbols: &[ParsedSymbol], ) -> Vec<DetectedEndpoint>
Detect cross-service endpoints (HTTP routes/clients, pub-sub
emit/listen) in a file. Returns DetectedEndpoints attributed to the
owning symbol by qname; the index pipeline enriches them with repo +
symbol identity. Whole-file signature (not per-symbol) because the
signal often lives just outside a symbol’s body (e.g. a route decorator
above a def). Default: empty — adapters opt in.
See crate::cross_service for the contract-keyed matching model.
Sourcefn resolve_endpoint_prefixes(
&self,
_files: &[(String, String)],
_endpoints: &mut Vec<ServiceEndpoint>,
)
fn resolve_endpoint_prefixes( &self, _files: &[(String, String)], _endpoints: &mut Vec<ServiceEndpoint>, )
Project-level pass (Plan Q t-004b): rewrite endpoint contracts using
cross-file context — e.g. resolving nested router-mount prefix chains
(app.include_router(api, prefix="/api") → api.include_router(calc, prefix="/calc") → @calc.get("/x") = /api/calc/x) that span files.
files is (path, source) for THIS adapter’s language; endpoints is
the full project set — the adapter must only touch its own. Runs once
after per-file detection. Default: no-op.
Sourcefn extract_dataflow(
&self,
_file: &str,
_source: &str,
_symbols: &[ParsedSymbol],
_workspace: &WorkspaceSymbols,
) -> Vec<DetectedDataFlow>
fn extract_dataflow( &self, _file: &str, _source: &str, _symbols: &[ParsedSymbol], _workspace: &WorkspaceSymbols, ) -> Vec<DetectedDataFlow>
Detect intra-process data-flow sites (arg → param at call sites) in a
file. Returns DetectedDataFlow naming caller/callee by qname plus the
argument and its position; the index pipeline resolves the callee’s
parameter name and symbol identity. Default: empty — adapters opt in.
See crate::dataflow for the model.
Sourcefn extract_property_types(
&self,
_symbols: &[ParsedSymbol],
) -> HashMap<String, String>
fn extract_property_types( &self, _symbols: &[ParsedSymbol], ) -> HashMap<String, String>
Extract stored property declarations from a file’s parsed symbols,
returning "EnclosingTypeSimpleName.propertyName" → "TypeSimpleName".
Called by the index pipeline for EVERY file in a run so that
workspace.properties accumulates a project-wide property map.
That map is then available to extract_call_edges to resolve
instance property calls across file boundaries.
Default: returns an empty map (most adapters don’t need this).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".