Files
codebase-memory-mcp/internal/cbm/lsp/rust_rustdoc.h
Martin Vogel 31f7438ce0 Add Rust hybrid LSP resolver
Hybrid tree-sitter + type-resolution call resolver for Rust, alongside the
Go/C/PHP/C#/Python/TypeScript/Java/Kotlin resolvers. Resolves method dispatch
on typed receivers, UFCS and associated-function calls, trait/impl methods,
generics, closures, the `?` operator, and iterator adapters; seeds the standard
library and well-known crates, parses Cargo.toml for dependency context, and
expands a curated set of derive/proc-macro generated methods.

Includes rust_cargo (manifest parsing), rust_proc_macros (derive expansion),
rust_rustdoc (doc extraction), a generated stdlib + crates seed, and a large
test suite (registered as suite rust_lsp). Wired into the per-file dispatch.
Field-access chains through Self-returning calls remain a documented coverage
gap. Full suite green (4666 tests).
2026-06-03 02:13:30 +02:00

34 lines
1.4 KiB
C

/* rust_rustdoc.h — Ingest `cargo +nightly rustdoc --output-format json`
* output into the Rust LSP type registry.
*
* Per the FOLLOWUP-extension Option A: when a project opts in by
* running rustdoc once, we can ingest the resulting JSON and register
* every item (struct, trait, fn, method) with accurate signatures.
* That eliminates the "unseeded external crate" gap because rustdoc
* already did the macro expansion and type resolution.
*
* The schema is rustdoc's "Crate" type. We handle:
* - paths { id → { path: [..], kind: "struct"|"trait"|... } }
* - index { id → Item { name, inner: { Function|Struct|... }, … } }
*
* We ignore everything we don't understand. The JSON format is unstable
* across rustdoc versions; we tolerate missing fields gracefully and
* just skip items we can't make sense of.
*
* Schema reference: https://github.com/rust-lang/rust/blob/master/src/rustdoc-json-types/lib.rs
*/
#ifndef CBM_LSP_RUST_RUSTDOC_H
#define CBM_LSP_RUST_RUSTDOC_H
#include "../arena.h"
#include "type_registry.h"
/* Ingest a rustdoc JSON document into the registry. `crate_qn` is the
* QN prefix to use for items (e.g. "serde" for crate `serde`). Returns
* the number of items registered. */
int cbm_rust_rustdoc_ingest(CBMTypeRegistry* reg, CBMArena* arena,
const char* json, int json_len, const char* crate_qn);
#endif /* CBM_LSP_RUST_RUSTDOC_H */