parser

package
v0.0.0-...-19abfbe Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetModule

func GetModule(path string) (modPath string, file *modfile.File, err error)

Types

type Arg

type Arg interface {
	Type() string
	Value() string
	String() string
}

func NewArg

func NewArg(arg ast.Expr) (av Arg)

type ArgComposite

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

func NewComposite

func NewComposite(compositeLit *ast.CompositeLit) (composit ArgComposite)

func (ArgComposite) String

func (a ArgComposite) String() string

func (ArgComposite) Type

func (a ArgComposite) Type() string

func (ArgComposite) Value

func (a ArgComposite) Value() string

type ArgValue

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

func (ArgValue) String

func (a ArgValue) String() string

func (ArgValue) Type

func (a ArgValue) Type() string

func (ArgValue) Value

func (a ArgValue) Value() string

type CompositeKeyValue

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

type Field

type Field struct {
	Name        string
	Type        string
	Tags        []Tag
	Comment     string
	Package     *ImportPackage
	Struct      *Struct
	IsLocalType bool
}

func NewField

func NewField(astField *ast.Field, imports Imports) (field *Field)

func (*Field) Clone

func (f *Field) Clone() *Field

func (*Field) Has

func (f *Field) Has(tagKey string) bool

func (*Field) IsNestedStructType

func (f *Field) IsNestedStructType() bool

func (*Field) IsNotPrimitiveType

func (f *Field) IsNotPrimitiveType() bool

func (*Field) IsPrimitiveType

func (f *Field) IsPrimitiveType() bool

func (*Field) String

func (f *Field) String() string

type FunctionCall

type FunctionCall struct {
	Package *ImportPackage
	Name    string
	Args    []Arg
}

func NewFunctionCall

func NewFunctionCall(exprStmt *ast.ExprStmt, imports Imports) (fc *FunctionCall)

func (*FunctionCall) ArgString

func (fc *FunctionCall) ArgString() string

func (*FunctionCall) String

func (fc *FunctionCall) String() string

type GoFile

type GoFile struct {
	PackageName string
	Structs     []*Struct
	Init        struct {
		FuncCalls []*FunctionCall
	}
}

func ParseGoFile

func ParseGoFile(path string) (file GoFile)

type ImportPackage

type ImportPackage struct {
	Alias       string
	PackageName string
	Path        string
}

func NewImportPackage

func NewImportPackage(importSpec *ast.ImportSpec) (im *ImportPackage)

func (*ImportPackage) String

func (p *ImportPackage) String() string

type Imports

type Imports []*ImportPackage

func NewImports

func NewImports(astImports []*ast.ImportSpec) Imports

func (Imports) Append

func (imps Imports) Append(importSpec *ast.ImportSpec) Imports

func (Imports) GetByAlias

func (imps Imports) GetByAlias(alias string) (imp *ImportPackage)

type Struct

type Struct struct {
	Name   string
	Fields []*Field
	Ast    *ast.StructType
}

func NewStruct

func NewStruct(name string, astStruct *ast.StructType, imports Imports) (st *Struct)

func (*Struct) Dependencies

func (st *Struct) Dependencies() (imports []string)

func (*Struct) NotEmbeddingFields

func (st *Struct) NotEmbeddingFields() []*Field

func (*Struct) String

func (st *Struct) String() (str string)

func (*Struct) TagExist

func (st *Struct) TagExist(tag string) (ok bool)

func (*Struct) UnWarpedFields

func (st *Struct) UnWarpedFields() (fields []*Field)

type Tag

type Tag struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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