parser

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenerateFileSuffix = "_zenrpc.go"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg struct {
	Name            string
	Type            string
	CapitalName     string
	CaseName        string
	HasStar         bool
	HasDefaultValue bool
	Description     string // from magic comment
	SMDType         SMDType
}

func (Arg) String added in v1.1.0

func (a Arg) String() string

type DefaultValue

type DefaultValue struct {
	Name        string
	CapitalName string
	Type        string // without star
	Comment     string // original comment
	Value       string
}

type Interface added in v1.2.0

type Interface struct {
	Name          string // key in map, Ref in arguments and returns
	Namespace     string
	Type          string
	InterfaceType *ast.InterfaceType
	Properties    []Property // array because order is important
}

type Method

type Method struct {
	FuncDecl           *ast.FuncType
	Name               string
	EndpointName       string
	SchemaEndpointName string
	HasContext         bool
	Args               []Arg
	DefaultValues      map[string]DefaultValue
	Returns            []Return
	SMDReturn          *SMDReturn // return for generate smd schema; pointer for nil check
	Description        string

	Errors []SMDError // errors for documentation in SMD
}

func (Method) String added in v1.1.0

func (m Method) String() string

type PackageInfo

type PackageInfo struct {
	Dir string

	PackageName string
	Services    []*Service

	Scopes  map[string][]*ast.Scope // key - import name, value - array of scopes from each package file
	Structs map[string]*Struct
	Imports []*ast.ImportSpec

	StructsNamespacesFromArgs map[string]struct{} // set of structs names from arguments for printing imports
	ImportsForGeneration      []*ast.ImportSpec
	// contains filtered or unexported fields
}

PackageInfo represents struct info for XXX_zenrpc.go file generation

func NewPackageInfo

func NewPackageInfo(useSnakeCase bool) *PackageInfo

func (*PackageInfo) Parse

func (pi *PackageInfo) Parse(filename string) error

ParseFiles parse all files associated with package from original file

func (PackageInfo) String

func (pi PackageInfo) String() string

type Property

type Property struct {
	Name        string
	Description string
	SMDType     SMDType
}

type Return

type Return struct {
	Name string
	Type string
}

type SMDError

type SMDError struct {
	Code        int
	Description string
}

type SMDReturn

type SMDReturn struct {
	Name        string
	HasStar     bool
	Description string
	SMDType     SMDType
}

type SMDType

type SMDType struct {
	Type      string
	ItemsType string // for array
	Ref       string // for object and also if array item is object
}

SMDType is a type representation for SMD generation

type Service

type Service struct {
	GenDecl     *ast.GenDecl
	Name        string
	Methods     []*Method
	Description string
	IsInterface bool
}

func (Service) HasErrorVariable

func (s Service) HasErrorVariable() bool

HasErrorVariable define adding err variable to generated Invoke function

type Struct

type Struct struct {
	Name       string // key in map, Ref in arguments and returns
	Namespace  string
	Type       string
	StructType *ast.StructType
	Properties []Property // array because order is important
}

func Definitions

func Definitions(smdType SMDType, structs map[string]*Struct) []*Struct

Definitions returns list of structs used inside smdType

Jump to

Keyboard shortcuts

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