join

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package join provides implementations of the InjectionPoint interface for common injection points.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllOf

func AllOf(requirements ...Point) allOf

func Configuration

func Configuration(requirements map[string]string) configuration

func Directive

func Directive(name string) directive

func Function

func Function(opts ...FunctionOption) *funcDecl

Function matches function declaration nodes based on properties of their signature.

func FunctionBody

func FunctionBody(up Point) *funcBody

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 Not

func Not(jp Point) not

func OneOf

func OneOf(candidates ...Point) oneOf

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

func StructLiteralField(typeName TypeName, field string) *structLiteral

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 {
	code.AsCode
	// contains filtered or unexported methods
}

func Name

func Name(name string) FunctionOption

func Receiver

func Receiver(typeName TypeName) FunctionOption

func Receives

func Receives(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 {
	code.AsCode

	// 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

	// RenderHTML renders an HTML block containing the join point's description
	// for documentation purposes.
	RenderHTML() string
}

Point is the interface that abstracts selection of nodes where to inject code.

func FromYAML

func FromYAML(node *yaml.Node) (Point, error)

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

func MustTypeName(n string) (tn TypeName)

MustTypeName is the same as NewTypeName, except it panics in case of an error.

func NewTypeName

func NewTypeName(n string) (tn TypeName, err error)

func (*TypeName) AsCode

func (n *TypeName) AsCode() jen.Code

func (*TypeName) AsNode

func (n *TypeName) AsNode() dst.Expr

func (*TypeName) ImportPath

func (n *TypeName) ImportPath() string

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

func (n *TypeName) Matches(node dst.Expr) bool

Matches determines whether the provided node represents the same type as this TypeName.

func (*TypeName) MatchesDefinition

func (n *TypeName) MatchesDefinition(node dst.Expr, importPath string) bool

MacthesDefinition determines whether the provided node matches the definition of this TypeName. The `importPath` argument determines the context in which the assertion is made.

func (*TypeName) Name

func (n *TypeName) Name() string

Name returns the unqualified name of this type.

func (*TypeName) Pointer

func (n *TypeName) Pointer() bool

Pointer returns whether this is a pointer type.

func (*TypeName) RenderHTML

func (n *TypeName) RenderHTML() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL