Documentation
¶
Index ¶
- Constants
- func MarshalJSON(n jsonNode) ([]byte, error)
- type Alternative
- type AlternativeAlias
- type BaseType
- type BaseTypeAlias
- type DataType
- type DataTypeAlias
- type DeclNode
- type DeclNodeList
- type DeclNodes
- type EllipsisType
- type EllipsisTypeAlias
- type EnumBoolType
- type EnumBoolTypeAlias
- type EnumDecl
- type EnumDeclAlias
- type Field
- type FieldAlias
- type FieldList
- type FieldNode
- type FuncAttr
- type FuncAttrAlias
- type FuncConfig
- type FuncConfigAlias
- type FuncDecl
- type FuncDeclAlias
- type NodeKind
- type PointerType
- type PointerTypeAlias
- type RawAlternative
- type RawEllipsisType
- type RawField
- type RawPointerType
- type RawSliceType
- type Scope
- func (s *Scope) InsertDecl(decl DeclNode) bool
- func (s *Scope) Lookup(name string) DeclNode
- func (s *Scope) LookupFuncAttr(name string) *FuncAttr
- func (s *Scope) LookupFuncConfig(name string) *FuncConfig
- func (s *Scope) LoopEnum(f func(*EnumDecl))
- func (s *Scope) LoopFunc(f func(*FuncDecl))
- func (s *Scope) LoopStruct(f func(*StructDecl))
- func (s *Scope) NodeList() DeclNodeList
- func (s *Scope) Nodes() DeclNodes
- type SliceType
- type SliceTypeAlias
- type StructDecl
- type StructDeclAlias
- type TypeNode
- type WalkNodeFct
Constants ¶
const ( ConfigType = "type" ConfigTypeSubscribe = "subscribe" ConfigTypeUnsubscribe = "unsubscribe" ConfigCallback = "callback" ConfigChannel = "channel" )
Function configuration constants.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
Types ¶
type Alternative ¶
type Alternative struct { Name string `json:"name"` Cmd string `json:"cmd"` Type TypeNode `json:"type"` List FieldList `json:"list"` }
Alternative represents a set of alternative fields.
func (*Alternative) MarshalJSON ¶
func (alt *Alternative) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface.
func (*Alternative) NodeCmd ¶
func (alt *Alternative) NodeCmd() string
NodeCmd implements FieldNode interface.
func (*Alternative) NodeName ¶
func (alt *Alternative) NodeName() string
NodeName implements FieldNode interface.
func (*Alternative) NodeType ¶
func (alt *Alternative) NodeType() TypeNode
NodeType implements FieldNode interface.
func (*Alternative) UnmarshalJSON ¶
func (alt *Alternative) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the Unmarshaler interface.
type AlternativeAlias ¶
type AlternativeAlias Alternative
AlternativeAlias is the alias type for Alternative.
type BaseType ¶
type BaseType struct {
Name string `json:"name"`
}
BaseType represents a base type (like string, int64, ...).
func (*BaseType) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
type DataType ¶
type DataType struct {
Name string `json:"name"`
}
DataType represents a structure.
func (*DataType) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
type DeclNode ¶
type DeclNode interface {
// contains filtered or unexported methods
}
DeclNode represents a declaration.
type DeclNodeList ¶
type DeclNodeList []DeclNode
DeclNodeList is a sclice ao all declaration nodes.
func (*DeclNodeList) UnmarshalJSON ¶
func (l *DeclNodeList) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the Unmarshaler interface.
type DeclNodes ¶
DeclNodes is a map of declaration nodes with key name.
func (*DeclNodes) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface.
type EllipsisType ¶
type EllipsisType struct {
Node TypeNode `json:"node"`
}
EllipsisType represents a variadic attribute.
func (*EllipsisType) MarshalJSON ¶
func (t *EllipsisType) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface.
func (*EllipsisType) String ¶
func (t *EllipsisType) String() string
func (*EllipsisType) UnmarshalJSON ¶
func (t *EllipsisType) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the Unmarshaler interface.
type EllipsisTypeAlias ¶
type EllipsisTypeAlias EllipsisType
EllipsisTypeAlias is the alias type for EllipsisType.
type EnumBoolType ¶
type EnumBoolType struct {
Values []string `json:"values"`
}
EnumBoolType represents an one or two element enumeration.
func (*EnumBoolType) BaseType ¶
func (t *EnumBoolType) BaseType() TypeNode
BaseType returns the base type of an EnumBoolType.
func (*EnumBoolType) MarshalJSON ¶
func (t *EnumBoolType) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface.
func (*EnumBoolType) String ¶
func (t *EnumBoolType) String() string
type EnumBoolTypeAlias ¶
type EnumBoolTypeAlias EnumBoolType
EnumBoolTypeAlias is the alias type for EnumBoolType.
type EnumDecl ¶
EnumDecl represents an enumeration declaration.
func NewEnumDecl ¶
NewEnumDecl is the EnumDecl constructor.
func (*EnumDecl) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
type Field ¶
Field represents an AST field.
func (*Field) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
func (*Field) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface.
type FieldList ¶
type FieldList []FieldNode
FieldList is a list of field definitions.
func (*FieldList) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface.
func (FieldList) WalkNode ¶
func (list FieldList) WalkNode(fct WalkNodeFct)
WalkNode iterates through all nodes of the list.
type FieldNode ¶
type FieldNode interface { NodeName() string NodeCmd() string NodeType() TypeNode // contains filtered or unexported methods }
FieldNode represents a field definition.
type FuncAttr ¶
type FuncAttr struct { Name string `json:"name"` Summary string `json:"summary"` Complexity string `json:"complexity"` Since string `json:"since"` Group string `json:"group"` }
FuncAttr represents a function attribute declaration.
func NewFuncAttr ¶
NewFuncAttr is the FuncAttr constructor.
func (*FuncAttr) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
type FuncConfig ¶
FuncConfig represents a function configuration declaration
func (*FuncConfig) MarshalJSON ¶
func (d *FuncConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface.
type FuncConfigAlias ¶
type FuncConfigAlias FuncConfig
FuncConfigAlias is the alias type for FuncConfig.
type FuncDecl ¶
type FuncDecl struct { Name string `json:"name"` Skip bool `json:"skip"` Attr string `json:"attr"` Token []string `json:"token"` List FieldList `json:"list"` }
FuncDecl represents a function declaration.
func NewFuncDecl ¶
NewFuncDecl is the FuncDecl constructor.
func (*FuncDecl) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
type NodeKind ¶
type NodeKind struct {
Kind string `json:"_type"`
}
NodeKind is a helper structure to unmarshall the node kind.
type PointerType ¶
type PointerType struct {
Node TypeNode `json:"node"`
}
PointerType represents an optinal attribute.
func (*PointerType) MarshalJSON ¶
func (t *PointerType) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface.
func (*PointerType) String ¶
func (t *PointerType) String() string
func (*PointerType) UnmarshalJSON ¶
func (t *PointerType) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the Unmarshaler interface.
type PointerTypeAlias ¶
type PointerTypeAlias PointerType
PointerTypeAlias is the alias type for PointerType.
type RawAlternative ¶
type RawAlternative struct { Name string `json:"name"` Cmd string `json:"cmd"` Type json.RawMessage `json:"type"` List FieldList `json:"list"` }
RawAlternative is a helper structure to unmarshal an alternative and it's type in raw json format.
type RawEllipsisType ¶
type RawEllipsisType struct {
Node json.RawMessage `json:"node"`
}
RawEllipsisType is a helper structure to unmarshal an ellipsis.
type RawField ¶
type RawField struct { Name string `json:"name"` Cmd string `json:"cmd"` Type json.RawMessage `json:"type"` }
RawField is a helper structure to unmarshal a field and it's type in raw json format.
type RawPointerType ¶
type RawPointerType struct {
Node json.RawMessage `json:"node"`
}
RawPointerType is a helper structure to unmarshal a pointer.
type RawSliceType ¶
type RawSliceType struct { AllowNil bool `json:"allowNil"` Cmd string `json:"cmd"` Node json.RawMessage `json:"node"` }
RawSliceType is a helper structure to unmarshal a slice.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope represents an AST scope.
func (*Scope) InsertDecl ¶
InsertDecl inserts a declaration node in scope.
func (*Scope) LookupFuncAttr ¶
LookupFuncAttr searches and returns a function attribute declaration by name.
func (*Scope) LookupFuncConfig ¶
func (s *Scope) LookupFuncConfig(name string) *FuncConfig
LookupFuncConfig searches and returns a function configuration declaration by name.
func (*Scope) LoopStruct ¶
func (s *Scope) LoopStruct(f func(*StructDecl))
LoopStruct iterates through all structure declarations.
func (*Scope) NodeList ¶
func (s *Scope) NodeList() DeclNodeList
NodeList return all declaration nodes.
type SliceType ¶
type SliceType struct { AllowNil bool `json:"allowNil"` Cmd string `json:"cmd"` Node TypeNode `json:"node"` }
SliceType represents a multi-value attribute.
func (*SliceType) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
func (*SliceType) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface.
type StructDecl ¶
StructDecl represent a structure declaration.
func NewStructDecl ¶
func NewStructDecl(name string) *StructDecl
NewStructDecl is the StructDecl constructor.
func (*StructDecl) MarshalJSON ¶
func (d *StructDecl) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface.
type StructDeclAlias ¶
type StructDeclAlias StructDecl
StructDeclAlias is the alias type for StructDecl.
type TypeNode ¶
type TypeNode interface { String() string // contains filtered or unexported methods }
TypeNode represents a node with type information.
var ( // KeyType represents a key. KeyType TypeNode = &BaseType{Name: "interface{}"} // InterfaceType represents a generic type. InterfaceType TypeNode = &BaseType{Name: "interface{}"} // StringType represents a string. StringType TypeNode = &BaseType{Name: "string"} // IntegerType represents an integer. IntegerType TypeNode = &BaseType{Name: "int64"} // FloatType represents a float. FloatType TypeNode = &BaseType{Name: "float64"} // BoolType represents a boolean. BoolType TypeNode = &BaseType{Name: "bool"} // TimeType represents a time. TimeType TypeNode = &BaseType{Name: "time.Time"} // StringPointerType represents a pointer to a string StringPointerType TypeNode = &PointerType{Node: StringType} // IntegerPointerType represents a pointer to an integer. IntegerPointerType TypeNode = &PointerType{Node: IntegerType} // StringSliceType represents a slice of string. StringSliceType TypeNode = &SliceType{Node: StringType} )
type WalkNodeFct ¶
WalkNodeFct is the callback function definition for node visitor WalkNode.