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'; /** * Swift AST traverser. * * Functions/methods/initializers live inside `class_declaration` (which covers * class / struct / actor / enum / extension) and `protocol_declaration` bodies * (`class_body` / `enum_class_body` / `protocol_body`). Closures can appear as * property initializers (`let handler = { … }`). */ export declare class SwiftTraverser 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; } /** * Swift export extractor. * * Swift has no `export` keyword. Top-level declarations and (non-private/ * fileprivate) members form the file's API surface. Protocol members are * implicitly part of the protocol's surface. */ export declare class SwiftExportExtractor implements LanguageExportExtractor { extractExports(rootNode: SyntaxNode): string[]; private extractFromNode; private extractMembers; } /** * Swift import extractor. * * Handles `import Foundation`, dotted `import Combine.Just`, and import-kind * forms (`import struct Combine.Just` — the `struct`/`class`/… keyword is an * anonymous token and is ignored; the module path is what matters). Only the * `Swift` stdlib module is filtered out. */ export declare class SwiftImportExtractor implements LanguageImportExtractor { readonly importNodeTypes: string[]; extractImportPath(node: SyntaxNode): string | null; extractImportPaths(node: SyntaxNode): string[]; processImportSymbols(node: SyntaxNode): { importPath: string; symbols: string[]; } | null; processImportSymbolsList(node: SyntaxNode): Array<{ importPath: string; symbols: string[]; }>; private getImportPath; } /** * Swift symbol extractor. * * Handles `function_declaration`, `init`/`deinit`/`subscript` declarations, * `class_declaration` (class / struct / actor / enum / extension — distinguished * by the `declaration_kind` keyword), and `protocol_declaration`. `SymbolInfo.type` * only has `function|method|class|interface`, so struct/actor/enum/extension map * to `class` (keeping the real keyword in the signature) and protocol maps to * `interface`. * * Call sites: `call_expression` — `foo()` (simple_identifier callee) and * `a.b.c()` (the member is the `simple_identifier` in the trailing * `navigation_suffix`). */ export declare class SwiftSymbolExtractor implements LanguageSymbolExtractor { readonly symbolNodeTypes: string[]; extractSymbol(node: SyntaxNode, content: string, parentClass?: string): SymbolInfo | null; /** * Resolve a call site to the called symbol name. Dependency matching is by * bare name (call.symbol === symbol.name), so the name we record determines * which definition the call links to. * * Constructor calls are worth a note: Swift spells initialization `Foo(...)` * (no `new`), so the callee is the type name and we record `Foo` — linking the * call to the type's `class_declaration` symbol, exactly as JS records * `new Foo()` against the class and Python records `Foo()`. So blast-radius for * "who constructs Foo" is found via the TYPE symbol (a safe over-approximation), * not the `init` method symbol. An explicit `Foo.init()` records `init` and * links the initializer directly. The standalone `init`/`deinit`/`subscript` * symbols are definitions for search/listing (as Java emits constructor * symbols); they intentionally carry no implicit-`Foo()` caller edges. */ extractCallSite(node: SyntaxNode): { symbol: string; line: number; key: string; } | null; private extractFunctionInfo; /** * `parentClass` is threaded through so a nested type — idiomatic in Swift * (a `class`/`struct`/`enum` declared directly inside another type's body, * or a protocol nested inside a type) — reports its enclosing type. * `SwiftTraverser.findParentContainerName` already resolves this for every * top-level node, not just methods (#949). */ private extractClassInfo; private extractProtocolInfo; private makeSymbol; } export declare const swiftDefinition: LanguageDefinition; //# sourceMappingURL=swift.d.ts.map