Documentation ¶
Index ¶
- Constants
- func EachFile(collector *Collector, pkgs []*Package, callback FileCallback)
- func GoModDir() (string, error)
- func IsDecimal(character rune) bool
- func IsIdentifier(character rune, index int) bool
- func LowerCamelCase(str string) string
- func NewErrorList(errors []error) error
- type AliasMap
- type AnonymousStructType
- type AnyKindType
- type Argument
- type ArgumentType
- type ArgumentTypeInfo
- type ArrayType
- type ChanDirection
- type ChanType
- type Collector
- type Definition
- type DictionaryType
- type ErrorList
- type Field
- type File
- type FileCallback
- type FunctionType
- type Import
- type ImportError
- type ImportMarker
- type InterfaceType
- type Kind
- type Marker
- type MarkerValues
- type Method
- type ModuleInfo
- type ObjectType
- type Output
- type Package
- type PackageInfo
- type ParserError
- type PointerType
- type Position
- type Registry
- type Scanner
- func (scanner *Scanner) AddError(message string)
- func (scanner *Scanner) ErrorCount() int
- func (scanner *Scanner) Expect(expected rune, description string) bool
- func (scanner *Scanner) Next() rune
- func (scanner *Scanner) Peek() rune
- func (scanner *Scanner) Reset()
- func (scanner *Scanner) Scan() rune
- func (scanner *Scanner) ScanIdentifier() rune
- func (scanner *Scanner) ScanNumber() rune
- func (scanner *Scanner) ScanString(quote rune) (len int)
- func (scanner *Scanner) SearchIndex() int
- func (scanner *Scanner) SetSearchIndex(searchIndex int)
- func (scanner *Scanner) SkipWhitespaces() rune
- func (scanner *Scanner) SourceLength() int
- func (scanner *Scanner) Token() string
- type ScannerError
- type StructType
- type TargetLevel
- type Type
- type TypeInfo
- type UserDefinedType
- type VariadicType
Constants ¶
View Source
const ( // TypeLevel indicates that a marker is associated with any type. TypeLevel = StructTypeLevel | InterfaceTypeLevel // MethodLevel indicates that a marker is associated with a struct method or an interface method. MethodLevel = StructMethodLevel | InterfaceMethodLevel )
Combined levels
View Source
const ( EOF = -(iota + 1) Identifier Integer String )
View Source
const (
ImportMarkerName = "import"
)
Reserved markers
View Source
const (
ValueArgument = "Value"
)
Argument names
View Source
const Whitespace = 1<<'\t' | 1<<'\r' | 1<<' '
Variables ¶
This section is empty.
Functions ¶
func EachFile ¶
func EachFile(collector *Collector, pkgs []*Package, callback FileCallback)
func IsIdentifier ¶
func LowerCamelCase ¶
func NewErrorList ¶
Types ¶
type AnonymousStructType ¶
type AnonymousStructType struct { Markers MarkerValues Fields []Field }
func (AnonymousStructType) Kind ¶
func (typ AnonymousStructType) Kind() Kind
type AnyKindType ¶
type AnyKindType struct { }
func (AnyKindType) Kind ¶
func (typ AnyKindType) Kind() Kind
type Argument ¶
type Argument struct { Name string TypeInfo ArgumentTypeInfo Pointer bool Required bool SyntaxFree bool UseValueSyntax bool }
func ExtractArgument ¶
func ExtractArgument(structField reflect.StructField) (Argument, error)
type ArgumentType ¶
type ArgumentType int
const ( InvalidType ArgumentType = iota RawType AnyType BoolType IntegerType StringType SliceType MapType )
func (ArgumentType) String ¶
func (argumentType ArgumentType) String() string
type ArgumentTypeInfo ¶
type ArgumentTypeInfo struct { ActualType ArgumentType ItemType *ArgumentTypeInfo }
func GetArgumentTypeInfo ¶
func GetArgumentTypeInfo(typ reflect.Type) (ArgumentTypeInfo, error)
type ChanType ¶
type ChanType struct { Typ Type Direction ChanDirection }
type Definition ¶
type Definition struct { Name string Level TargetLevel Output Output PkgId string }
func MakeDefinition ¶
func MakeDefinition(name string, pkgId string, level TargetLevel, output interface{}) (*Definition, error)
func (*Definition) Parse ¶
func (definition *Definition) Parse(marker string) (interface{}, error)
type DictionaryType ¶
func (DictionaryType) Kind ¶
func (typ DictionaryType) Kind() Kind
type File ¶
type File struct { Name string FullPath string Package PackageInfo Imports []Import Markers MarkerValues ImportMarkers []MarkerValues FunctionTypes []FunctionType StructTypes []StructType InterfaceTypes []InterfaceType UserDefinedTypes []UserDefinedType RawFile *ast.File }
type FileCallback ¶
type FunctionType ¶
type FunctionType struct { Name string Position Position Markers MarkerValues Parameters []TypeInfo ReturnValues []TypeInfo File *File RawFile *ast.File RawFuncDecl *ast.FuncDecl RawFuncType *ast.FuncType }
func (FunctionType) Kind ¶
func (function FunctionType) Kind() Kind
type Import ¶
type Import struct { Name string Path string Position Position RawImportSpec *ast.ImportSpec }
type ImportError ¶
type ImportError struct {
Marker string
}
func (ImportError) Error ¶
func (err ImportError) Error() string
type ImportMarker ¶
type ImportMarker struct { Value string `marker:"Value,useValueSyntax"` Alias string `marker:"Alias,optional"` Pkg string `marker:"Pkg"` }
func (ImportMarker) GetCommand ¶
func (m ImportMarker) GetCommand() string
func (ImportMarker) GetPkgId ¶
func (m ImportMarker) GetPkgId() string
func (ImportMarker) GetPkgVersion ¶
func (m ImportMarker) GetPkgVersion() string
func (ImportMarker) Validate ¶
func (m ImportMarker) Validate() error
type InterfaceType ¶
type InterfaceType struct { Name string Position Position Markers MarkerValues Methods []Method File *File RawFile *ast.File RawGenDecl *ast.GenDecl RawTypeSpec *ast.TypeSpec }
func (InterfaceType) Kind ¶
func (typ InterfaceType) Kind() Kind
type MarkerValues ¶
type MarkerValues map[string][]interface{}
func (MarkerValues) Get ¶
func (markerValues MarkerValues) Get(name string) interface{}
type ModuleInfo ¶
type ObjectType ¶
func (ObjectType) Kind ¶
func (typ ObjectType) Kind() Kind
type Package ¶
func LoadPackages ¶
LoadPackages loads and returns the Go packages by the given patterns.
type PackageInfo ¶
type ParserError ¶
type PointerType ¶
type PointerType struct {
Typ Type
}
func (PointerType) Kind ¶
func (typ PointerType) Kind() Kind
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry keeps the registered marker definitions.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry returns a new registry to register the markers.
func (*Registry) Lookup ¶
func (registry *Registry) Lookup(name string, pkgId string) *Definition
Lookup fetches the definition corresponding to the given name and pkgId.
func (*Registry) Register ¶
func (registry *Registry) Register(name string, pkgId string, level TargetLevel, output interface{}, useValueSyntax ...bool) error
Register registers a new marker with the given name, target level, and output type.
func (*Registry) RegisterWithDefinition ¶
func (registry *Registry) RegisterWithDefinition(definition *Definition) error
RegisterWithDefinition registers a new marker with the given definition.
type Scanner ¶
type Scanner struct { ErrorCallback func(scanner *Scanner, message string) // contains filtered or unexported fields }
func NewScanner ¶
func (*Scanner) ErrorCount ¶
func (*Scanner) ScanIdentifier ¶
func (*Scanner) ScanNumber ¶
func (*Scanner) ScanString ¶
func (*Scanner) SearchIndex ¶
func (*Scanner) SetSearchIndex ¶
func (*Scanner) SkipWhitespaces ¶
func (*Scanner) SourceLength ¶
type ScannerError ¶
type ScannerError struct {
Message string
}
func (ScannerError) Error ¶
func (err ScannerError) Error() string
type StructType ¶
type StructType struct { Name string Position Position Markers MarkerValues Fields []Field Methods []Method File *File RawFile *ast.File RawGenDecl *ast.GenDecl RawTypeSpec *ast.TypeSpec }
func (StructType) Kind ¶
func (typ StructType) Kind() Kind
type TargetLevel ¶
type TargetLevel int
TargetLevel describes which kind of nodes a given marker are associated with.
const ( // PackageLevel indicates that a marker is associated with a package. PackageLevel TargetLevel = 1 << iota // ImportLevel indicates that a marker is associated with an import block. ImportLevel // StructTypeLevel indicates that a marker is associated with a struct type. StructTypeLevel // InterfaceTypeLevel indicates that a marker is associated with an interface type. InterfaceTypeLevel // FieldLevel indicates that a marker is associated with a struct field. FieldLevel // FunctionLevel indicates that a marker is associated with a function. FunctionLevel // StructMethodLevel indicates that a marker is associated with a struct method. StructMethodLevel // InterfaceMethodLevel indicates that a marker is associated with an interface method. InterfaceMethodLevel )
type TypeInfo ¶
type TypeInfo struct { Name string Type Type Markers MarkerValues RawField *ast.Field }
type UserDefinedType ¶
type UserDefinedType struct { Name string ActualType Type Position Position Markers MarkerValues Methods []Method File *File RawFile *ast.File RawGenDecl *ast.GenDecl RawTypeSpec *ast.TypeSpec }
func (UserDefinedType) Kind ¶
func (typ UserDefinedType) Kind() Kind
type VariadicType ¶
type VariadicType struct {
ItemType Type
}
func (VariadicType) Kind ¶
func (typ VariadicType) Kind() Kind
Source Files ¶
Click to show internal directories.
Click to hide internal directories.