Documentation
¶
Index ¶
- type BaseNode
- type CallableOps
- func (c CallableOps) Body() string
- func (c CallableOps) Code() string
- func (c CallableOps) Comments() string
- func (c CallableOps) Parameters() []NamedType
- func (c CallableOps) PrintBody()
- func (c CallableOps) PrintReturnType()
- func (c CallableOps) PrintSignature()
- func (c CallableOps) ReturnType() string
- func (c CallableOps) ReturnTypes() []string
- func (c CallableOps) Signature() string
- type FuncConfig
- type FuncNode
- type MethodConfig
- type MethodNode
- func (m MethodNode) Code() string
- func (m MethodNode) FieldsAccessed() []string
- func (m MethodNode) HasPointerReceiver() bool
- func (m MethodNode) MethodsCalled() []string
- func (m MethodNode) Name() string
- func (m MethodNode) PrintComments()
- func (m MethodNode) PrintNode()
- func (m MethodNode) ReceiverName() string
- func (m MethodNode) ReceiverType() string
- type NamedType
- type NodeInfo
- type StructConfig
- type StructNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseNode ¶
type BaseNode struct { // Name of the code element (e.g., function or struct name) Name string // Path to the file where the element is defined Path string // Line number where the element starts Line int // Number of characters from the start of the file to the element Characters int // Whether the element is exported (starts with uppercase letter) Exported bool // Leading comment associated with the element Comment string }
BaseNode contains shared metadata about code elements like structs, methods, and functions.
type CallableOps ¶
type CallableOps struct {
// contains filtered or unexported fields
}
CallableOps contains logic for extracting code and metadata from AST function declarations.
func (CallableOps) Body ¶
func (c CallableOps) Body() string
Body returns the string representation of the function body.
func (CallableOps) Code ¶
func (c CallableOps) Code() string
Code returns the full source code of the function, optionally including comments.
func (CallableOps) Comments ¶
func (c CallableOps) Comments() string
Comments returns the associated documentation comments for the function.
func (CallableOps) Parameters ¶
func (c CallableOps) Parameters() []NamedType
Parameters returns a slice of parameter names and types for the function.
func (CallableOps) PrintBody ¶
func (c CallableOps) PrintBody()
PrintBody prints the body of the function.
func (CallableOps) PrintReturnType ¶
func (c CallableOps) PrintReturnType()
PrintReturnType prints the function's return type(s).
func (CallableOps) PrintSignature ¶
func (c CallableOps) PrintSignature()
PrintSignature prints the function's signature (name + parameters).
func (CallableOps) ReturnType ¶
func (c CallableOps) ReturnType() string
ReturnType returns a string representing the function's return type(s).
func (CallableOps) ReturnTypes ¶
func (c CallableOps) ReturnTypes() []string
ReturnTypes returns a slice of string representations of all return types.
func (CallableOps) Signature ¶
func (c CallableOps) Signature() string
Signature returns the function's name and parameter list.
type FuncConfig ¶
type FuncConfig struct { // Name of the function. Name string // Expected parameter types (a subset unless exact is specified). ParamTypes []NamedType // Expected return types (a subset unless exact is specified). ReturnTypes []string // If true, function should have no parameters. NoParams *bool // If true, function should have no return values. NoReturn *bool // If true, all criteria slices must match exactly. Exact bool }
FuncConfig holds configuration for scouting a function in source code.
type FuncNode ¶
type FuncNode struct { // Node contains metadata such as name, path, line number, etc. Node BaseNode // CallableOps provides operations and data tied to the function's AST node CallableOps CallableOps }
FuncNode represents a top-level function with its metadata and operations.
func ScoutFunction ¶
func ScoutFunction(path string, config FuncConfig) (*FuncNode, error)
ScoutFunction returns the first function in the given path matching the config.
func ScoutFunctions ¶
func ScoutFunctions(path string, config FuncConfig) ([]*FuncNode, error)
ScoutFunctions returns all functions in the given path matching the config.
func (FuncNode) PrintComments ¶
func (f FuncNode) PrintComments()
PrintComments prints the function's associated comments.
type MethodConfig ¶
type MethodConfig struct { // Name of the method. Name string // Expected parameter types (a subset unless exact is specified). ParamTypes []NamedType // Expected return types (a subset unless exact is specified). ReturnTypes []string // Type of the receiver. Receiver string // If true, method must have pointer receiver. IsPointerRec *bool // Struct fields that must be accessed within method. Fields []string // Struct methods that must be called within method. Methods []string // If true, method should have no parameters. NoParams *bool // If true, method should have no return values. NoReturn *bool // If true, the method must not access any of the struct fields. NoFields *bool // If true, the method must not call any of the struct methods. NoMethods *bool // If true, all criteria slices must match exactly. Exact bool }
MethodConfig holds configuration for scouting a method in source code.
type MethodNode ¶
type MethodNode struct { // Node contains metadata such as name, path, line number, etc. Node BaseNode // CallableOps provides operations and data tied to the method's AST node CallableOps CallableOps // contains filtered or unexported fields }
MethodNode represents a method with its associated metadata and interactions.
func ScoutMethod ¶
func ScoutMethod(path string, config MethodConfig) (*MethodNode, error)
ScoutMethod returns the first method in the given path matching the config.
func ScoutMethods ¶
func ScoutMethods(path string, config MethodConfig) ([]*MethodNode, error)
ScoutMethods returns all methods in the given path matching the config.
func (MethodNode) Code ¶
func (m MethodNode) Code() string
Code returns the full source code of the method.
func (MethodNode) FieldsAccessed ¶
func (m MethodNode) FieldsAccessed() []string
FieldsAccessed returns a slice of field names accessed by this method.
func (MethodNode) HasPointerReceiver ¶
func (m MethodNode) HasPointerReceiver() bool
HasPointerReceiver checks whether the method has a pointer receiver.
func (MethodNode) MethodsCalled ¶
func (m MethodNode) MethodsCalled() []string
MethodsCalled returns a slice of method names called by this method.
func (MethodNode) PrintComments ¶
func (m MethodNode) PrintComments()
PrintComments prints the method's associated documentation comments.
func (MethodNode) ReceiverName ¶
func (m MethodNode) ReceiverName() string
ReceiverName returns the name of the receiver variable (e.g., "m" in "func (m *MyStruct) ...").
func (MethodNode) ReceiverType ¶
func (m MethodNode) ReceiverType() string
ReceiverType returns the type name of the method's receiver.
type StructConfig ¶
type StructConfig struct { // Name of the struct. Name string // Expected field names and types. FieldTypes []NamedType // If true, struct should not have fields. NoFields *bool // If true, all criteria slices must match exactly. Exact bool }
StructConfig holds configuration for scouting a struct type in source code.
type StructNode ¶
type StructNode struct { // Node contains metadata such as name, path, line number, etc. Node BaseNode // Methods holds all methods associated with this struct Methods []*MethodNode // contains filtered or unexported fields }
StructNode represents a Go struct declaration in the AST.
func ScoutStruct ¶
func ScoutStruct(path string, config StructConfig) (*StructNode, error)
ScoutStruct returns the first struct in the given path matching the config.
func ScoutStructs ¶
func ScoutStructs(path string, config StructConfig) ([]*StructNode, error)
ScoutStructs returns all structs in the given path matching the config.
func (StructNode) Body ¶
func (s StructNode) Body() string
Body returns the string representation of the struct's fields only.
func (StructNode) Code ¶
func (s StructNode) Code() string
Code returns the source code representation of the struct declaration.
func (StructNode) Comments ¶
func (s StructNode) Comments() string
Comments returns documentation comments associated with the struct declaration.
func (StructNode) Fields ¶
func (s StructNode) Fields() []NamedType
Fields extracts all named fields from the struct definition.
func (StructNode) PrintComments ¶
func (s StructNode) PrintComments()
PrintComments prints comments associated with the struct.
func (StructNode) PrintNode ¶
func (s StructNode) PrintNode()
PrintNode prints the full code of the struct.
func (StructNode) Signature ¶
func (s StructNode) Signature() string
Signature returns the struct name along with any generic type parameters.