Documentation ¶
Index ¶
- Variables
- func NewBaseType(pkg *Package, name string) *baseType
- func NewEnvironment() (*environment, error)
- func NewPackageContext(pkg *Package, buildPackage *build.Package) *parsePackageContext
- type ArrayRefType
- type BaseRefType
- type ChanRefType
- type Constant
- type Doc
- type Ellipsis
- type EllipsisRefType
- type EnvConfig
- type Field
- type File
- type Interface
- type MapType
- type MethodArgument
- type MethodDescriptor
- type MethodResult
- type Package
- func (p *Package) AddRefType(ref RefType)
- func (p *Package) AppendInterface(s *Interface)
- func (p *Package) AppendMethod(method *MethodDescriptor)
- func (p *Package) AppendRefType(name string) (ref RefType)
- func (p *Package) AppendStruct(s *Struct)
- func (p *Package) AppendVariable(variable *Variable) *Variable
- func (p *Package) EnsureRefType(name string) (RefType, bool)
- func (p *Package) InterfaceByName(name string) (*Interface, bool)
- func (p *Package) MethodByName(name string) (*MethodDescriptor, bool)
- func (p *Package) RefTypeByName(name string) (RefType, bool)
- func (p *Package) StructByName(name string) (*Struct, bool)
- func (p *Package) VariableByName(name string) (vrle *Variable)
- type RefType
- type StarRefType
- type Struct
- type Tag
- type TagParam
- type Type
- type TypeMethod
- type Variable
Constants ¶
This section is empty.
Variables ¶
var ( NullRefType = &BaseRefType{ name: "nil", } InterfaceRefType = &BaseRefType{ name: "interface", } )
var ( ErrTypeNotFound = errors.New("type not found") ErrBuiltInNotFound = errors.New("builtin package not found") ErrPackageAliasNotFound = errors.New("package alias not found") ErrUnexpectedSelector = errors.New("unexpected selector identifier") ErrUnexpectedExpressionType = errors.New("unexpected expression type") )
Functions ¶
func NewBaseType ¶
NewBaseType creates a new initialized baseType.
func NewEnvironment ¶
func NewEnvironment() (*environment, error)
func NewPackageContext ¶
Types ¶
type ArrayRefType ¶
type ArrayRefType struct {
RefType
}
func NewArrayRefType ¶
func NewArrayRefType(refType RefType) *ArrayRefType
func (*ArrayRefType) AppendType ¶
func (refType *ArrayRefType) AppendType(tp Type)
func (*ArrayRefType) Name ¶
func (refType *ArrayRefType) Name() string
func (*ArrayRefType) Pkg ¶
func (refType *ArrayRefType) Pkg() *Package
func (*ArrayRefType) Type ¶
func (refType *ArrayRefType) Type() Type
type BaseRefType ¶
type BaseRefType struct {
// contains filtered or unexported fields
}
func (*BaseRefType) AppendType ¶
func (rt *BaseRefType) AppendType(tp Type)
AppendType add Type in RefType
func (*BaseRefType) Name ¶
func (refType *BaseRefType) Name() string
func (*BaseRefType) Pkg ¶
func (refType *BaseRefType) Pkg() *Package
func (*BaseRefType) Type ¶
func (refType *BaseRefType) Type() Type
type ChanRefType ¶
type ChanRefType struct {
RefType
}
func NewChanRefType ¶
func NewChanRefType(refType RefType) *ChanRefType
func (*ChanRefType) AppendType ¶
func (refType *ChanRefType) AppendType(tp Type)
func (*ChanRefType) Name ¶
func (refType *ChanRefType) Name() string
func (*ChanRefType) Pkg ¶
func (refType *ChanRefType) Pkg() *Package
func (*ChanRefType) Type ¶
func (refType *ChanRefType) Type() Type
type Doc ¶
type Doc struct {
Comments []string
}
func (*Doc) FormatComment ¶
FormatComment is simple method to remove // or /* */ of comment
type Ellipsis ¶
type Ellipsis struct { Elt RefType // contains filtered or unexported fields }
func NewEllipsis ¶
func (*Ellipsis) AddMethod ¶
func (el *Ellipsis) AddMethod(method *TypeMethod)
func (*Ellipsis) Methods ¶
func (el *Ellipsis) Methods() []*TypeMethod
type EllipsisRefType ¶
type EllipsisRefType struct {
RefType
}
func NewEllipsisRefType ¶
func NewEllipsisRefType(refType RefType) *EllipsisRefType
func (*EllipsisRefType) AppendType ¶
func (refType *EllipsisRefType) AppendType(tp Type)
func (*EllipsisRefType) Name ¶
func (refType *EllipsisRefType) Name() string
func (*EllipsisRefType) Pkg ¶
func (refType *EllipsisRefType) Pkg() *Package
func (*EllipsisRefType) Type ¶
func (refType *EllipsisRefType) Type() Type
type File ¶
type File struct { Package *Package FileName string Doc Doc Variables []*Variable Constants []*Constant Structs []*Struct Interfaces []*Interface Files []*File }
File is utilized to represent each file read in Package.
type Interface ¶
type Interface struct { Doc Doc // contains filtered or unexported fields }
func NewInterface ¶
NewInterface Create new Interface.
func (*Interface) AddMethod ¶
func (t *Interface) AddMethod(method *TypeMethod)
func (*Interface) Methods ¶
func (t *Interface) Methods() []*TypeMethod
type MapType ¶
func (*MapType) AddMethod ¶
func (mt *MapType) AddMethod(method *TypeMethod)
func (*MapType) Methods ¶
func (mt *MapType) Methods() []*TypeMethod
type MethodArgument ¶
MethodArgument represent type of fields and arguments.
type MethodDescriptor ¶
type MethodDescriptor struct { Doc Doc Recv []MethodArgument Arguments []MethodArgument Result []MethodResult Tag Tag // contains filtered or unexported fields }
func NewMethodDescriptor ¶
func NewMethodDescriptor(pkg *Package, name string) *MethodDescriptor
NewMethodDescriptor return the pointer of new MethodDescriptor
func (*MethodDescriptor) AddMethod ¶
func (t *MethodDescriptor) AddMethod(method *TypeMethod)
func (*MethodDescriptor) Compatible ¶
func (method *MethodDescriptor) Compatible(m *MethodDescriptor) bool
Compatible checks if the signature of both method descriptor are compatible.
It checks if the all arguments refer to the same RefType. The same happens with the result.
Receivers are not taken into consideration, neither names.
func (*MethodDescriptor) Methods ¶
func (t *MethodDescriptor) Methods() []*TypeMethod
func (*MethodDescriptor) Name ¶
func (method *MethodDescriptor) Name() string
Name return name of Method
func (*MethodDescriptor) Package ¶
func (method *MethodDescriptor) Package() *Package
Package return pointer of Package
type MethodResult ¶
type Package ¶
type Package struct { Name string ImportPath string RealPath string BuildInfo *build.Package Doc Doc Variables []*Variable Constants []*Constant Methods []*MethodDescriptor Structs []*Struct Interfaces []*Interface RefType []RefType Types []Type Files []*File Parent *Package Subpackages []*Package // contains filtered or unexported fields }
func NewPackage ¶
func (*Package) AddRefType ¶
func (*Package) AppendInterface ¶
AppendInterface registers a new Interface to the package.
func (*Package) AppendMethod ¶
func (p *Package) AppendMethod(method *MethodDescriptor)
func (*Package) AppendRefType ¶
AppendRefType add new RefType in Package.
func (*Package) AppendStruct ¶
AppendStruct add new Struct in Package
func (*Package) AppendVariable ¶
func (*Package) EnsureRefType ¶
EnsureRefType will try to get the RefType from the list by the name param. If the RefType exists, it will return the reference with true (second return). If it is does not exists in the list, the function will create a new type and return it with false (second return).
func (*Package) InterfaceByName ¶
StructByName find Struct by name.
func (*Package) MethodByName ¶
func (p *Package) MethodByName(name string) (*MethodDescriptor, bool)
func (*Package) RefTypeByName ¶
RefTypeByName find RefType by name.
func (*Package) StructByName ¶
StructByName find Struct by name.
func (*Package) VariableByName ¶
type StarRefType ¶
type StarRefType struct {
RefType
}
func NewStarRefType ¶
func NewStarRefType(refType RefType) *StarRefType
func (*StarRefType) AppendType ¶
func (refType *StarRefType) AppendType(tp Type)
func (*StarRefType) Name ¶
func (refType *StarRefType) Name() string
func (*StarRefType) Pkg ¶
func (refType *StarRefType) Pkg() *Package
func (*StarRefType) Type ¶
func (refType *StarRefType) Type() Type
type Struct ¶
func (*Struct) AddMethod ¶
func (t *Struct) AddMethod(method *TypeMethod)
func (*Struct) Implements ¶
Implements checks if this struct implements a given interface.
This method uses the `MethodDescriptor.Compatible` to check if all interface methods have are implemented on the struct.
TODO(jota): Take into consideration Interface composing...
func (*Struct) Methods ¶
func (t *Struct) Methods() []*TypeMethod
type Tag ¶
func (*Tag) AppendTagParam ¶
AppendTagParam add new TagParam in Tag
func (*Tag) TagParamByName ¶
TagParamByName find TagParam by name.
type Type ¶
type Type interface { Package() *Package Name() string Methods() []*TypeMethod AddMethod(*TypeMethod) }
type TypeMethod ¶
type TypeMethod struct { Name string Descriptor *MethodDescriptor }