parser

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func EntryPointPackageName

func EntryPointPackageName(filename string) (string, string, error)

Types

type Arg

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

type DefaultValue

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

type Method

type Method struct {
	FuncDecl      *ast.FuncType
	Name          string
	LowerCaseName 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
}

type PackageFiles

type PackageFiles struct {
	PackagePath string
	PackageName string

	AstFiles []*ast.File
}

func GetDependenciesAstFiles

func GetDependenciesAstFiles(filename string) ([]PackageFiles, error)

type PackageInfo

type PackageInfo struct {
	EntryPoint  string
	Dir         string
	PackageName string
	PackagePath 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

	PackageNamesAndAliasesUsedInServices map[string]struct{} // set of structs names from arguments for printing imports
	ImportsIncludedToGeneratedCode       []*ast.ImportSpec
}

PackageInfo represents struct info for XXX_zenrpc.go file generation

func NewPackageInfo

func NewPackageInfo(filename string) (*PackageInfo, error)

func (PackageInfo) OutputFilename

func (pi PackageInfo) OutputFilename() string

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
}

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