parse

package
v0.0.0-...-bdf6e57 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReceiverLine     = 1 << 1
	FunctionNameLine = 1 << 2
)

Variables

View Source
var ParamTypes = map[string]ParamStructType{
	"struct":    structFunc,
	"slice":     sliceFunc,
	"array":     arrayFunc,
	"map":       mapFunc,
	"func":      funcFunc,
	"interface": interfaceFunc,
	"chan":      chanFunc,
}
View Source
var ReturnNameMap = map[ReturnType]string{
	StructReturn:    "struct",
	SliceReturn:     "slice",
	ArrayReturn:     "array",
	MapReturn:       "map",
	FuncReturn:      "func",
	InterFaceReturn: "interface",
	ChanReturn:      "chan",
}

Functions

func CheckPointer

func CheckPointer(s string) (t string, p bool)

func Contain

func Contain(sourceStruct *SourceStruct, i *ImportStruct) bool

func FunctionNameLineNum

func FunctionNameLineNum(lines []*FuncLine) int

func FunctionReceiverLineNum

func FunctionReceiverLineNum(lines []*FuncLine) int

func SourcePrettyText

func SourcePrettyText(
	sources []*SourceStruct) string

Types

type Double

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

func (*Double) End

func (d *Double) End(r rune) bool

type FuncLine

type FuncLine struct {
	LineString string
	LineNum    int
	Types      int
}

type FuncStruct

type FuncStruct struct {
	FuncString  string
	Receiver    *ReceiverStruct
	FuncName    string
	FuncLine    int
	FuncEndLine int
	Params      []*ParamStruct
	ReturnLine  int
	Returns     []ReturnType
	NameLine    int
	LineString  []*FuncLine
}

func NewFuncStruct

func NewFuncStruct(name string, line *int) *FuncStruct

type ImportStruct

type ImportStruct struct {
	ImportTag     string
	ImportString  string
	ImportEndTerm string
	SourceTag     string
	SourceContain bool
}

func ImportCopy

func ImportCopy(imports []*ImportStruct) (result []*ImportStruct)

func ImportStr

func ImportStr(str string) *ImportStruct

type ParamStruct

type ParamStruct struct {
	Pointer    bool
	Name       string
	ParamType  string
	StructType ParamStructType
}

type ParamStructType

type ParamStructType func(str string) (param *ParamStruct)

func GetTypeStruct

func GetTypeStruct(t string) ParamStructType

type ReceiverStruct

type ReceiverStruct struct {
	Pointer  bool
	Alias    string
	Receiver string
}

type ReturnType

type ReturnType int
const (
	StructReturn ReturnType
	SliceReturn
	ArrayReturn
	MapReturn
	FuncReturn
	InterFaceReturn
	ChanReturn
)

type Single

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

func (*Single) End

func (s *Single) End(r rune) bool

type Skip

type Skip interface {
	End(r rune) bool
}

type SkipHolder

type SkipHolder struct {
	Skip
}

func (*SkipHolder) NeedSkip

func (h *SkipHolder) NeedSkip(r rune) bool

type SourceStruct

type SourceStruct struct {
	Path         string
	XgcPath      string
	PackageStr   string
	Imports      []*ImportStruct
	Funcs        []*FuncStruct
	InjectImport func(sourceStruct *SourceStruct, imports []*ImportStruct)
	ImportLine   int
	FileLine     int
}

func NewSourceStruct

func NewSourceStruct(path string) *SourceStruct

func SourceParse

func SourceParse(sourceFile string) *SourceStruct

Jump to

Keyboard shortcuts

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