Documentation ¶
Index ¶
- Constants
- func FindDecl(parsedFile *ast.File, declName string) *ast.GenDecl
- func LoadTemplate(templatePath string) (*template.Template, error)
- func PackagePathForFile(fullpath string) string
- func RenderTemplate(writer io.Writer, templatePath string, context interface{}) error
- type AliasTypeData
- type Field
- type FunctionTypeData
- type Generator
- type ITypeLibrary
- type ListTypeData
- type MapTypeData
- type NamedTypeData
- type ParsedFile
- type RecordTypeData
- type ReferenceTypeData
- type TupleTypeData
- type Type
- func (t *Type) AsAliasType() *AliasTypeData
- func (t *Type) AsFunctionType() *FunctionTypeData
- func (t *Type) AsListType() *ListTypeData
- func (t *Type) AsMapType() *MapTypeData
- func (t *Type) AsNamedType() *NamedTypeData
- func (t *Type) AsRecordType() *RecordTypeData
- func (t *Type) AsReferenceType() *ReferenceTypeData
- func (t *Type) AsTupleType() *TupleTypeData
- func (t *Type) IsAliasType() bool
- func (t *Type) IsFunctionType() bool
- func (t *Type) IsListType() bool
- func (t *Type) IsMapType() bool
- func (t *Type) IsNamedType() bool
- func (t *Type) IsNullType() bool
- func (t *Type) IsRecordType() bool
- func (t *Type) IsReferenceType() bool
- func (t *Type) IsTupleType() bool
- func (t *Type) IsUnresolvedType() bool
- func (t *Type) IsValueType() bool
- func (t *Type) LeafType() *NamedTypeData
- func (t *Type) String() string
- func (t *Type) TypeClassString() string
- type TypeLibrary
- func (tl *TypeLibrary) AddGlobalType(name string) (alt *Type)
- func (tl *TypeLibrary) AddPackage(pkg string) (shortName string)
- func (tl *TypeLibrary) AddType(pkg string, name string, t *Type) (alt *Type)
- func (tl *TypeLibrary) ForEach(mapFunc func(string, *Type, *bool))
- func (tl *TypeLibrary) GetGlobalType(name string) (alt *Type)
- func (tl *TypeLibrary) GetType(pkg string, name string) *Type
- func (tl *TypeLibrary) PackageByShortName(name string) string
- func (tl *TypeLibrary) ShortNameForPackage(pkg string) string
- func (tl *TypeLibrary) Signature(t *Type) string
- func (tl *TypeLibrary) TransitiveClosureFrom(startType *Type, filter func(t *Type) bool) ([]*Type, []string)
- func (tl *TypeLibrary) TypeListSignature(types []*Type, argfmt string) string
Constants ¶
View Source
const ( NullType = iota UnresolvedType NamedType AliasType ReferenceType TupleType RecordType FunctionType ListType MapType )
Variables ¶
This section is empty.
Functions ¶
func PackagePathForFile ¶
Given a full path to a file or folder, finds the full name of the package path in one of the GOPATH or GOROOT folders For example, if GOPATH contained the following folders: /home/user1/a /home/user1/b
and GOROOT was: /user/local/go
and given the input full path of:
/home/user1/a/src/github.com/theuser/repo
would return
github.com/theuser/repo
as the full package path as it exists in the src folder of one of the folders in GOPATH or GOROOT
Types ¶
type AliasTypeData ¶
type FunctionTypeData ¶
type FunctionTypeData struct { // Types of the input parameters InputTypes []*Type // Types of the output parameters OutputTypes []*Type // Types of possible exceptions that can be thrown (not supported in all languages) ExceptionTypes []*Type }
func (*FunctionTypeData) NumExceptions ¶
func (td *FunctionTypeData) NumExceptions() int
func (*FunctionTypeData) NumInputs ¶
func (td *FunctionTypeData) NumInputs() int
func (*FunctionTypeData) NumOutputs ¶
func (td *FunctionTypeData) NumOutputs() int
type Generator ¶
type Generator interface { /** * Emits the class that acts as a client for the service. */ EmitClientClass(writer io.Writer, serviceType *Type) error /** * For a given service operation, emits a method which: * 1. Has inputs the same as those of the underlying service operation, * 2. creates a transport level request * 3. Sends the transport level request * 4. Gets a response from the transport level and returns it */ EmitServiceCallMethod(writer io.Writer, opName string, opType *FunctionTypeData, argPrefix string) error /** * Emits the writer for a particular type. */ EmitTypeWriter(writer io.Writer, argType *Type) error /** * Emits the reader for a particular type. */ EmitTypeReader(writer io.Writer, argType *Type) error }
*
- Responsible for generating the code for the client classes.
type ITypeLibrary ¶
type ITypeLibrary interface { AddType(pkg string, name string, t *Type) (alt *Type) GetType(pkg string, name string) *Type AddGlobalType(name string) (alt *Type) GetGlobalType(name string) (alt *Type) // Package related API AddPackage(name string) (shortName string) ForEach(func(string, *Type, *bool)) PackageByShortName(name string) string ShortNameForPackage(pkg string) string // Signature string creation Signature(t *Type) string TypeListSignature(types []*Type, argfmt string) string // General visitors // TODO: move this out of this fat interface TransitiveClosureFrom(startType *Type, filter func(t *Type) bool) ([]*Type, []string) }
type ListTypeData ¶
type ListTypeData struct { // The target type this is an array of TargetType *Type }
type MapTypeData ¶
type NamedTypeData ¶
type ParsedFile ¶
type ParsedFile struct { FullPath string FileNode *ast.File Package string PackagePath string Imports map[string]string }
func NewParsedFile ¶
func NewParsedFile(srcFile string) (out *ParsedFile, err error)
func (*ParsedFile) NodeToType ¶
func (parsedFile *ParsedFile) NodeToType(node ast.Node, typeLibrary ITypeLibrary) *Type
*
- Convert a node to a type.
func (*ParsedFile) ProcessNode ¶
func (parsedFile *ParsedFile) ProcessNode(typeLibrary ITypeLibrary) error
*
- Parses a file and returns a map of types indexed by name.
type RecordTypeData ¶
type RecordTypeData struct { NamedTypeData // Type of each member in the struct Bases []*Type Fields []*Field }
func (*RecordTypeData) NumBases ¶
func (td *RecordTypeData) NumBases() int
func (*RecordTypeData) NumFields ¶
func (td *RecordTypeData) NumFields() int
type ReferenceTypeData ¶
type ReferenceTypeData struct { // The target type this is a reference to TargetType *Type }
type TupleTypeData ¶
type TupleTypeData struct {
SubTypes []*Type
}
type Type ¶
type Type struct { // One of the above type classes TypeClass int TypeData interface{} }
func (*Type) AsAliasType ¶
func (t *Type) AsAliasType() *AliasTypeData
func (*Type) AsFunctionType ¶
func (t *Type) AsFunctionType() *FunctionTypeData
func (*Type) AsListType ¶
func (t *Type) AsListType() *ListTypeData
func (*Type) AsMapType ¶
func (t *Type) AsMapType() *MapTypeData
func (*Type) AsNamedType ¶
func (t *Type) AsNamedType() *NamedTypeData
func (*Type) AsRecordType ¶
func (t *Type) AsRecordType() *RecordTypeData
func (*Type) AsReferenceType ¶
func (t *Type) AsReferenceType() *ReferenceTypeData
func (*Type) AsTupleType ¶
func (t *Type) AsTupleType() *TupleTypeData
func (*Type) IsAliasType ¶
func (*Type) IsFunctionType ¶
func (*Type) IsListType ¶
func (*Type) IsNamedType ¶
func (*Type) IsNullType ¶
func (*Type) IsRecordType ¶
func (*Type) IsReferenceType ¶
func (*Type) IsTupleType ¶
func (*Type) IsUnresolvedType ¶
func (*Type) LeafType ¶
func (t *Type) LeafType() *NamedTypeData
func (*Type) TypeClassString ¶
type TypeLibrary ¶
type TypeLibrary struct {
// contains filtered or unexported fields
}
func NewTypeLibrary ¶
func NewTypeLibrary() *TypeLibrary
func (*TypeLibrary) AddGlobalType ¶
func (tl *TypeLibrary) AddGlobalType(name string) (alt *Type)
func (*TypeLibrary) AddPackage ¶
func (tl *TypeLibrary) AddPackage(pkg string) (shortName string)
func (*TypeLibrary) AddType ¶
func (tl *TypeLibrary) AddType(pkg string, name string, t *Type) (alt *Type)
*
- Adds a type to the type system. If the type already exists then
- the existing one is returned otherwise a new type is added and returned.
- Also the type's ID will be set.
func (*TypeLibrary) ForEach ¶
func (tl *TypeLibrary) ForEach(mapFunc func(string, *Type, *bool))
*
- Returns all the types as a list.
func (*TypeLibrary) GetGlobalType ¶
func (tl *TypeLibrary) GetGlobalType(name string) (alt *Type)
func (*TypeLibrary) PackageByShortName ¶
func (tl *TypeLibrary) PackageByShortName(name string) string
func (*TypeLibrary) ShortNameForPackage ¶
func (tl *TypeLibrary) ShortNameForPackage(pkg string) string
func (*TypeLibrary) Signature ¶
func (tl *TypeLibrary) Signature(t *Type) string
func (*TypeLibrary) TransitiveClosureFrom ¶
func (*TypeLibrary) TypeListSignature ¶
func (tl *TypeLibrary) TypeListSignature(types []*Type, argfmt string) string
Click to show internal directories.
Click to hide internal directories.