types

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopySlice

func CopySlice[T IElem[T]](src []T) []T

func CopySliceWithFilter

func CopySliceWithFilter[T IElem[T]](src []T, filter func(T) bool) []T

Types

type Comment

type Comment struct {
	Index      int                `json:"index"`
	Content    string             `json:"content"`           //原始的一行注释内容
	IsSelf     bool               `json:"is_self,omitempty"` // 注释是否是以自己名称开头
	Op         bool               `json:"op,omitempty"`
	AttrType   constants.AttrType `json:"attr_type"`
	CustomAttr string             `json:"custom_attr,omitempty"`
	AttrValue  string             `json:"attr_value,omitempty"`
}

func OfComment

func OfComment(index int, content string, selfName string) *Comment

func (*Comment) Clone

func (c *Comment) Clone() *Comment

func (*Comment) GetWithoutSelf

func (c *Comment) GetWithoutSelf(name string) string

func (*Comment) IsHttpMethod

func (c *Comment) IsHttpMethod() bool

func (*Comment) String

func (c *Comment) String() string

type Const

type Const = Variable

type Enum

type Enum struct {
	Index    int                `json:"index"`
	Type     string             `json:"type"`
	TypeName string             `json:"type_name"`
	ElemType constants.ElemType `json:"elem_type"`
	Name     string             `json:"name"`
	Doc      []*Comment         `json:"doc,omitempty"`
	Comment  []*Comment         `json:"comment,omitempty"`
	Private  bool               `json:"private,omitempty"`
	Iota     bool               `json:"iota"`
	Enums    []*EnumItem        `json:"enums,omitempty"`
}

func (*Enum) Clone

func (e *Enum) Clone() *Enum

func (*Enum) String

func (e *Enum) String() string

type EnumItem

type EnumItem struct {
	Index   int        `json:"index"`
	Name    string     `json:"name"`
	Type    string     `json:"type"`
	Value   any        `json:"value"`
	Private bool       `json:"private"`
	Doc     []*Comment `json:"doc,omitempty"`
	Comment []*Comment `json:"comment,omitempty"`
}

func (*EnumItem) Clone

func (e *EnumItem) Clone() *EnumItem

func (*EnumItem) String

func (e *EnumItem) String() string

type Field

type Field struct {
	Index     int          `json:"index"`
	Name      string       `json:"name"`
	TypeName  string       `json:"type_name"`
	Type      string       `json:"type"`
	Parent    bool         `json:"parent,omitempty"`
	Private   bool         `json:"private,omitempty"`
	Generic   bool         `json:"generic,omitempty"`
	Slice     bool         `json:"slice,omitempty"`
	Pointer   bool         `json:"pointer,omitempty"`
	TypeParam []*TypeParam `json:"type_param,omitempty"`
	Tag       string       `json:"tag,omitempty"`
	Doc       []*Comment   `json:"doc,omitempty"`
	Comment   []*Comment   `json:"comment,omitempty"`
	Struct    *Struct      `json:"struct,omitempty"`
	Package   *Package     `json:"package,omitempty"`
}

func (*Field) Clone

func (f *Field) Clone() *Field

func (*Field) GetTag

func (f *Field) GetTag() reflect.StructTag

func (*Field) GetTagByName

func (f *Field) GetTagByName(name string) string

func (*Field) HasTag

func (f *Field) HasTag() bool

func (*Field) IsTop

func (f *Field) IsTop() bool

func (*Field) String

func (f *Field) String() string

type File

type File struct {
	Name      string       `json:"name"`
	Key       string       `json:"-"`
	KeyHash   string       `json:"-"`
	Package   *Package     `json:"package,omitempty"`
	Comment   []*Comment   `json:"comment,omitempty"`
	Import    []*Import    `json:"import,omitempty"`
	Variable  []*Variable  `json:"variable,omitempty"`
	Const     []*Const     `json:"const,omitempty"`
	Function  []*Function  `json:"function,omitempty"`
	Interface []*Interface `json:"interface,omitempty"`
	Struct    []*Struct    `json:"struct,omitempty"`
}

