code

package
v0.0.0-...-fdde285 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PriorityFirst   = -10
	PrioritySecond  = -1
	PriorityDefault = 0
)
View Source
const Header = `// Code generated by "github.com/podhmo/apikit"; DO NOT EDIT.

`

Variables

View Source
var ErrNoImports = fmt.Errorf("no imports")

Functions

This section is empty.

Types

type Code

type Code struct {
	Name   string
	Header string

	Here *tinypkg.Package

	ImportPackages func(*tinypkg.ImportCollector) error
	EmitCode       func(w io.Writer, c *Code) error // currently used by Config.EmitCodeFunc

	Priority int
	Config   *Config
	// contains filtered or unexported fields
}

func (*Code) AddDependency

func (c *Code) AddDependency(deps ...tinypkg.Node)

func (*Code) CollectImports

func (c *Code) CollectImports(collector *tinypkg.ImportCollector) error

CollectImports is currently used by Config.EmitCodeFunc

func (*Code) Dependencies

func (c *Code) Dependencies() []tinypkg.Node

func (*Code) EmitContent

func (c *Code) EmitContent(w io.Writer) error

EmitContent emits content only (if you want fullset version, please use c.Config.EmitCodeFunc() )

func (*Code) Import

func (c *Code) Import(pkg *tinypkg.Package) *tinypkg.ImportedPackage

func (*Code) OnWalk

func (c *Code) OnWalk(use func(*tinypkg.Symbol) error) error

OnWalk : for pkg/tinypkg.Node

func (*Code) RelativeTypeString

func (c *Code) RelativeTypeString(here *tinypkg.Package) string

String : for pkg/tinypkg 's internal interface

func (*Code) String

func (c *Code) String() string

String : for pkg/tinypkg.Node

type CodeEmitter

type CodeEmitter struct {
	*Code
}

func (*CodeEmitter) Emit

func (c *CodeEmitter) Emit(w io.Writer) error

Emit : for pkg/emitfile.Emitter

func (*CodeEmitter) EmitImports

func (c *CodeEmitter) EmitImports(w io.Writer, imports []*tinypkg.ImportedPackage) error

EmitImports is currently used by Config.EmitCodeFunc

func (*CodeEmitter) FormatBytes

func (c *CodeEmitter) FormatBytes(b []byte) ([]byte, error)

Priority : for pkg/emitfile 's internal interface

func (*CodeEmitter) Priority

func (c *CodeEmitter) Priority(priority *int) int

Priority : for pkg/emitfile 's internal interface

type Config

type Config struct {
	*resolve.Config

	Header        string
	DisableFormat bool

	EmitCodeFunc EmitCodeFunc
	Resolver     *resolve.Resolver
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) NewCode

func (c *Config) NewCode(
	here *tinypkg.Package,
	name string,
	emitCode func(io.Writer, *Code) error,
) *Code

func (*Config) ZeroCode

func (c *Config) ZeroCode(
	here *tinypkg.Package,
	name string,
) *Code

type EmitCodeFunc

type EmitCodeFunc func(w io.Writer, e *CodeEmitter) error

Jump to

Keyboard shortcuts

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