Documentation
¶
Overview ¶
Package signature provides utilities for extracting and formatting Go function signatures and types.
This package handles:
- Extracting function signatures from types.Signature
- Type qualification using import aliases
- Converting types to strings with proper package selectors
The Extractor type maintains the context needed for proper type qualification, including the current package and import aliases from the source code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor extracts function signatures and formats types with proper package qualification.
func New ¶
New creates a signature extractor.
The currentPackage is used to determine when type qualification is needed. The importAliases map provides the mapping from import paths to the aliases used in the source code (e.g., "net/http/httputil" -> "httputil").
func (*Extractor) ElidedQualifier ¶
ElidedQualifier returns the selector used for a type, as its import package alias used in source, or the empty string if this is a local declaration.
func (*Extractor) ElidedType ¶
ElidedType returns a string representation of the type with package names as they appear in source.
Uses import aliases when available (e.g., "httputil.Handler" if imported as "httputil").
func (*Extractor) ExtractFunctionSignature ¶
func (e *Extractor) ExtractFunctionSignature(signature *types.Signature, name string) model.Function
ExtractFunctionSignature extracts function signature details from a types.Signature.
This is used for both regular functions and function types (var/type declarations).