traverser

package
v0.0.0-...-70f9d4a Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AssignmentTmpl = `
{{ .BFieldPath }} = {{ .AFieldPath }}`
View Source
const DefaultMapTmpl = `` /* 168-byte string literal not displayed */
View Source
const DefaultPointerTmpl = `
if {{ .AFieldPath }} != nil {
  {{ .BFieldPath }} = new({{ .NonPointerTypeB }})
{{ .Statements }}
}`
View Source
const DefaultSliceTmpl = `` /* 170-byte string literal not displayed */
View Source
const DirectProducerTmpl = `` /* 234-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignmentTmplInput

type AssignmentTmplInput struct {
	AFieldPath string
	BFieldPath string
}

type Basic

type Basic struct {
	Templates        map[types.BasicKind]string
	PointerTemplates map[types.BasicKind]string
}

func NewBasic

func NewBasic() *Basic

func (*Basic) Print

func (bs *Basic) Print(a, b *types.Basic, aFieldPath, bFieldPath string, isPointer bool) (string, error)

func (*Basic) SetPointerTemplate

func (bs *Basic) SetPointerTemplate(t map[types.BasicKind]string)

func (*Basic) SetTemplate

func (bs *Basic) SetTemplate(t map[types.BasicKind]string)

type BasicTraverser

type BasicTraverser interface {
	SetTemplate(t map[types.BasicKind]string)
	SetPointerTemplate(t map[types.BasicKind]string)
	Print(a, b *types.Basic, aFieldPath, bFieldPath string, isPointer bool) (string, error)
}

type DefaultMapTmplInput

type DefaultMapTmplInput struct {
	AFieldPath string
	TypeA      string
	BFieldPath string
	TypeB      string
	Key        string
	Value      string
	Statements string
}

type Generic

type Generic struct {
	Imports *packages.Imports
	Named   NamedTraverser
	Slice   SliceTraverser
	Basic   BasicTraverser
	Map     MapTraverser
	Pointer PointerTraverser
}

func NewGeneric

func NewGeneric(im *packages.Imports, opts ...Option) *Generic

func (*Generic) Print

func (g *Generic) Print(a, b types.Type, aFieldPath, bFieldPath string, levelNum int) (string, error)

type GenericCaller

type GenericCaller interface {
	SetGenericTraverser(p GenericTraverser)
}

type GenericTraverser

type GenericTraverser interface {
	Print(a, b types.Type, aFieldPath, bFieldPath string, levelNum int) (string, error)
}

type Map

type Map struct {
	Template string
	Imports  *packages.Imports
	Generic  GenericTraverser
}

func NewMap

func NewMap(im *packages.Imports) *Map

func (*Map) Print

func (m *Map) Print(a, b *types.Map, aFieldPath, bFieldPath string, levelNum int) (string, error)

func (*Map) SetGenericTraverser

func (m *Map) SetGenericTraverser(p GenericTraverser)

func (*Map) SetTemplate

func (m *Map) SetTemplate(t string)

type MapTraverser

type MapTraverser interface {
	GenericCaller
	Templater
	Print(a, b *types.Map, aFieldPath, bFieldPath string, levelNum int) (string, error)
}

type Named

type Named struct {
	Generic GenericTraverser
}

func NewNamed

func NewNamed() *Named

func (*Named) Print

func (s *Named) Print(a, b *types.Named, aFieldPath, bFieldPath string, levelNum int) (string, error)

func (*Named) SetGenericTraverser

func (s *Named) SetGenericTraverser(p GenericTraverser)

type NamedTraverser

type NamedTraverser interface {
	GenericCaller
	Print(a, b *types.Named, aFieldPath, bFieldPath string, levelNum int) (string, error)
}

type Option

type Option func(*Generic)

func WithBasic

func WithBasic(b BasicTraverser) Option

func WithBasicPointerTemplate

func WithBasicPointerTemplate(t map[types.BasicKind]string) Option

func WithBasicTemplate

func WithBasicTemplate(t map[types.BasicKind]string) Option

func WithMap

func WithMap(m MapTraverser) Option

func WithMapTemplate

func WithMapTemplate(t string) Option

func WithNamed

func WithNamed(n NamedTraverser) Option

func WithPointer

func WithPointer(p PointerTraverser) Option

func WithPointerTemplate

func WithPointerTemplate(t string) Option

func WithSlice

func WithSlice(s SliceTraverser) Option

func WithSliceTemplate

func WithSliceTemplate(t string) Option

type Pointer

type Pointer struct {
	Template string
	Imports  *packages.Imports
	Generic  GenericTraverser
}

func NewPointer

func NewPointer(im *packages.Imports) *Pointer

func (*Pointer) Print

func (p *Pointer) Print(a, b *types.Pointer, aFieldPath, bFieldPath string, levelNum int) (string, error)

func (*Pointer) SetGenericTraverser

func (p *Pointer) SetGenericTraverser(tt GenericTraverser)

func (*Pointer) SetTemplate

func (p *Pointer) SetTemplate(t string)

type PointerTmplInput

type PointerTmplInput struct {
	AFieldPath      string
	TypeA           string
	NonPointerTypeA string
	BFieldPath      string
	TypeB           string
	NonPointerTypeB string
	Statements      string
}

type PointerTraverser

type PointerTraverser interface {
	GenericCaller
	Templater
	Print(a, b *types.Pointer, aFieldPath, bFieldPath string, levelNum int) (string, error)
}

type Printer

type Printer struct {
	Imports   *packages.Imports
	Traverser GenericTraverser
	Template  string
}

func NewPrinter

func NewPrinter(im *packages.Imports, tr GenericTraverser, opts ...PrinterOption) *Printer

func (*Printer) Print

func (p *Printer) Print(name string, a, b types.Type, extraInput map[string]interface{}) (string, error)

type PrinterOption

type PrinterOption func(p *Printer)

func WithTemplate

func WithTemplate(t string) PrinterOption

type Slice

type Slice struct {
	Template string
	Imports  *packages.Imports
	Generic  GenericTraverser
}

func NewSlice

func NewSlice(im *packages.Imports) *Slice

func (*Slice) Print

func (s *Slice) Print(a, b *types.Slice, aFieldPath, bFieldPath string, levelNum int) (string, error)

func (*Slice) SetGenericTraverser

func (s *Slice) SetGenericTraverser(p GenericTraverser)

func (*Slice) SetTemplate

func (s *Slice) SetTemplate(t string)

type SliceTmplInput

type SliceTmplInput struct {
	AFieldPath string
	TypeA      string
	BFieldPath string
	TypeB      string
	Index      string
	Statements string
}

type SliceTraverser

type SliceTraverser interface {
	GenericCaller
	Templater
	Print(a, b *types.Slice, aFieldPath, bFieldPath string, levelNum int) (string, error)
}

type Templater

type Templater interface {
	SetTemplate(t string)
}

Jump to

Keyboard shortcuts

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