Documentation
¶
Index ¶
- Constants
- Variables
- func FilterUserFiles(files []string) []string
- func FindCommonDir(files []string) string
- func RunCodegen(dir string, verbose bool) error
- type BatchCall
- type BatchResult
- type CodeProcessor
- type Config
- type FileProcessor
- func (fp *FileProcessor) CollectAllGoFiles(dir string) ([]string, error)
- func (fp *FileProcessor) FilterFilesWithMarkers(files []string) []string
- func (fp *FileProcessor) FindFunctionFiles(dir string) error
- func (fp *FileProcessor) IsFunctionFile(path string) bool
- func (fp *FileProcessor) LoadUserFunctions() error
- func (fp *FileProcessor) ProcessDirectory(dir string, verbose bool, codeProcessor *CodeProcessor) error
- func (fp *FileProcessor) ProcessDirectoryInjections(dir string, verbose bool, injector *Injector) error
- type FunctionExecutor
- type InjectionResult
- type Injector
- type ProcessorContext
- func (ctx *ProcessorContext) CalculateDepth(dir string) int
- func (ctx *ProcessorContext) FormatDepthInfo() string
- func (ctx *ProcessorContext) GetFunctionCountByDepth(depth int) int
- func (ctx *ProcessorContext) GetMaxDepth() int
- func (ctx *ProcessorContext) ResolveFunction(name, sourceDir string) (*UserFunction, string)
- type ToolexecManager
- type UserFunction
Constants ¶
const ( FunctionMarker = "//go:ahead functions" CommentPattern = `^\s*//\s*:([^:]+)(?::(.*))?` ExecutionTemplate = `` /* 278-byte string literal not displayed */ ExecutionBatchTemplate = `` /* 353-byte string literal not displayed */ )
const InjectPattern = `^\s*//\s*:inject:(\w+)\s*$`
InjectPattern matches //:inject:MethodName
Variables ¶
var ( GoInstallPaths = []string{ "/usr/lib/go", "/usr/local/go", "/opt/go", "\\Go\\", } SystemPaths = []string{ "/runtime/", "/internal/", "/vendor/", "/pkg/mod/", "\\runtime\\", "\\internal\\", "\\vendor\\", "\\pkg\\mod\\", } )
var Version = getVersion()
Functions ¶
func FilterUserFiles ¶
func FindCommonDir ¶
func RunCodegen ¶
Types ¶
type BatchResult ¶ added in v0.2.9
type BatchResult struct {
Result string
UserFunc *UserFunction
Err error
}
type CodeProcessor ¶
type CodeProcessor struct {
// contains filtered or unexported fields
}
func NewCodeProcessor ¶
func NewCodeProcessor(ctx *ProcessorContext, executor *FunctionExecutor) *CodeProcessor
func (*CodeProcessor) ProcessFile ¶
func (cp *CodeProcessor) ProcessFile(filePath string, verbose bool) error
type FileProcessor ¶
type FileProcessor struct {
// contains filtered or unexported fields
}
func NewFileProcessor ¶
func NewFileProcessor(ctx *ProcessorContext) *FileProcessor
func (*FileProcessor) CollectAllGoFiles ¶ added in v0.2.8
func (fp *FileProcessor) CollectAllGoFiles(dir string) ([]string, error)
CollectAllGoFiles walks the directory tree once and collects all .go files It also identifies function files and stores them in ctx.FuncFiles Submodules (directories with their own go.mod) are detected and stored separately
func (*FileProcessor) FilterFilesWithMarkers ¶ added in v0.2.8
func (fp *FileProcessor) FilterFilesWithMarkers(files []string) []string
FilterFilesWithMarkers quickly checks which files contain placeholder or inject markers Uses parallel scanning for speed
func (*FileProcessor) FindFunctionFiles ¶
func (fp *FileProcessor) FindFunctionFiles(dir string) error
FindFunctionFiles is kept for backward compatibility but now just wraps CollectAllGoFiles
func (*FileProcessor) IsFunctionFile ¶
func (fp *FileProcessor) IsFunctionFile(path string) bool
func (*FileProcessor) LoadUserFunctions ¶
func (fp *FileProcessor) LoadUserFunctions() error
func (*FileProcessor) ProcessDirectory ¶
func (fp *FileProcessor) ProcessDirectory(dir string, verbose bool, codeProcessor *CodeProcessor) error
func (*FileProcessor) ProcessDirectoryInjections ¶ added in v0.2.0
func (fp *FileProcessor) ProcessDirectoryInjections(dir string, verbose bool, injector *Injector) error
type FunctionExecutor ¶
type FunctionExecutor struct {
// contains filtered or unexported fields
}
func NewFunctionExecutor ¶
func NewFunctionExecutor(ctx *ProcessorContext) *FunctionExecutor
func (*FunctionExecutor) ExecuteBatch ¶ added in v0.2.9
func (fe *FunctionExecutor) ExecuteBatch(calls []BatchCall, sourceDir string) []BatchResult
func (*FunctionExecutor) ExecuteFunction ¶
func (fe *FunctionExecutor) ExecuteFunction(funcName string, argsStr string, sourceDir string) (string, *UserFunction, error)
func (*FunctionExecutor) Prepare ¶
func (fe *FunctionExecutor) Prepare() error
type InjectionResult ¶ added in v0.2.0
type InjectionResult struct {
FunctionCode string
FunctionDecls map[string]string // Individual function declarations keyed by name
DepDecls map[string]string // Individual dependency declarations (const/var/type) keyed by name
Imports []string
Constants string
Variables string
Types string
}
InjectionResult contains the extracted function and its dependencies
type Injector ¶ added in v0.2.0
type Injector struct {
// contains filtered or unexported fields
}
Injector handles function injection from helper files
func NewInjector ¶ added in v0.2.0
func NewInjector(ctx *ProcessorContext) *Injector
NewInjector creates a new Injector
func (*Injector) ExtractFunction ¶ added in v0.2.0
func (inj *Injector) ExtractFunction(funcName, sourceDir string) (*InjectionResult, error)
ExtractFunction extracts a function and its dependencies from helper files
func (*Injector) ProcessFileInjections ¶ added in v0.2.0
ProcessFileInjections handles all //:inject: directives in a file. Inject markers must appear above an interface declaration. The method name must exist in that interface.
type ProcessorContext ¶
type ProcessorContext struct {
// FunctionsByDepth maps depth level to functions defined at that depth
// Key is the depth (0 = root), value is map of function name to function
FunctionsByDepth map[int]map[string]*UserFunction
// FunctionsByDir maps directory path to functions defined in that directory
// Key is the absolute directory path, value is map of function name to function
FunctionsByDir map[string]map[string]*UserFunction
// RootDir is the root directory being processed (for hierarchy resolution)
RootDir string
// Verbose enables detailed logging
Verbose bool
// Submodules contains paths to directories with their own go.mod (treated as separate projects)
Submodules []string
FileSet *token.FileSet
CurrentFile string
FuncFiles []string
TempDir string
}
func (*ProcessorContext) CalculateDepth ¶ added in v0.2.6
func (ctx *ProcessorContext) CalculateDepth(dir string) int
CalculateDepth returns the depth of a directory relative to RootDir
func (*ProcessorContext) FormatDepthInfo ¶ added in v0.2.6
func (ctx *ProcessorContext) FormatDepthInfo() string
FormatDepthInfo returns a formatted string showing functions by depth
func (*ProcessorContext) GetFunctionCountByDepth ¶ added in v0.2.6
func (ctx *ProcessorContext) GetFunctionCountByDepth(depth int) int
GetFunctionCountByDepth returns total functions at a specific depth
func (*ProcessorContext) GetMaxDepth ¶ added in v0.2.6
func (ctx *ProcessorContext) GetMaxDepth() int
GetMaxDepth returns the maximum depth with functions defined
func (*ProcessorContext) ResolveFunction ¶ added in v0.2.0
func (ctx *ProcessorContext) ResolveFunction(name, sourceDir string) (*UserFunction, string)
ResolveFunction finds a function using depth-based resolution. It first searches from the source file's depth down to depth 0 (closest wins). If not found, it searches deeper depths so all project helpers are visible. Returns the function and the helper file path it came from.
type ToolexecManager ¶
type ToolexecManager struct{}
func NewToolexecManager ¶
func NewToolexecManager() *ToolexecManager
func (*ToolexecManager) RunAsToolexec ¶
func (tm *ToolexecManager) RunAsToolexec()
RunAsToolexec esegue goahead come wrapper toolexec