func (*File) Clone

func (f *File) Clone() *File

func (*File) FindStruct

func (f *File) FindStruct(keyHash string) *Struct

func (*File) IsMainPackage

func (f *File) IsMainPackage() bool

func (*File) String

func (f *File) String() string

type Function

type Function struct {
	Name string `json:"name"`
	//Key       string             `json:"key"`
	//KeyHash   string             `json:"key_hash"`
	ElemType  constants.ElemType `json:"elem_type,omitempty"`
	TypeName  string             `json:"type_name"`
	Doc       []*Comment         `json:"doc,omitempty"`
	Private   bool               `json:"private,omitempty"`
	Index     int                `json:"index"`
	Package   *Package           `json:"package,omitempty"`
	Generic   bool               `json:"generic,omitempty"`
	TypeParam []*TypeParam       `json:"type_param,omitempty"`
	Param     []*Param           `json:"param,omitempty"`
	Result    []*Param           `json:"result,omitempty"`
	Receiver  *Receiver          `json:"receiver,omitempty"`
	// contains filtered or unexported fields
}

func (*Function) Clone

func (f *Function) Clone() *Function

func (*Function) GetAttrValue

func (f *Function) GetAttrValue(attr constants.AttrType) string

func (*Function) GetAttrs

func (f *Function) GetAttrs() []*Comment

func (*Function) GetCustomAttrs

func (f *Function) GetCustomAttrs() []*Comment

func (*Function) GetHttpMethodAttrs

func (f *Function) GetHttpMethodAttrs() []*Comment

func (*Function) GetRValue

func (f *Function) GetRValue() reflect.Value

func (*Function) GetValue

func (f *Function) GetValue() any

func (*Function) HasAttr

func (f *Function) HasAttr(attr constants.AttrType) bool

func (*Function) HasAttrs

func (f *Function) HasAttrs() bool

func (*Function) IsOp

func (f *Function) IsOp() bool

func (*Function) SetRValue

func (f *Function) SetRValue(t reflect.Value)

func (*Function) SetValue

func (f *Function) SetValue(t any)

func (*Function) String

func (f *Function) String() string

func (*Function) VisitParams

func (f *Function) VisitParams(handler func(param *Param))

func (*Function) VisitResults

func (f *Function) VisitResults(handler func(param *Param))

type IElem

type IElem[T any] interface {
	String() string
	Clone() T
}

type Import

type Import struct {
	Name   string `json:"name"`
	Alias  string `json:"alias,omitempty"`
	Path   string `json:"path,omitempty"`
	Ignore bool   `json:"ignore,omitempty"`
}

type Interface

type Interface struct {
	Index     int                `json:"index"`
	Name      string             `json:"name"`
	ElemType  constants.ElemType `json:"elem_type"`
	TypeName  string             `json:"type_name"`
	TypeParam []*TypeParam       `json:"type_param,omitempty"`
	Function  []*Function        `json:"function,omitempty"`
	Doc       []*Comment         `json:"doc,omitempty"`
	Param     []*Param           `json:"param,omitempty"`
	Result    []*Param           `json:"result,omitempty"`
}

func (*Interface) Clone

func (i *Interface) Clone() *Interface

func (*Interface) String

func (i *Interface) String() string

type Package

type Package struct {
	FileName string                `json:"file_name,omitempty"`
	FilePath string                `json:"file_path,omitempty"`
	Name     string                `json:"name,omitempty"`
	Path     string                `json:"path,omitempty"`
	Type     constants.PackageType `json:"type"`
}

func (*Package) Clone

func (p *Package) Clone() *Package

func (*Package) IsThis

func (p *Package) IsThis() bool

func (*Package) String

