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'; /** * Go AST traverser * * Go has a flat structure — methods are top-level declarations with receiver * parameters, not nested inside struct/interface blocks. There are no container * types (unlike Rust's `impl` blocks or Python's classes). * * Anonymous functions can appear in var declarations: * var handler = func(w http.ResponseWriter, r *http.Request) { ... } */ export declare class GoTraverser 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; private hasFuncLiteral; } /** * Go export extractor * * Go uses capitalization for exports — identifiers starting with an uppercase * letter are exported from the package. * * Exportable items: * - func NewUser() {} (uppercase function) * - func (u *User) GetName() {} (uppercase method) * - type User struct {} (uppercase type) * - type Validator interface {} (uppercase interface) * - const MaxSize = 100 (uppercase constant) * - var GlobalVar = "hello" (uppercase variable) * * Grouped declarations are also supported: * - const ( StatusActive = 1; StatusInactive = 2 ) * - var ( Version = "1.0"; Build = "123" ) * - type ( Request struct{}; Response struct{} ) */ export declare class GoExportExtractor implements LanguageExportExtractor { extractExports(rootNode: SyntaxNode): string[]; private extractTypeExports; private extractSpecExports; } /** * Go import extractor * * Handles all Go import patterns: * - import "fmt" (single import) * - import ( "fmt"; "net/http" ) (grouped imports) * - import f "fmt" (aliased import) * - import . "strings" (dot import — imports into current scope) * - import _ "database/sql" (blank import — side effects only) * * Standard library imports are filtered out (no dots in first path component). */ export declare class GoImportExtractor implements LanguageImportExtractor { readonly importNodeTypes: string[]; /** * Returns only the FIRST non-stdlib path from a grouped `import (...)` * block — kept for existing callers/tests that want a single result. * Delegates to `extractImportPaths` so the two can never disagree; see * that method for why a grouped import can legitimately declare several * distinct targets (#863). */ extractImportPath(node: SyntaxNode): string | null; /** * Returns EVERY non-stdlib path declared by this import node, in source * order. A single `import (...)` block commonly groups 2+ external * packages (e.g. `import ( "fmt"; "github.com/foo/utils"; "github.com/foo/models" )`), * and each is a genuinely distinct target — silently keeping only the * first (the pre-#863 behavior) dropped every subsequent target from * `chunk.metadata.imports`, hiding any test file that only imports a * later package in the group from `findTestAssociationsFromChunks`. */ extractImportPaths(node: SyntaxNode): string[]; processImportSymbols(node: SyntaxNode): { importPath: string; symbols: string[]; } | null; /** * Returns EVERY non-stdlib spec's {importPath, symbols} from this * declaration, not just the first -- the same multi-target gap * `extractImportPaths` already closed for the plain path list (#863). * `import (...)` blocks commonly group 2+ external packages (confirmed on * real gin source: `render/json.go`'s single grouped import names both * `codec/json` and `internal/bytesconv`), and the pre-fix singular-return * `processImportSymbols` silently dropped every one after the first, * leaving `chunk.metadata.importedSymbols` missing an entry for the * dropped path entirely -- not just imprecise, but ABSENT, which made * every downstream symbol-level consumer (e.g. MCP's `get_dependents`) * blind to real dependents whose only recorded import happened to land on * a later spec in the same block. */ processImportSymbolsList(node: SyntaxNode): Array<{ importPath: string; symbols: string[]; }>; private collectImportSpecs; private extractSpecPath; private getSpecRawPath; private getSpecAlias; } /** * Go symbol extractor * * Handles: * - function_declaration (func foo() {}) * - method_declaration (func (u *User) GetName() {}) — receiver type as parentClass * - type_declaration containing struct_type → class, interface_type → interface * * Call sites: call_expression (direct calls and selector/method calls) */ export declare class GoSymbolExtractor 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 buildFuncSymbolInfo; private extractTypeInfo; } export declare const goDefinition: LanguageDefinition; //# sourceMappingURL=go.d.ts.map