/** * Derivation of SCIP symbol monikers and language tags from OpenLore graph * nodes. * * SCIP symbols are formatted strings, not structured objects, per the grammar * documented at https://github.com/sourcegraph/scip/blob/main/docs/scip.md. * We emit global symbols of the form: * * ' ' ' ' ' ' * * where descriptors are `/` (namespace) followed by * `().` (method). Example: * * openlore npm openlore 2.0.2 `src/core/scip/index.ts`/exportScip(1). * * Identifiers containing characters outside the SCIP "simple identifier" set * are backtick-escaped (with embedded backticks doubled). */ import type { FunctionNode } from '../analyzer/call-graph.js'; /** Package coordinates that fill the SCIP `` slot of every symbol. */ export interface PackageInfo { manager: string; name: string; version: string; } /** * Map an OpenLore language tag (see signature-extractor.ts) to the SCIP * `Language` enum name used as `Document.language`. Returns `''` for languages * SCIP has no value for (the caller records these for the export summary). */ export declare function scipLanguageName(openloreLanguage: string): string; /** Fully-qualified name within a file: `Class.method` or bare `function`. */ export declare function qualifiedName(node: FunctionNode): string; /** * Best-effort parameter count from a node's declaration `signature`. Counts * top-level comma-separated parameters inside the parameter group. * Returns `undefined` when no signature is available (the analyzer does not * persist arity directly — TODO(spec-04-followup): arity in analyzer). */ export declare function arityOf(node: FunctionNode): number | undefined; /** * Build the SCIP symbol moniker string for a function node. * * `repoRelPath` must be the document's relative path (POSIX separators), the * same value used for the node's `Document.relative_path`. */ export declare function symbolMoniker(node: FunctionNode, repoRelPath: string, pkg: PackageInfo): string; /** * Normalized signature shape: the balanced parenthesized parameter group only, * identifier removed, whitespace-collapsed (e.g. `(a: number, b: string)`). * Shared by {@link stableSymbolId} (overload disambiguator) and structural-diff's * rename-recovery heuristic, so both agree on one notion of "same shape". * * Deliberately bounded to the parameter list — it excludes everything *after* the * matching close paren, which matters for two reasons: * - Leading modifiers/the name (a rename, `async`/`export`/visibility) and the * trailing return type are NOT in the shape, so a change confined to those * keeps a symbol's `stableId` and is reported as *modified*, not remove+add. * - For expression-bodied arrows (`const f = (a) => a.length`) the analyzer's * captured `signature` includes the body; bounding to the param group keeps the * `stableId` BODY-INVARIANT — essential so a moved-and-edited symbol resolves as * `drifted` (not `orphaned`) via its anchor's `stableId`. * * Pass the symbol's `name` (and `language`) so the parameter group is located by * {@link parameterGroupStart}: this skips a Go method receiver and refuses to * mistake a call inside an expression body (Ruby/Scala paren-less defs, paren-less * arrows) for the parameters — keeping the shape genuinely body-invariant. With no * `name` (bare unit-test calls) the legacy first-`(` heuristic is used. * Returns `''` when there is no parameter group. */ export declare function signatureShape(signature: string | undefined, language?: string, name?: string): string; /** * Content-addressed, location-independent stable identity for a function symbol. * (change: add-content-addressed-stable-symbol-ids) * * A pure function of the symbol's OWN structure: the qualified name * (`Class.method` or bare function) plus the normalized {@link signatureShape} * (the parameter group). It deliberately excludes the repo-relative path that * {@link symbolMoniker} bakes into its namespace AND the function body, so a * symbol keeps its identity across a file rename/move and across body edits. * * A function id always carries a `(...)` parameter group (empty `()` when no * signature was captured), so it never collides with a {@link stableClassId} of * the same name (classes carry none). * * Because the id is content-only, two genuinely distinct symbols that share a * qualified name and parameter shape (homonyms) receive the SAME `stableId`. This * is intentional: the change never fabricates a position-dependent discriminator * (which a file rename/add/remove would silently flip). Consumers resolve a * `stableId` only when it identifies a UNIQUE symbol (see * `EdgeStore.getNodeByStableId`) and otherwise fall back rather than guess. * * Returns `undefined` for symbols with no derivable descriptor (anonymous or * synthetic), which keep only their path-based `id`. */ export declare function stableSymbolId(node: FunctionNode): string | undefined; /** * Stable id for a class symbol: the escaped class name only (a class has no * parameter group, so it never collides with a function's `sid:Name(...)`). * Returns `undefined` for synthetic module groupings and non-derivable names. * Like {@link stableSymbolId}, homonym classes share an id and resolve only when * unique. */ export declare function stableClassId(name: string, isModule?: boolean): string | undefined; //# sourceMappingURL=moniker.d.ts.map