func (p *Package) String() string

type Param

type Param struct {
	Index     int                `json:"index"`
	Name      string             `json:"name"`
	TypeName  string             `json:"type_name"`
	ElemType  constants.ElemType `json:"elem_type,omitempty"`
	Package   *Package           `json:"package,omitempty"`
	Type      string             `json:"type"`
	Slice     bool               `json:"slice,omitempty"`
	Pointer   bool               `json:"pointer,omitempty"`
	Generic   bool               `json:"generic,omitempty"`
	TypeParam []*TypeParam       `json:"type_param,omitempty"`
	Struct    *Struct            `json:"struct,omitempty"`
	// contains filtered or unexported fields
}

func (*Param) Clone

func (p *Param) Clone() *Param

func (*Param) GetRType

func (p *Param) GetRType() reflect.Type

func (*Param) SetRType

func (p *Param) SetRType(t reflect.Type)

func (*Param) String

func (p *Param) String() string

type PkgType

type PkgType struct {
	IsGeneric bool
	IsSlice   bool
	IsPtr     bool
	PkgPath   string
	PkgName   string
	TypeName  string
	PkgType   constants.PackageType
}

type Project

type Project struct {
	ModPkg     string           `json:"mod_pkg,omitempty"`
	BaseDir    string           `json:"base_dir,omitempty"`
	ModName    string           `json:"mod_name,omitempty"`
	ModVersion string           `json:"mod_version,omitempty"`
	ModPath    string           `json:"mod_path,omitempty"`
	SdkPath    string           `json:"sdk_path,omitempty"`
	Timestamp  int64            `json:"timestamp,omitempty"`
	Generator  string           `json:"generator,omitempty"`
	Version    string           `json:"version,omitempty"`
	FileMap    map[string]*File `json:"file,omitempty"`
}

func (*Project) AddFile

func (p *Project) AddFile(f *File)

func (*Project) AfterParseProj

func (p *Project) AfterParseProj()

func (*Project) FindStruct

func (p *Project) FindStruct(keyHash string) *Struct

func (*Project) Merge

func (p *Project) Merge(files map[string]*File)

func (*Project) Read

func (p *Project) Read(path string) error

func (*Project) Write

func (p *Project) Write(fileName string) error

type Receiver

type Receiver struct {
	Name      string             `json:"name"`
	Pointer   bool               `json:"pointer,omitempty"`
	ElemType  constants.ElemType `json:"elem_type,omitempty"`
	Type      string             `json:"type"`
	TypeName  string             `json:"type_name"`
	Generic   bool               `json:"generic,omitempty"`
	TypeParam []*TypeParam       `json:"type_param,omitempty"`
	Struct    *Struct            `json:"struct,omitempty"`
}

func (*Receiver) Clone

func (r *Receiver) Clone() *Receiver

func (*Receiver) String

func (r *Receiver) String() string

type Struct

type Struct struct {
	Name      string             `json:"name"`
	Index     int                `json:"index"`
	Key       string             `json:"-"`
	KeyHash   string             `json:"-"`
	TypeName  string             `json:"type_name"`
	Type      string             `json:"type"`
	Private   bool               `json:"private,omitempty"`
	Generic   bool               `json:"generic,omitempty"`
	Top       bool               `json:"top,omitempty"`
	ElemType  constants.ElemType `json:"elem_type"`
	TypeParam []*TypeParam       `json:"type_param,omitempty"`
	Field     []*Field           `json:"field,omitempty"`
	Doc       []*Comment         `json:"doc,omitempty"`
	Comment   []*Comment         `json:"comment,omitempty"`
	Method    []*Function        `json:"method,omitempty"`
	Package   *Package           `json:"package,omitempty"`
	Enum      *Enum              `json:"enum,omitempty"`
	// contains filtered or unexported fields
}

func (*Struct) Clone

func (s *Struct) Clone() *Struct

