Documentation ¶
Index ¶
- Constants
- Variables
- func CreateTargetDir(path string, suffix string) string
- func ExecuteAnnotator(ctx *Context, ator Annotator, filtered []*Annotation) error
- func IsFunc(d *Annotation) bool
- func IsInterface(d *Annotation) bool
- func IsPublic(d *Annotation) bool
- func IsStruct(d *Annotation) bool
- func MappedAnnotsByFile(annots []*Annotation) map[*File][]*Annotation
- func PackageName(path string) string
- func ParseRawAnnot(raw string) (name, params string)
- func StructTag(tag *ast.BasicLit) reflect.StructTag
- func WriteCoder(c *typgo.Context, coder Coder, target string) error
- type AliasGenerator
- type AnnotProcessor
- type AnnotatedFileProcessor
- type Annotation
- type Annotator
- type CodeGenerator
- type CodeLine
- type CodeLines
- type Coder
- type Coders
- type Context
- func (i *Context) AppendFileCoder(file *File, coder Coder)
- func (c *Context) AppendInit(s string)
- func (i *Context) AppendInitf(format string, args ...interface{})
- func (i *Context) ProvideConstructor(name, importPath, constructor string)
- func (i *Context) WriteFile(f *File, target string) error
- func (i *Context) WriteInitFile(target string) error
- type Decl
- type Field
- type FieldList
- type File
- type FilePaths
- type Function
- type GenDecl
- type Import
- type Interface
- type Layouts
- type PostAnnotator
- type PreAnnotator
- type Struct
- type Type
- type TypeDecl
- type Walker
Constants ¶
View Source
const (
DefaultParent = "internal/generated"
)
View Source
const (
InitFilePath = "internal/generated/init.go"
)
Variables ¶
View Source
var ( DefaultInitImports = map[string]string{ "github.com/kmrtftech/tg-framework/pkg/typapp": "", } InfoSignature = CodeLine("// DO NOT EDIT. Code-generated file\n") )
Functions ¶
func CreateTargetDir ¶
func ExecuteAnnotator ¶
func ExecuteAnnotator(ctx *Context, ator Annotator, filtered []*Annotation) error
func IsFunc ¶
func IsFunc(d *Annotation) bool
func IsInterface ¶
func IsInterface(d *Annotation) bool
func IsPublic ¶
func IsPublic(d *Annotation) bool
func IsStruct ¶
func IsStruct(d *Annotation) bool
func MappedAnnotsByFile ¶
func MappedAnnotsByFile(annots []*Annotation) map[*File][]*Annotation
func PackageName ¶
func ParseRawAnnot ¶
ParseRawAnnot parse raw string to annotation
Types ¶
type AliasGenerator ¶
type AliasGenerator struct { Map map[string]string // key is import package , value is import alias // contains filtered or unexported fields }
func NewAliasGenerator ¶
func NewAliasGenerator(m map[string]string) *AliasGenerator
func (*AliasGenerator) Generate ¶
func (i *AliasGenerator) Generate(val string) string
func (*AliasGenerator) Imports ¶
func (i *AliasGenerator) Imports() []*Import
func (*AliasGenerator) Keys ¶
func (i *AliasGenerator) Keys() []string
type AnnotProcessor ¶
type AnnotProcessor interface {
ProcessAnnot(*Context, *Annotation) error
}
type AnnotatedFileProcessor ¶
type AnnotatedFileProcessor interface {
ProcessAnnotatedFile(*Context, *File, []*Annotation) error
}
type Annotation ¶
type Annotation struct { Name string `json:"name"` Params reflect.StructTag `json:"params"` Decl *Decl `json:"decl"` }
Annotation that contain extra additional information
func Compile ¶
func Compile(paths ...string) ([]*Annotation, error)
func Filter ¶
func Filter(annotations []*Annotation, annotator Annotator) []*Annotation
func (*Annotation) Dir ¶
func (d *Annotation) Dir() string
func (*Annotation) PackagePath ¶
func (d *Annotation) PackagePath() string
func (*Annotation) Path ¶
func (d *Annotation) Path() string
type Annotator ¶
type Annotator interface { AnnotationName() string IsAllowed(*Annotation) bool }
type CodeGenerator ¶
type Context ¶
type Context struct { *typgo.Context InitAliasGen *AliasGenerator InitFuncBody CodeLines MappedCoders map[*File][]Coder Annotations []*Annotation }
func NewContext ¶
func NewContext(c *typgo.Context, annots []*Annotation) *Context
func (*Context) AppendFileCoder ¶
func (*Context) AppendInit ¶
func (*Context) AppendInitf ¶
func (*Context) ProvideConstructor ¶
func (*Context) WriteInitFile ¶
type Function ¶
type Function struct { Name string Docs []string Recv []*Field Params []*Field Returns []*Field Body Coder }
Function declaration
type Import ¶
func CreateImports ¶
type Interface ¶
type Interface struct {
TypeDecl
}
Interface interface declaration
func CreateInterfaceDecl ¶
type PostAnnotator ¶
type PostAnnotator interface {
AfterAnnotate(*Context, []*Annotation) error
}
type PreAnnotator ¶
type PreAnnotator interface {
BeforeAnnotate(*Context, []*Annotation) error
}
type Struct ¶
Struct declaration
func CreateStructDecl ¶
func CreateStructDecl(typeDecl TypeDecl, structType *ast.StructType) *Struct
Click to show internal directories.
Click to hide internal directories.