import type { SymbolInfo, SyntaxNode } from '../types.js'; import type { LanguageDefinition } from './types.js'; import type { LanguageTraverser, DeclarationFunctionInfo } from '../traversers/types.js'; import type { LanguageExportExtractor, LanguageImportExtractor, LanguageSymbolExtractor } from '../extractors/types.js'; /** * Rust AST traverser * * Handles Rust AST node types and traversal patterns. * Rust is similar to Python in that functions are always declared with `fn`: * - No variable declarations with functions (unlike JS const x = || {}) * - `impl` blocks and `trait` blocks act as containers (like classes) * - Closures exist but are not top-level declarations */ export declare class RustTraverser implements LanguageTraverser { targetNodeTypes: string[]; containerTypes: string[]; declarationTypes: string[]; functionTypes: string[]; shouldExtractChildren(node: SyntaxNode): boolean; isDeclarationWithFunction(_node: SyntaxNode): boolean; getContainerBody(node: SyntaxNode): SyntaxNode | null; shouldTraverseChildren(node: SyntaxNode): boolean; findParentContainerName(node: SyntaxNode): string | undefined; findFunctionInDeclaration(_node: SyntaxNode): DeclarationFunctionInfo; } /** * Rust export extractor * * Rust uses `pub` visibility to mark items as exported. Items with a * `visibility_modifier` child (e.g., `pub`, `pub(crate)`) are considered exports. * * Exportable items: * - pub fn helper() {} * - pub struct User {} * - pub enum Status {} * - pub trait Serialize {} * - pub type Alias = ... * - pub const VALUE: ... = ... * - pub static GLOBAL: ... = ... * - pub mod submodule; * - pub use other::Thing; (re-exports) */ export declare class RustExportExtractor implements LanguageExportExtractor { private readonly exportableTypes; extractExports(rootNode: SyntaxNode): string[]; private extractExportName; private hasVisibilityModifier; /** * Extract exported names from a use declaration argument. * Handles both simple patterns and list patterns: * - `pub use crate::auth::AuthService;` -> ["AuthService"] * - `pub use crate::auth::{AuthService, AuthError};` -> ["AuthService", "AuthError"] */ private extractUseExportNames; } /** * Rust import extractor * * Handles all `use` declarations (not just `pub use`) — every `use` creates * a dependency — AND file-backed `mod` declarations (`mod x;`/`pub mod x;`, * #1000): the idiomatic Rust pattern of `mod x;` at the crate root plus * qualified calls (`x::func()`) with no `use` at all otherwise produces no * edge whatsoever. See `extractModImportPath` for how a `mod` declaration is * resolved to a directory-anchored, extensionless module path rather than * an ambiguous bare specifier. An INLINE `mod x { ... }` (has a body) is a namespace, not an * import, and correctly produces no edge for itself — see * `isInlineModDeclaration`. * * Examples: * - `use crate::auth::AuthService;` * - `use crate::auth::{AuthService, AuthError};` * - `use crate::auth::Service as Auth;` * - `use crate::models::*;` * - `use std::io::Read;` (external - skipped) * - `use super::utils::helper;` * - `mod reporter;` -> `/reporter` (#1000) * - `pub mod reporter;` -> same as above; visibility doesn't affect whether * the sibling file is a real dependency * - `mod tests { ... }` -> no edge (inline, no separate file) */ export declare class RustImportExtractor implements LanguageImportExtractor { readonly importNodeTypes: string[]; extractImportPath(node: SyntaxNode, rustCrateMap?: ReadonlyMap, importerFile?: string): string | null; extractImportPaths(node: SyntaxNode, rustCrateMap?: ReadonlyMap, importerFile?: string): string[]; processImportSymbols(node: SyntaxNode, rustCrateMap?: ReadonlyMap, importerFile?: string, workspaceRoot?: string): { importPath: string; symbols: string[]; } | null; processImportSymbolsList(node: SyntaxNode, rustCrateMap?: ReadonlyMap, importerFile?: string, workspaceRoot?: string): Array<{ importPath: string; symbols: string[]; }>; private processUseArgument; private processScopedIdentifier; private processScopedUseList; private processUseAsClause; private processUseWildcard; /** * Resolve the full path of a use argument for the imports list. * Returns the full `crate::...` path or similar. */ private resolveFullPath; } /** * Rust symbol extractor * * Handles: * - function_item (fn foo() {}) * - function_signature_item (fn foo(); in traits) * - impl_item (impl Foo {}) - treated as class equivalent * - trait_item (trait Foo {}) - treated as interface equivalent * * Call sites: call_expression (foo()), macro_invocation (println!()) */ export declare class RustSymbolExtractor implements LanguageSymbolExtractor { readonly symbolNodeTypes: string[]; extractSymbol(node: SyntaxNode, content: string, parentClass?: string): SymbolInfo | null; extractCallSite(node: SyntaxNode): { symbol: string; line: number; key: string; } | null; private extractFunctionInfo; /** * `impl Trait for Type` — the trait being implemented (if any) is * arguably the single most useful fact about an impl block (which * behavior it provides), and the generic parameters distinguish a * blanket/generic impl from a concrete one; `signature` used to report * neither, just `impl Type`. `type`, `trait`, and `type_parameters` are * all registered fields on `impl_item`. Deliberately excludes the * trailing `where_clause` (an unnamed child, not a field) — same * out-of-scope call as C#'s generic constraints. Each piece is passed * through `collapseWhitespace` in case it spans multiple physical lines. */ private extractImplInfo; /** * `trait Foo: Bar + Baz` — `bounds` (supertraits) and `type_parameters` * are both registered fields on `trait_item`; `bounds.text` already * includes its leading `:` (e.g. `": Bar + Baz"`). Each piece is passed * through `collapseWhitespace` in case it spans multiple physical lines. */ private extractTraitInfo; } export declare const rustDefinition: LanguageDefinition; //# sourceMappingURL=rust.d.ts.map