/** * SMI-1305: Go Language Adapter * * Parses Go source files and extracts imports, exports, and functions * using regex-based parsing. Go uses capitalization-based visibility: * identifiers starting with uppercase are exported (public). * * @see docs/internal/architecture/multi-language-analysis.md */ import { LanguageAdapter, type SupportedLanguage } from './base.js'; import type { ParseResult, ExportInfo, FunctionInfo, FrameworkRule } from './base.js'; /** * Extended ExportInfo for Go with visibility support */ export interface GoExportInfo extends ExportInfo { /** Go exports via capitalization */ visibility: 'public' | 'private'; /** Line number in source */ line: number; } /** * Extended FunctionInfo for Go with receiver support */ export interface GoFunctionInfo extends FunctionInfo { /** Method receiver type (e.g., "*MyStruct") */ receiver?: string; } /** * Go module information from go.mod */ export interface GoModInfo { /** Module path (e.g., "github.com/user/project") */ module: string; /** Go version (e.g., "1.21") */ goVersion?: string; /** Direct dependencies */ require: Array<{ path: string; version: string; }>; /** Replaced dependencies */ replace: Array<{ old: string; new: string; version?: string; }>; } /** * Go Language Adapter * * Parses Go source files using regex-based parsing. * Handles Go's capitalization-based visibility rules. * * @example * ```typescript * const adapter = new GoAdapter() * const result = adapter.parseFile(goCode, 'main.go') * console.log(result.exports) // Uppercase identifiers only * ``` */ export declare class GoAdapter extends LanguageAdapter { readonly language: SupportedLanguage; readonly extensions: string[]; /** * Parse a Go source file and extract information */ parseFile(content: string, filePath: string): ParseResult; /** * Parse file incrementally (currently same as full parse) */ parseIncremental(content: string, filePath: string, _previousTree?: unknown): ParseResult; /** * Get Go framework detection rules */ getFrameworkRules(): FrameworkRule[]; /** * Clean up resources (no-op for regex-based parsing) */ dispose(): void; /** * Check if an identifier is exported (starts with uppercase) * * In Go, identifiers starting with uppercase are exported (public) * and can be accessed from other packages. * * @param name - Identifier name * @returns True if the identifier is exported */ private isExported; /** * Extract import statements from Go source * * Handles both single imports and import blocks: * - import "fmt" * - import ( "fmt" \n "os" ) * - import alias "path/to/package" */ private extractImports; /** * Extract exports (public declarations) from Go source * * In Go, any top-level declaration starting with uppercase is exported: * - type Foo struct/interface * - func Foo() or func (r *Receiver) Foo() * - const/var Foo */ private extractExports; /** * Extract function definitions from Go source * * Handles both regular functions and methods: * - func name(params) return * - func (r *Receiver) name(params) return */ private extractFunctions; } /** * Parse go.mod file to extract module info and dependencies * * @param content - Content of go.mod file * @returns Parsed go.mod information * * @example * ```typescript * const modInfo = parseGoMod(goModContent) * console.log(modInfo.module) // "github.com/user/project" * console.log(modInfo.require) // [{ path: "...", version: "..." }] * ``` */ export declare function parseGoMod(content: string): GoModInfo; //# sourceMappingURL=go.d.ts.map