Clone returns a deep copy of the struct without the methods

func (*Struct) CloneFull

func (s *Struct) CloneFull() *Struct

CloneFull returns a deep copy of the struct with the methods

func (*Struct) GetAttr

func (s *Struct) GetAttr() constants.AttrType

func (*Struct) GetAttrValue

func (s *Struct) GetAttrValue(attr constants.AttrType) string

func (*Struct) GetAttrs

func (s *Struct) GetAttrs() []*Comment

func (*Struct) GetCustomAttrs

func (s *Struct) GetCustomAttrs() []*Comment

func (*Struct) GetRType

func (s *Struct) GetRType() reflect.Type

func (*Struct) GetRValue

func (s *Struct) GetRValue() reflect.Value

func (*Struct) GetValue

func (s *Struct) GetValue() any

func (*Struct) HasAttr

func (s *Struct) HasAttr(attr constants.AttrType) bool

func (*Struct) HasCustomAttr

func (s *Struct) HasCustomAttr(attr string) bool

func (*Struct) HasParamAttr

func (s *Struct) HasParamAttr() bool

func (*Struct) IsEnum

func (s *Struct) IsEnum() bool

func (*Struct) IsTop

func (s *Struct) IsTop() bool

func (*Struct) SetRType

func (s *Struct) SetRType(t reflect.Type)

func (*Struct) SetRValue

func (s *Struct) SetRValue(r reflect.Value)

func (*Struct) SetValue

func (s *Struct) SetValue(v any)

func (*Struct) String

func (s *Struct) String() string

func (*Struct) VisitFields

func (s *Struct) VisitFields(filter func(f *Field) bool, handler func(f *Field))

func (*Struct) VisitMethods

func (s *Struct) VisitMethods(filter func(f *Function) bool, handler func(f *Function))

type TypeParam

type TypeParam struct {
	Type          string             `json:"type"`
	TypeName      string             `json:"type_name"`
	Index         int                `json:"index"`
	Key           string             `json:"key"`
	ElemType      constants.ElemType `json:"elem_type,omitempty"`
	Pointer       bool               `json:"pointer,omitempty"`
	Slice         bool               `json:"slice,omitempty"`
	TypeInterface string             `json:"type_interface,omitempty"`
	Struct        *Struct            `json:"struct,omitempty"`
	Package       *Package           `json:"package,omitempty"`
}

func (*TypeParam) Clone

func (t *TypeParam) Clone() *TypeParam

func (*TypeParam) CloneTiny

func (t *TypeParam) CloneTiny() *TypeParam

func (*TypeParam) String

func (t *TypeParam) String() string

type TypePkgInfo added in v0.4.2

type TypePkgInfo struct {
	Imports    []*Import
	ModPkg     string
	CurrentPkg string
	Valid      bool
	Pointer    bool
	Slice      bool
	PkgName    string
	Name       string
	PkgType    constants.PackageType
	PkgPath    string
	Generic    bool
	FullName   string
	Children   []*TypePkgInfo
}

func NewTypePkgInfo added in v0.4.2

func NewTypePkgInfo(modPkg string, currentPkg string, imports []*Import) *TypePkgInfo

type Variable

type Variable struct {
	Name     string             `json:"name"`
	ElemType constants.ElemType `json:"elem_type"`
	Index    int                `json:"index"`
	Value    any                `json:"value"`
	Type     string             `json:"type"`
	TypeName string             `json:"type_name"`
	Iota     bool               `json:"iota,omitempty"`
	Package  *Package           `json:"package,omitempty"`
	Struct   *Struct            `json:"struct,omitempty"`
	Doc      []*Comment         `json:"doc,omitempty"`
	Comment  []*Comment         `json:"comment,omitempty"`
}

func (*Variable) Clone

func (v *Variable) Clone() *Variable

func (*Variable) String

func (v *Variable) String() string

Jump to

Keyboard shortcuts

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