Documentation
¶
Overview ¶
Copyright © 2024 Gareth Watts <gareth@omnipotent.net>
Mostly written by an LLM.
Index ¶
- func Format(source string) string
- type ASTProcessor
- func (a *ASTProcessor) ExtractFullCall(filePath string, line, character int) (string, error)
- func (a *ASTProcessor) FindFuncDefinitions(pkgPath string, funcPattern ...string) (matches []Match, err error)
- func (a *ASTProcessor) GetEnclosingFunctionName(filePath string, line, character int) (functionName, receiverType, receiverName string, err error)
- func (a *ASTProcessor) ParseFile(filePath string) error
- type Match
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ASTProcessor ¶
type ASTProcessor struct {
// contains filtered or unexported fields
}
ASTProcessor handles parsing source files and extracting method calls.
func NewASTProcessor ¶
func NewASTProcessor() *ASTProcessor
NewASTProcessor creates a new ASTProcessor.
func (*ASTProcessor) ExtractFullCall ¶
func (a *ASTProcessor) ExtractFullCall(filePath string, line, character int) (string, error)
ExtractFullCall extracts the call expression corresponding to the reference.
func (*ASTProcessor) FindFuncDefinitions ¶
func (a *ASTProcessor) FindFuncDefinitions(pkgPath string, funcPattern ...string) (matches []Match, err error)
FindFuncDefinitions locates the position of all supplied exported functions or methods within a package. funcPattern is one or more globs. methods can be specified as `TypeName.MethodName`
func (*ASTProcessor) GetEnclosingFunctionName ¶
func (a *ASTProcessor) GetEnclosingFunctionName(filePath string, line, character int) (functionName, receiverType, receiverName string, err error)
GetEnclosingFunctionName finds the name and receiver type of the function/method containing the given position.
func (*ASTProcessor) ParseFile ¶
func (a *ASTProcessor) ParseFile(filePath string) error
ParseFile parses a Go source file and caches the AST.
type Match ¶
type Match struct { Pkg string RecvType string RecvName string FuncName string Filename string OffsetLine int OffsetCol int }
Match holds a matching function reference located by FindFuncDefinitions.
func (Match) MethodName ¶
MethodName returns the pretty-printed name of a method or function call.