Documentation ¶
Overview ¶
Package join provides implementations of the InjectionPoint interface for common injection points.
Index ¶
- func AllOf(requirements ...Point) allOf
- func Configuration(requirements map[string]string) configuration
- func DeclarationOf(importPath string, name string) *declarationOf
- func Directive(name string) directive
- func Function(opts ...FunctionOption) *functionDeclaration
- func FunctionBody(up Point) *functionBody
- func FunctionCall(importPath string, name string) *functionCall
- func ImportPath(name string) importPath
- func Not(jp Point) not
- func OneOf(candidates ...Point) oneOf
- func PackageName(name string) packageName
- func StructDefinition(typeName TypeName) *structDefinition
- func StructLiteral(typeName TypeName, match StructLiteralMatch) *structLiteral
- func StructLiteralField(typeName TypeName, field string) *structLiteral
- func TestMain(v bool) testMain
- func ValueDeclaration(typeName TypeName) *valueDeclaration
- type FunctionOption
- type Point
- type StructLiteralMatch
- type TypeName
- func (n *TypeName) AsNode() dst.Expr
- func (n TypeName) Hash(h *fingerprint.Hasher) error
- func (n TypeName) ImportPath() string
- func (n TypeName) Matches(node dst.Expr) bool
- func (n TypeName) MatchesDefinition(node dst.Expr, importPath string) bool
- func (n TypeName) Name() string
- func (n TypeName) Pointer() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configuration ¶
func DeclarationOf ¶ added in v0.9.4
DeclarationOf matches the (top-level) declaration of the specified symbol.
func Function ¶
func Function(opts ...FunctionOption) *functionDeclaration
Function matches function declaration nodes based on properties of their signature.
func FunctionBody ¶
func FunctionBody(up Point) *functionBody
FunctionBody returns the *dst.BlockStmt of the matched *dst.FuncDecl body.
func FunctionCall ¶
func ImportPath ¶
func ImportPath(name string) importPath
func PackageName ¶
func PackageName(name string) packageName
func StructDefinition ¶
func StructDefinition(typeName TypeName) *structDefinition
StructDefinition matches the definition of a particular struct given its fully qualified name.
func StructLiteral ¶
func StructLiteral(typeName TypeName, match StructLiteralMatch) *structLiteral
StructLiteral matches struct literal expressions of the designated type, filtered by the specified match type.
func StructLiteralField ¶
StructLiteralField matches a specific field in struct literals of the designated type.
func TestMain ¶ added in v1.0.2
func TestMain(v bool) testMain
TestMain matches only nodes in ASTs in files that either are (if true), or are not (if false) part of a synthetic test main package.
func ValueDeclaration ¶
func ValueDeclaration(typeName TypeName) *valueDeclaration
Types ¶
type FunctionOption ¶
type FunctionOption interface { fingerprint.Hashable // contains filtered or unexported methods }
func Name ¶
func Name(name string) FunctionOption
func Receiver ¶
func Receiver(typeName TypeName) FunctionOption
func Signature ¶
func Signature(args []TypeName, ret []TypeName) FunctionOption
Signature matches function declarations based on their arguments and return value types.
type Point ¶
type Point interface { // ImpliesImported returns a list of import paths that are known to already be // imported if the join point matches. ImpliesImported() []string // Matches determines whether the injection should be performed on the given // node or not. The node's ancestry is also provided to allow Point to make // decisions based on parent nodes. Matches(ctx context.AspectContext) bool fingerprint.Hashable }
Point is the interface that abstracts selection of nodes where to inject code.
type StructLiteralMatch ¶
type StructLiteralMatch int
const ( // StructLiteralMatchAny matches struct literals regardless of whether they are pointer or value. // [StructLiteral] join points specified with this match type may match [*dst.CompositeLit] or // [*dst.UnaryExpr] nodes. StructLiteralMatchAny StructLiteralMatch = iota // StructLiteralMatchValueOnly matches struct literals that are not pointers. [StructLiteral] join // points specified with this match type only ever match [*dst.CompositeLit] nodes. StructLiteralMatchValueOnly // StructLiteralMatchPointerOnly matches struct literals that are pointers. [StructLiteral] join // points specified with this match type only ever match [*dst.UnaryExpr] nodes. StructLiteralMatchPointerOnly )
func (StructLiteralMatch) Hash ¶ added in v1.0.0
func (s StructLiteralMatch) Hash(h *fingerprint.Hasher) error
func (StructLiteralMatch) String ¶
func (s StructLiteralMatch) String() string
func (*StructLiteralMatch) UnmarshalYAML ¶
func (s *StructLiteralMatch) UnmarshalYAML(node *yaml.Node) error
type TypeName ¶
type TypeName struct {
// contains filtered or unexported fields
}
func MustTypeName ¶
MustTypeName is the same as NewTypeName, except it panics in case of an error.
func NewTypeName ¶
func (TypeName) ImportPath ¶
ImportPath returns the import path for this type name, or a blank string if this refers to a local or built-in type.
func (TypeName) Matches ¶
Matches determines whether the provided node represents the same type as this TypeName.
func (TypeName) MatchesDefinition ¶
MacthesDefinition determines whether the provided node matches the definition of this TypeName. The `importPath` argument determines the context in which the assertion is made.