Documentation
¶
Index ¶
- Constants
- Variables
- func IsBuiltin(t Type) bool
- func IsBuiltinFuncString(t string) bool
- func IsBuiltinString(t string) bool
- func IsBuiltinTypeString(t string) bool
- func IsType(f func(Type) Type) func(Type) bool
- func TypeName(t Type) *string
- type Base
- type File
- type FileType
- type Function
- type Import
- type Interface
- type LinearType
- type Method
- type Struct
- type StructField
- type TArray
- type TChan
- type TEllipsis
- type TImport
- type TInterface
- type TMap
- type TName
- type TPointer
- type Type
- type TypesOfTypes
- type Variable
Constants ¶
View Source
const ( ChanDirSend = 1 ChanDirRecv = 2 ChanDirAny = ChanDirSend | ChanDirRecv )
Variables ¶
View Source
var ( // Checks, is type contain array. IsArray = IsType(TypeArray) // Checks, is type contain map. IsMap = IsType(TypeMap) // Checks, is type contain interface. IsInterface = IsType(TypeInterface) IsEllipsis = IsType(TypeEllipsis) )
Checks, is type contain some type. Generic checkers.
Functions ¶
func IsBuiltinFuncString ¶ added in v1.0.0
func IsBuiltinString ¶ added in v1.0.0
func IsBuiltinTypeString ¶ added in v1.0.0
Types ¶
type Base ¶
Base type for all (almost) entities. It contains name of entity and docs. Docs is a comments in golang syntax above entity declaration. Each block comment is counted as one.
type File ¶
type File struct {
Base // `File.Name` is package name, `File.Docs` is a comments above `package ...`
Imports []Import `json:"imports,omitempty"` // Contains imports and their aliases from `import` blocks.
Constants []Variable `json:"constants,omitempty"` // Contains constant variables from `const` blocks.
Vars []Variable `json:"vars,omitempty"` // Contains variables from `var` blocks.
Interfaces []Interface `json:"interfaces,omitempty"` // Contains `type Foo interface` declarations.
Structures []Struct `json:"structures,omitempty"` // Contains `type Foo struct` declarations.
Functions []Function `json:"functions,omitempty"` // Contains `func Foo() {}` declarations.
Methods []Method `json:"methods,omitempty"` // Contains `func (a A) Foo(b B) (c C) {}` declarations.
Types []FileType `json:"types,omitempty"` // Contains `type X int` declarations.
}
File is a top-level entity, that contains all top-level declarations of the file.
type Function ¶
type LinearType ¶ added in v1.0.0
type LinearType interface {
NextType() Type
}
type Struct ¶
type Struct struct {
Base
Fields []StructField `json:"fields,omitempty"`
Methods []*Method `json:"methods,omitempty"`
}
type StructField ¶
type TArray ¶ added in v1.0.0
type TArray struct {
ArrayLen int `json:"array_len,omitempty"`
IsSlice bool `json:"is_slice,omitempty"` // [] declaration
IsEllipsis bool `json:"is_ellipsis,omitempty"`
Next Type `json:"next,omitempty"`
}
func (TArray) TypeOf ¶ added in v1.0.0
func (TArray) TypeOf() TypesOfTypes
type TChan ¶ added in v1.1.0
func (TChan) TypeOf ¶ added in v1.1.0
func (TChan) TypeOf() TypesOfTypes
type TEllipsis ¶ added in v1.0.0
type TEllipsis struct {
Next Type `json:"next,omitempty"`
}
TEllipsis used only for function params in declarations like `strs ...string`
func (TEllipsis) TypeOf ¶ added in v1.0.0
func (TEllipsis) TypeOf() TypesOfTypes
type TImport ¶ added in v1.0.0
func (TImport) TypeOf ¶ added in v1.0.0
func (TImport) TypeOf() TypesOfTypes
type TInterface ¶ added in v1.0.0
type TInterface struct {
Interface *Interface `json:"interface,omitempty"`
}
func (TInterface) String ¶ added in v1.0.0
func (i TInterface) String() string
func (TInterface) TypeOf ¶ added in v1.0.0
func (TInterface) TypeOf() TypesOfTypes
type TName ¶ added in v1.0.0
type TName struct {
TypeName string `json:"type_name,omitempty"`
}
func (TName) TypeOf ¶ added in v1.0.0
func (TName) TypeOf() TypesOfTypes
type TPointer ¶ added in v1.0.0
type TPointer struct {
NumberOfPointers int `json:"number_of_pointers,omitempty"`
Next Type `json:"next,omitempty"`
}
func (TPointer) TypeOf ¶ added in v1.0.0
func (TPointer) TypeOf() TypesOfTypes
type Type ¶
type Type interface {
TypeOf() TypesOfTypes
String() string
}
func TypeArray ¶ added in v1.0.0
Returns first array entity of type. If array not found, returns nil.
func TypeEllipsis ¶ added in v1.0.0
func TypeInterface ¶ added in v1.0.0
type TypesOfTypes ¶ added in v1.0.0
type TypesOfTypes int32
const ( T_Name TypesOfTypes = iota T_Pointer T_Array T_Map T_Interface T_Import T_Ellipsis T_CHAN )
Click to show internal directories.
Click to hide internal directories.