types

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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 IsBuiltin added in v1.0.0

func IsBuiltin(t Type) bool

Checks is type is builtin type.

func IsBuiltinFuncString added in v1.0.0

func IsBuiltinFuncString(t string) bool

func IsBuiltinString added in v1.0.0

func IsBuiltinString(t string) bool

func IsBuiltinTypeString added in v1.0.0

func IsBuiltinTypeString(t string) bool

func IsType added in v1.0.0

func IsType(f func(Type) Type) func(Type) bool

func TypeName added in v1.0.0

func TypeName(t Type) *string

Returns name of type if it has it. Raw maps and interfaces do not have names.

Types

type Base

type Base struct {
	Name string   `json:"name,omitempty"`
	Docs []string `json:"docs,omitempty"`
}

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 FileType added in v1.0.0

type FileType struct {
	Base
	Type    Type      `json:"type,omitempty"`
	Methods []*Method `json:"methods,omitempty"`
}

type Function

type Function struct {
	Base
	Args    []Variable `json:"args,omitempty"`
	Results []Variable `json:"results,omitempty"`
}

func (Function) GoString added in v0.2.0

func (f Function) GoString() string

func (Function) String added in v0.2.0

func (f Function) String() string

type Import

type Import struct {
	Base
	Package string `json:"package,omitempty"`
}

func TypeImport added in v1.0.0

func TypeImport(t Type) *Import

Returns Import of type or nil.

func (Import) GoString added in v0.2.0

func (i Import) GoString() string

func (Import) String added in v0.2.0

func (i Import) String() string

type Interface

type Interface struct {
	Base
	Methods []*Function `json:"methods,omitempty"`
}

func (Interface) GoString added in v0.2.0

func (i Interface) GoString() string

func (Interface) String added in v0.2.0

func (i Interface) String() string

type LinearType added in v1.0.0

type LinearType interface {
	NextType() Type
}

type Method

type Method struct {
	Function
	Receiver Variable `json:"receiver,omitempty"`
}

func (Method) GoString added in v0.2.0

func (f Method) GoString() string

func (Method) String added in v0.2.0

func (f Method) String() string

type Struct

type Struct struct {
	Base
	Fields  []StructField `json:"fields,omitempty"`
	Methods []*Method     `json:"methods,omitempty"`
}

type StructField

type StructField struct {
	Variable
	Tags    map[string][]string `json:"tags,omitempty"`
	RawTags string              `json:"raw,omitempty"` // Raw string from source.
}

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) NextType added in v1.0.0

func (i TArray) NextType() Type

func (TArray) String added in v1.0.0

func (i TArray) String() string

func (TArray) TypeOf added in v1.0.0

func (TArray) TypeOf() TypesOfTypes

type TChan added in v1.1.0

type TChan struct {
	Direction int
	Next      Type
}

func (TChan) NextType added in v1.1.0

func (c TChan) NextType() Type

func (TChan) String added in v1.1.0

func (c TChan) String() string

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) NextType added in v1.0.0

func (i TEllipsis) NextType() Type

func (TEllipsis) String added in v1.0.0

func (i TEllipsis) String() string

func (TEllipsis) TypeOf added in v1.0.0

func (TEllipsis) TypeOf() TypesOfTypes

type TImport added in v1.0.0

type TImport struct {
	Import *Import `json:"import,omitempty"`
	Next   Type    `json:"next,omitempty"`
}

func (TImport) NextType added in v1.0.0

func (i TImport) NextType() Type

func (TImport) String added in v1.0.0

func (i TImport) String() string

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 TMap added in v1.0.0

type TMap struct {
	Key   Type `json:"key,omitempty"`
	Value Type `json:"value,omitempty"`
}

func (TMap) String added in v1.0.0

func (m TMap) String() string

func (TMap) TypeOf added in v1.0.0

func (TMap) TypeOf() TypesOfTypes

type TName added in v1.0.0

type TName struct {
	TypeName string `json:"type_name,omitempty"`
}

func (TName) NextType added in v1.0.0

func (i TName) NextType() Type

func (TName) String added in v1.0.0

func (i TName) String() string

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) NextType added in v1.0.0

func (i TPointer) NextType() Type

func (TPointer) String added in v1.0.0

func (i TPointer) String() string

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

func TypeArray(t Type) Type

Returns first array entity of type. If array not found, returns nil.

func TypeEllipsis added in v1.0.0

func TypeEllipsis(t Type) Type

func TypeInterface added in v1.0.0

func TypeInterface(t Type) Type

func TypeMap added in v1.0.0

func TypeMap(t Type) Type

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
)

type Variable

type Variable struct {
	Base
	Type Type `json:"type,omitempty"`
}

func (Variable) GoString added in v0.2.0

func (v Variable) GoString() string

func (Variable) String added in v0.2.0

func (v Variable) String() string

String representation of variable without docs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL