Documentation
¶
Index ¶
- Constants
- Variables
- func BuildComment(comment *ast.CommentGroup) string
- func BuildDoc(doc *ast.CommentGroup) string
- func BuildIdent(ident *ast.Ident) string
- func BuildIdentList(idents []*ast.Ident) []string
- func IntFromExpr(expr Expr) (string, bool)
- func IsValidKind(kind string) bool
- func JoinBeanKey(pkgName, beanName string) string
- func ParseFlags() (plugin Plugin, config PluginRuntimeConfig, builder *Builder, err error)
- func ParseIntFromExpr(expr Expr) (int, bool)
- func ReadBeanIds(reader io.Reader, sep string) (map[string]int, error)
- func SplitBeanKey(key string) (pkgName, beanName string)
- type ArrayType
- type BasicLit
- type BasicType
- type Bean
- type BeanIdAllocator
- type Builder
- type ConstSpec
- type EmbeddedPosition
- type EmbeddedValue
- type Expr
- type ExprBase
- type Extension
- type ExtensionKey
- type Field
- type File
- type FuncType
- type GenDecl
- type Group
- type IdPair
- type Ident
- type ImportSpec
- type MapType
- type ObjectId
- type Package
- type Plugin
- type PluginRuntimeConfig
- func (config *PluginRuntimeConfig) BoolEnv(name string) bool
- func (config *PluginRuntimeConfig) Decode(s string) error
- func (config PluginRuntimeConfig) Encode() string
- func (config *PluginRuntimeConfig) FloatEnv(name string) float64
- func (config *PluginRuntimeConfig) Getenv(name string) string
- func (config *PluginRuntimeConfig) IntEnv(name string) int64
- func (config *PluginRuntimeConfig) UintEnv(name string) uint64
- type PluginSet
- type StructType
- type Tag
- type Type
- type TypeBase
- type VectorType
Constants ¶
View Source
const ( // positions FileHead = "file_head" BeforeImport = "before_import" InImport = "in_import" AfterImport = "after_import" BeforeConst = "before_const" AfterConst = "after_const" ConstFront = "const_front" ConstBack = "const_back" BeforeEnum = "before_enum" EnumFront = "enum_front" EnumBack = "enum_back" AfterEnum = "after_enum" BeforeStruct = "before_struct" StructFront = "struct_front" StructBack = "struct_back" AfterStruct = "after_struct" BeforeProtocol = "before_protocol" ProtocolFront = "protocol_front" ProtocolBack = "protocol_back" AfterProtocol = "after_protocol" BeforeService = "before_service" ServiceFront = "service_front" ServiceBack = "service_back" AfterService = "after_service" // Extension config filename ExtConfigFilename = "ext.json" )
Variables ¶
View Source
var (
ErrAmbiguousNames = errors.New("ambiguous names")
)
View Source
var (
ErrExtensionName = errors.New("invalid extension name")
)
Functions ¶
func BuildComment ¶
func BuildComment(comment *ast.CommentGroup) string
BuildDoc builds Comment node to string
func BuildIdentList ¶
BuildIdentList builds Ident nodes to string slice
func IntFromExpr ¶ added in v0.1.3
IntFromExpr converts Expr node to string which represents an integer
func IsValidKind ¶ added in v0.1.2
func JoinBeanKey ¶ added in v0.1.3
func ParseFlags ¶
func ParseFlags() (plugin Plugin, config PluginRuntimeConfig, builder *Builder, err error)
func ParseIntFromExpr ¶ added in v0.1.4
func ReadBeanIds ¶ added in v0.1.3
ReadBeanIds read key-id pairs from reader. Each line contains one key-id pair seperated by `sep`.
func SplitBeanKey ¶ added in v0.1.3
Types ¶
type ArrayType ¶
func BuildArray ¶
type BasicLit ¶
func BuildBasicLit ¶
type Bean ¶
type Bean struct {
Id int
Kind string
Doc string
Name string
Extends []Type
Tag Tag
Fields []*Field
Comment string
Group string
}
func (Bean) FindFieldByName ¶ added in v0.1.4
type BeanIdAllocator ¶ added in v0.1.3
type BeanIdAllocator interface {
// Allocate returns a integer as id of key
Allocate(key string) int
// Output outputs all key-id pairs to writer w or outputs to default writer of allocator if w is nil
Output(w io.Writer) error
}
func NewBeanIdAllocator ¶ added in v0.1.3
func NewBeanIdAllocator(name, opts string) (BeanIdAllocator, error)
func NewFileBeanIdAllocator ¶ added in v0.1.3
func NewFileBeanIdAllocator(filename string) (BeanIdAllocator, error)
type Builder ¶
type Builder struct {
Packages map[string]*Package
SortedPackages []*Package
// contains filtered or unexported fields
}
Builder
func NewBuilder ¶
func NewBuilder() *Builder
type EmbeddedPosition ¶
type EmbeddedPosition string
func (EmbeddedPosition) IsValid ¶
func (pos EmbeddedPosition) IsValid() bool
func (EmbeddedPosition) Match ¶
func (pos EmbeddedPosition) Match(at string) bool
type EmbeddedValue ¶
type EmbeddedValue struct {
Text string `join:"text"`
Template string `json:"template"`
Suffix string `json:"suffix"`
Kinds []string `json:"kinds"`
}
func (EmbeddedValue) IsValid ¶
func (v EmbeddedValue) IsValid() bool
func (EmbeddedValue) MatchKind ¶ added in v0.1.2
func (v EmbeddedValue) MatchKind(kind string) bool
type Expr ¶
type Expr interface {
ExprNode()
}
Expr is an interface which represents expression node
type Extension ¶ added in v0.1.3
type Extension struct {
Name string `json:"name"`
Author string `json:"author"`
URL string `json:"url"`
Version string `json:"version"`
Deps []string `json:"deps"`
// language -> position -> embedded_values
EmbeddedAt map[string]map[EmbeddedPosition][]EmbeddedValue `json:"at"`
Path string `json:"path"`
}
func (Extension) Find ¶ added in v0.1.3
func (e Extension) Find(lang, kind, at string) []EmbeddedValue
type ExtensionKey ¶ added in v0.1.3
func GetExtensionKey ¶ added in v0.1.3
func GetExtensionKey(name string) (ExtensionKey, error)
func (ExtensionKey) Path ¶ added in v0.1.3
func (key ExtensionKey) Path(rootdir string) string
func (ExtensionKey) Subdir ¶ added in v0.1.3
func (key ExtensionKey) Subdir() string
type Field ¶
type Field struct {
Doc string
Options []string
Type Type
Names []string
Default Expr
Tag Tag
Comment string
}
Field represents a field of struct or protocol
func BuildField ¶
BuildField builds Field node to Field struct
func BuildFieldList ¶
BuildFieldList builds Field nodes to field struct slice
type File ¶
type GenDecl ¶
type GenDecl struct {
Doc string
Imports []*ImportSpec
Consts []*ConstSpec
Group string
}
func BuildGenDecl ¶
type Group ¶ added in v0.1.3
type Group struct {
Doc string
Name string
Tag Tag
Beans []*Bean
Decls []*GenDecl
Groups []*Group
Parent string
}
func BuildGroup ¶ added in v0.1.3
type ImportSpec ¶
func BuildImportSpec ¶
func BuildImportSpec(spec *ast.ImportSpec) *ImportSpec
type Package ¶
func BuildPackage ¶
type Plugin ¶
type Plugin struct {
Lang string `json:"lang"`
Name string `json:"name"`
Bin string `json:"bin"`
TemplatesDir string `json:"templates,omitempty"`
RuntimeConfig PluginRuntimeConfig `json:"-"`
}
type PluginRuntimeConfig ¶
type PluginRuntimeConfig struct {
Verbose string
Outdir string
ExtentionsDir string
Extensions []Extension
Envvars map[string]string
}
func (*PluginRuntimeConfig) BoolEnv ¶
func (config *PluginRuntimeConfig) BoolEnv(name string) bool
func (*PluginRuntimeConfig) Decode ¶
func (config *PluginRuntimeConfig) Decode(s string) error
func (PluginRuntimeConfig) Encode ¶
func (config PluginRuntimeConfig) Encode() string
func (*PluginRuntimeConfig) FloatEnv ¶
func (config *PluginRuntimeConfig) FloatEnv(name string) float64
func (*PluginRuntimeConfig) Getenv ¶
func (config *PluginRuntimeConfig) Getenv(name string) string
func (*PluginRuntimeConfig) IntEnv ¶
func (config *PluginRuntimeConfig) IntEnv(name string) int64
func (*PluginRuntimeConfig) UintEnv ¶
func (config *PluginRuntimeConfig) UintEnv(name string) uint64
type PluginSet ¶
type PluginSet struct {
// contains filtered or unexported fields
}
func NewPluginSet ¶
func NewPluginSet() *PluginSet
type StructType ¶
func BuildStruct ¶
func BuildStruct(t *ast.StructType) *StructType
func (StructType) IsStruct ¶ added in v0.1.2
func (StructType) IsStruct() bool
func (StructType) String ¶ added in v0.1.3
func (t StructType) String(sep string) string
type Tag ¶
type Tag string
Tag represents a tag
type Type ¶
type VectorType ¶
func BuildVector ¶
func BuildVector(t *ast.VectorType) *VectorType
func (VectorType) IsVector ¶ added in v0.1.2
func (VectorType) IsVector() bool
Click to show internal directories.
Click to hide internal directories.