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 Directive(name string) directive
- func Function(opts ...FunctionOption) *functionDeclaration
- func FunctionBody(up Point) *functionBody
- func FunctionCall(pattern string) *functionCall
- func ImportPath(name string) importPath
- func Not(jp Point) not
- func OneOf(candidates ...Point) oneOf
- func OneOfFunctions(opts ...FunctionOption) oneOfFunctions
- 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 ValueDeclaration(typeName TypeName) *valueDeclaration
- type FunctionOption
- type Point
- type StructLiteralMatch
- type TypeName
- func (n TypeName) AsCode() jen.Code
- func (n *TypeName) AsNode() dst.Expr
- 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
- func (n TypeName) RenderHTML() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configuration ¶
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 FunctionCall(pattern string) *functionCall
func ImportPath ¶
func ImportPath(name string) importPath
func OneOfFunctions ¶
func OneOfFunctions(opts ...FunctionOption) oneOfFunctions
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 ValueDeclaration ¶
func ValueDeclaration(typeName TypeName) *valueDeclaration
Types ¶
type FunctionOption ¶
type FunctionOption interface {
// 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 { // AsCode produces a jen.Code representation of the receiver. AsCode() jen.Code // 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 }
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) 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.