Documentation ¶
Index ¶
- Constants
- type Annotation
- type Array
- type Basic
- type BasicKind
- type ChanDir
- type Channel
- type DeclId
- type DeclIdBuilder
- type Interface
- type Location
- type Map
- type Named
- type Package
- type PackageQualifier
- type Param
- type PkgId
- type Pointer
- type Signature
- type Slice
- type Struct
- type Table
- func (t *Table) CreateImportTable() map[DeclId]PkgId
- func (t *Table) DeclIds() []DeclId
- func (t *Table) HasDeclaration(q DeclId) bool
- func (t *Table) PackageByImportPath(importPath string) (PkgId, bool)
- func (t *Table) PutDeclaration(q DeclId, p Type)
- func (t *Table) PutNamedDeclaration(importPath, pkgName string, q DeclId, p *Named)
- func (t *Table) String() string
- type Type
Constants ¶
const ( Invalid BasicKind = "" // type is invalid // predeclared types Bool = "bool" Int = "int" Int8 = "int8" Int16 = "int16" Int32 = "int32" Int64 = "int64" Uint = "uint" Uint8 = "uint8" Uint16 = "uint16" Uint32 = "uint32" Uint64 = "uint64" Uintptr = "uintptr" Float32 = "float32" Float64 = "float64" Complex64 = "complex64" Complex128 = "complex128" String = "string" UnsafePointer = "unsafe.Pointer" // aliases Byte = Uint8 Rune = Int32 )
const ( SendRecv ChanDir = "SendRecv" SendOnly = "SendOnly" RecvOnly = "RecvOnly" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
type Array ¶
Arrays has a length and an according type. Generic declarations (like map[x]y) refer to their own type.
type BasicKind ¶
type BasicKind string
BasicKind describes the kind of basic type.
func (BasicKind) IsUnsigned ¶
type DeclId ¶
type DeclId string
DeclId is usually a unique hash for a declaration (not just named types).
type DeclIdBuilder ¶
type DeclIdBuilder struct {
// contains filtered or unexported fields
}
func NewDeclId ¶
func NewDeclId() *DeclIdBuilder
func (*DeclIdBuilder) Finish ¶
func (b *DeclIdBuilder) Finish() DeclId
func (*DeclIdBuilder) Put ¶
func (b *DeclIdBuilder) Put(values ...interface{}) *DeclIdBuilder
type Interface ¶
type Interface struct { // Embeddeds refers only to TypeIds of other embedded Interfaces. Embeddeds []DeclId // AllMethods refers only to TypeIds of Signatures included by all declared methods, also // by embedded ones. AllMethods []DeclId }
An Interface has a set of signatures and embedded types.
type Named ¶
type Named struct { Location Location Doc string Annotations []Annotation `json:",omitempty"` // Name is the LHS of the declaration or empty if no such thing Name string // Underlying is the resolved RHS side of the declaration. Underlying DeclId // Methods contains the declared methods for this named type (Signature). Methods []DeclId `json:",omitempty"` }
A Named type is a declared type somewhere in the source. It is not a build-in, however it may be also an anonymous type, where the name is just empty.
type PackageQualifier ¶
type PackageQualifier struct { // Path is a / separated name to resolve a package. Path string // Name is the actual identifier of the package. This is also used by default, if not renamed at import. Name string }
A PackageQualifier consists of an import path and the according package name. This is rather obscure, because you can never deduce the actual package name from its path, however it allows at least elegant solutions like this:
- versioned packages, e.g. github.com/myproject/myapi and github.com/myproject/myapi/v2 should both be named myapi
- using path with chars which are illegal identifiers, like github.com/myproject/my-api (could still be myapi)
type Param ¶
type Param struct { Pos *Location `json:",omitempty"` Doc string `json:",omitempty"` Annotations []Annotation `json:",omitempty"` // The Name of the parameter, if not empty Name string // The type of the parameter DeclId DeclId // Tag is the raw string literal. The parsed literal is in Tags Tag string `json:",omitempty"` // Tags are the parsed form of the Tag literal Tags tag.Tags `json:",omitempty"` }
A Param is not a type but declares a tuple of name and type.
type Pointer ¶
type Pointer struct {
Base DeclId
}
A Pointer to a base type (which itself may be again a pointer).
type Signature ¶
type Signature struct { // Receiver is an optional parameter. Receiver *Param `json:",omitempty"` // Params represent the incoming parameters. Params []Param `json:",omitempty"` // Results represent the outgoing parameters. Results []Param `json:",omitempty"` // Variadic indicates if the last parameter is a ...T declaration. Variadic bool `json:",omitempty"` }
Signature represents a declared function or method.
type Slice ¶
type Slice struct { // Underlying of the sliced type. DeclId DeclId }
A Slice wraps a subset of an array of variable length
type Struct ¶
type Struct struct {
Fields []Param `json:",omitempty"`
}
A Struct contains field definitions. Interestingly the method set does not belong to the underlying type, which makes them assignable to each other. However this is also true for tags, so it is quite inconsistent.
type Table ¶
Table contains all resolved type declarations and other deduplicated information. Due to the sake of the default value in json for integer types (==0), we use 0 to indicate "undefined".
func (*Table) CreateImportTable ¶
CreateImportTable creates a new table which assigns each declaration id to its containing package id.
func (*Table) HasDeclaration ¶
func (*Table) PackageByImportPath ¶
func (*Table) PutDeclaration ¶
func (*Table) PutNamedDeclaration ¶
type Type ¶
type Type struct { Basic *Basic `json:",omitempty"` Array *Array `json:",omitempty"` Channel *Channel `json:",omitempty"` Interface *Interface `json:",omitempty"` Map *Map `json:",omitempty"` Pointer *Pointer `json:",omitempty"` Slice *Slice `json:",omitempty"` Struct *Struct `json:",omitempty"` Named *Named `json:",omitempty"` Signature *Signature `json:",omitempty"` }
An Type is a union tuple of exact one of Basic, Array, Channel, Interface, Map Pointer or Struct.