astutils

package
v0.0.0-...-f6bedb9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CommentProxy for struct while comment @Proxy generate a file with _gen.go suffix
	CommentProxy = Annotation("@Proxy")
	// CommentPointcut for struct function while comment @Pointcut generate a proxy func for proxy struct
	CommentPointcut = Annotation("@Pointcut")
	// CommentAspect for struct while comment @Aspect then use to enhance other function
	CommentAspect = Annotation("@Aspect")
	// CommentAdviceBefore for struct function while comment @Before then use to enhance other function
	CommentAdviceBefore = Annotation("@Before")
	// CommentAdviceAfter for struct function while comment @After then use to enhance other function
	CommentAdviceAfter = Annotation("@After")
	// CommentAdviceAround for struct function while comment @Around then use to enhance other function
	CommentAdviceAround = Annotation("@Around")
	// CommentComponent for struct factory method while comment @Component then use to inject proxy struct
	CommentComponent = Annotation("@Component")
	// CommentInject for struct field while comment @Inject then use to inject proxy struct
	CommentInject = Annotation("@Inject")

	// CommentKeyDefault key for comment params separated by "="
	CommentKeyDefault = AnnotationKey("default")
	// CommentKeyDefault abstract key for @Proxy comment
	CommentKeyAbstract  = AnnotationKey("abstract")
	CommentKeySuffix    = AnnotationKey("suffix")
	CommentKeyCustom    = AnnotationKey("custom")
	CommentKeyOption    = AnnotationKey("option")
	CommentKeySingleton = AnnotationKey("singleton")
)
View Source
const (
	DefaultProxySuffix = "Proxy"
)

Variables

This section is empty.

Functions

func GetCommentParam

func GetCommentParam(c *ast.CommentGroup, a Annotation) (ret map[AnnotationKey]string)

func GetProxyTpl

func GetProxyTpl() string

func IsSystemAnnotation

func IsSystemAnnotation(anno Annotation) bool

func IsSystemAnnotationKey

func IsSystemAnnotationKey(key AnnotationKey) bool

func IsTypeIdent

func IsTypeIdent(expr ast.Expr) (*ast.Ident, bool)

func ParseAdviceStmt

func ParseAdviceStmt(advice aspect.Advice, method aspect.Method) []string

func ParseAroundAdvice

func ParseAroundAdvice(advice aspect.Advice, method aspect.Method) ([]string, []string)

func RegisterFieldInterceptors

func RegisterFieldInterceptors(opts ...FieldInterceptor)

func RegisterProxyInterceptors

func RegisterProxyInterceptors(opts ...ProxyInterceptor)

Types

type Annotation

type Annotation string

func AdviceAnnotationList

func AdviceAnnotationList() []Annotation

func (Annotation) String

func (a Annotation) String() string

type AnnotationKey

type AnnotationKey string

type FieldInterceptor

type FieldInterceptor func([]Annotation, aspect.Field, *ast.Field) []aspect.FieldOption

type File

type File struct {
	Pkg     *Package  // Package to which this file belongs.
	File    *ast.File // Parsed AST.
	Imports map[string]string
}

File holds a single parsed file and associated data.

func (*File) InspectFuncDecl

func (f *File) InspectFuncDecl(node ast.Node) bool

func (*File) InspectGenDecl

func (f *File) InspectGenDecl(node ast.Node) bool

InspectGenDecl processes one node.

type Package

type Package struct {
	Path              string
	Pwd               string
	Name              string
	AstPkg            *packages.Package
	Files             []*File
	Defs              map[*ast.Ident]types.Object
	OutputFiles       map[string][]byte
	FileBuf           map[string]bytes.Buffer
	AspectCache       map[string]aspect.Aspect
	AspectAlias       map[string]string
	AspectCustoms     map[Annotation]string
	ProxyCache        map[*ast.Ident]aspect.Proxy
	DelayAspectLoader map[Annotation][]func()
	ComponentCache    map[string]aspect.Component
}

func (*Package) ImportPath

func (p *Package) ImportPath() string

type ProxyData

type ProxyData struct {
	Package         string
	Imports         []*ProxyImport
	ProxyStructName string
	Option          string
	Methods         []*ProxyMethod
	AbstractName    string
	ParentName      string
	InjectFields    []*ProxyInjectField
	Singleton       bool
}

type ProxyImport

type ProxyImport struct {
	Alias template.HTML
	Path  template.HTML
}

func GetImports

func GetImports(specs []*ast.ImportSpec) []*ProxyImport

type ProxyInjectField

type ProxyInjectField struct {
	Var template.HTML
	Val template.HTML
}

type ProxyInterceptor

type ProxyInterceptor func([]Annotation, aspect.Proxy, *ast.StructType) []aspect.ProxyOption

type ProxyMethod

type ProxyMethod struct {
	Name        string
	Params      string
	ParamNames  string
	Results     string
	ResultNames string
	Before      []any
	After       []any
}

Jump to

Keyboard shortcuts

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