parser

package
v0.0.0-...-9e23852 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetModulePath

func GetModulePath(dirPath string) (modPath string, err error)

Types

type Field

type Field struct {
	Var *types.Var
	Type
	// contains filtered or unexported fields
}

func NewField

func NewField(v *types.Var) Field

func (Field) IsDefined

func (field Field) IsDefined() bool

IsDefined return true if Var type is set.

func (Field) Name

func (field Field) Name() string

type File

type File struct {
	Name    string
	Content []byte
}

type Function

type Function struct {
	Name        string
	Arguments   []Field
	Results     ResultFields
	Receiver    Field
	Package     string
	ServiceType string
}

type Package

type Package struct {
	Name  string
	Alias string
	Path  string
}

func NewPackage

func NewPackage(path string, modulePath string) *Package

NewPackage returns new Packege instance wit initialized Name, Alias and Path.

type Parser

type Parser struct {
	Package *Package
	Service *tieTypes.Service
	Pkg     *types.Package
	// contains filtered or unexported fields
}

func NewParser

func NewParser(service *tieTypes.Service) *Parser

NewParser creates new parser.

func (*Parser) GetFunctions

func (p *Parser) GetFunctions() (functions []Function)

GetFunctions returns exported functions from package

func (*Parser) GetPackageName

func (p *Parser) GetPackageName() string

GetPackageName returns package name.

func (*Parser) GetTypes

func (p *Parser) GetTypes() (specs []*TypeSpec, err error)

GetTypes returns exported sturct types from package

func (*Parser) Parse

func (p *Parser) Parse(pkgPath string) error

Parse initializes parser by parsing package. Should be called before any other method.

func (*Parser) ToFiles

func (p *Parser) ToFiles() (files []File)

ToFiles returns array of files in package. Each file represents as a bytes array.

func (*Parser) UpgradeApiImports

func (p *Parser) UpgradeApiImports(imports []string, upgrade func(string) string) bool

UpgradeApiImports returns false if import deleted but not added.

type ResultFields

type ResultFields struct {
	Last Field
	// contains filtered or unexported fields
}

TODO make Last field of type ErrField ("parse, not validate")

func (ResultFields) List

func (rf ResultFields) List() []Field

type StructType

type StructType struct {
	Name   string
	Fields []Field
}

func NewStructType

func NewStructType(name string, fields []Field) StructType

type Type

type Type struct {
	// contains filtered or unexported fields
}

func (Type) TypeName

func (t Type) TypeName() string

func (Type) TypeParts

func (t Type) TypeParts() (prefix, path, local string)

type TypeSpec

type TypeSpec struct {
	Name   string
	Fields []Field
}

Jump to

Keyboard shortcuts

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