UNPKG

socraticode

Version:

SocratiCode — MCP server for local codebase indexing, semantic search, and code dependency graphs. All private, all local via Docker.

110 lines • 5.3 kB
/** * Per-language symbol & call-site extraction (mirrors `graph-imports.ts`). * * Populated in Phase B with ast-grep patterns for each language. */ import { Lang } from "@ast-grep/napi"; import type { EdgeKind, SymbolEdge, SymbolNode } from "../types.js"; /** Result of extracting symbols + raw call sites from a file. */ /** * One name a Rust `use` puts in a file's own scope, and the path it names. * * The file-import graph cannot supply this: `rustUseLeafPath` strips the alias * before the path is ever recorded, and `ImportInfo` has no field for a local * binding. Without it, `use crate::a::Type as Alias;` followed by * `Alias::method()` leaves the qualifier `Alias` naming nothing. * * Kept out of the persisted graph on purpose. It is an input to resolution, * which runs once per full build and in the same process as extraction, so * nothing needs to store it and no payload changes shape. */ export interface RustUseBinding { /** The name written in this file — the alias when there is one. */ local: string; /** The path it names, alias excluded: `crate::a::Type`, `std::fs`. */ path: string; } export interface ExtractedSymbols { symbols: SymbolNode[]; /** Outgoing call sites — `calleeCandidates` and `confidence` are filled later by resolution. */ rawCalls: Array<{ callerId: string; calleeName: string; kind: EdgeKind; sourceModule?: string; importedName?: string; localAlias?: string; /** * The path qualifying the callee, terminal name excluded: `Vec` in * `Vec::new()`, `std::fs` in `std::fs::copy()`. Absent on a bare call. */ calleeQualifier?: string; /** * The qualifier is rooted in an inline `mod`, which has no file to point * at and no spelling resolution can follow. Set only for Rust, and only * for the shape that cannot be rewritten as file-relative; resolution * leaves such a call unresolved rather than answering out of the wrong * scope. In memory only — it reaches resolution beside the edges and is * never part of one. */ qualifierRootedInInlineMod?: boolean; /** C# member-access receiver reference; see {@link SymbolEdge.csMemberReceiver}. */ csMemberReceiver?: boolean; callSite: { file: string; line: number; }; /** Receiver expression for method calls (e.g. "fighter" in "fighter.take_damage()"). * GDScript: present only for attribute_call nodes; bare calls have no receiver. * C#: `this`, `base` or `?`; see {@link SymbolEdge.receiver}. */ receiver?: string; /** True when this call represents a GDScript `signal_name.emit()`. */ signalEmit?: boolean; }>; /** Inferred variable types from assignment sites (var x = Expr, x = Expr). * Maps variable name → list of inferences, each with the enclosing scope's * line range. This prevents cross-function name collisions (e.g. two * functions each declaring `var f = X.new()` no longer overwrite each other). * Special markers in the type field: * - "<self>" → type is the file's class_name (resolved during resolution) * - "ref:varName" → type is the same as varName's type (resolved during resolution) * Present only for GDScript files with assignment-site inferences. */ inferredTypes?: Map<string, Array<{ type: string; startLine: number; endLine: number; }>>; /** Member assignments: `receiver.memberName = value` → records for cross-file * member type propagation. valueType uses the same markers as inferredTypes. * Present only for GDScript files with member assignments. */ memberAssignments?: Array<{ receiver: string; memberName: string; valueType: string; }>; /** Rust `use` bindings declared by this file. Absent for every other language. */ bindings?: RustUseBinding[]; /** * The ids of the symbols this file declares *inside* an inline `mod` — the * ones a path anchored at the file's own module cannot reach. Set only for * Rust, and only for the files that have any. * * In memory only, like `qualifierRootedInInlineMod`: it reaches resolution * beside the symbols and is never a field on one, so nothing about it is * persisted and a graph built before this still reads. */ inlineModSymbolIds?: Array<[id: string, inlineModPath: string]>; } /** * Reset the per-language dedupe set. Intended for tests that want to assert * deterministically on extraction warnings. */ export declare function resetSymbolExtractionWarnings(): void; /** * Public entry point: extract symbols and raw call sites from a source file. * Returns empty arrays if the language is unsupported or parsing fails. */ export declare function extractSymbolsAndCalls(source: string, lang: Lang | string, ext: string, relativePath: string): ExtractedSymbols; /** Convert raw call sites to unresolved SymbolEdge objects (resolution in Phase C). */ export declare function rawCallsToUnresolvedEdges(rawCalls: ExtractedSymbols["rawCalls"]): SymbolEdge[]; //# sourceMappingURL=graph-symbols.d.ts.map