ast

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAstParse   = errors.New("ast parse error")
	ErrFieldParse = fmt.Errorf("parse field: %w", ErrAstParse)
)

Functions

func Walk

func Walk(n ast.Node, fset *token.FileSet, h FileHandler)

Types

type CommentHandler

type CommentHandler interface {
	// contains filtered or unexported methods
}

type CommentSpec

type CommentSpec struct {
	Text string
	Line int
}

type DocHandler

type DocHandler interface {
	// contains filtered or unexported methods
}

type DocSpec

type DocSpec struct {
	Doc string
}

type FieldCollector

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

type FieldHandler

type FieldHandler interface {
	// contains filtered or unexported methods
}

type FieldSpec

type FieldSpec struct {
	Names   []string
	Doc     string
	Tag     string
	TypeRef FieldTypeRef
	Fields  []*FieldSpec
}

func (*FieldSpec) String

func (fs *FieldSpec) String() string

type FieldTypeRef

type FieldTypeRef struct {
	Name string
	Pkg  string
	Kind FieldTypeRefKind
}

func (FieldTypeRef) String

func (tr FieldTypeRef) String() string

type FieldTypeRefKind

type FieldTypeRefKind int
const (
	FieldTypeIdent FieldTypeRefKind = iota
	FieldTypeSelector
	FieldTypePtr
	FieldTypeArray
	FieldTypeMap
	FieldTypeStruct
)

func (*FieldTypeRefKind) ScanStr

func (r *FieldTypeRefKind) ScanStr(s string) bool

func (FieldTypeRefKind) String

func (i FieldTypeRefKind) String() string

type FileHandler

type FileHandler interface {
	// contains filtered or unexported methods
}

type FileSpec

type FileSpec struct {
	Name   string
	Pkg    string
	Types  []*TypeSpec
	Export bool // tru if file should be exported
}

func (*FileSpec) String

func (fs *FileSpec) String() string

type RootCollector

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

func NewRootCollector

func NewRootCollector(baseDir string, opts ...RootCollectorOption) *RootCollector

func (*RootCollector) Files

func (c *RootCollector) Files() []*FileSpec

type RootCollectorOption

type RootCollectorOption func(*RootCollector)

func WithFileGlob

func WithFileGlob(glob func(string) bool) RootCollectorOption

func WithGoGenDecl

func WithGoGenDecl(line int, file string) RootCollectorOption

func WithTypeGlob

func WithTypeGlob(glob func(string) bool) RootCollectorOption

type T

type T interface {
	Helper()
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

type TestTypeHandler

type TestTypeHandler interface {
	TypeHandler
	CommentHandler

	Types() []*TypeSpec
}

type TypeCollector

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

type TypeHandler

type TypeHandler interface {
	// contains filtered or unexported methods
}

type TypeSpec

type TypeSpec struct {
	Name   string
	Doc    string
	Fields []*FieldSpec
	Export bool // true if type should be exported
}

func (*TypeSpec) String

func (ts *TypeSpec) String() string

Jump to

Keyboard shortcuts

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