gotreload

package
v0.0.0-...-8de3b47 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileFromName

func FileFromName(pkg *packages.Package, name string) *ast.File

func FileFromPos

func FileFromPos(pkg *packages.Package, p Poser) *ast.File

func FormatNode

func FormatNode(fset *token.FileSet, node ast.Node) (string, []byte, error)

Types

type Info

type Info struct {
	Registrations []byte
}

type Poser

type Poser interface {
	Pos() token.Pos
}

type RewriteMode

type RewriteMode int
const (
	ModeInvalid RewriteMode = iota
	ModeRewrite
	ModeReload
)

type Rewriter

type Rewriter struct {
	OutputDir string
	Pwd       string
	Config    packages.Config
	Pkgs      []*packages.Package
	// Keys are PkgPath & stubVar name.  We use PkgPath as the key instead
	// of a *packages.Package because we need to be able to find this across
	// different instances of Rewriter, where pointer values will be
	// different, but package import paths, which are just strings, will be
	// the same.
	NewFunc map[string]map[string]*ast.FuncLit

	// Per-package supplemental information.  Used only in initial rewrite.
	Info map[*packages.Package]*Info
	// contains filtered or unexported fields
}

func NewRewriter

func NewRewriter() *Rewriter

func (*Rewriter) FuncDef

func (r *Rewriter) FuncDef(pkgPath, stubVar string) (string, error)

func (*Rewriter) FuncNode

func (r *Rewriter) FuncNode(pkgPath, stubVar string) (*packages.Package, *ast.FuncLit)

func (*Rewriter) Load

func (r *Rewriter) Load(paths ...string) error

func (*Rewriter) LookupFile

func (r *Rewriter) LookupFile(targetFileName string) *ast.File

func (*Rewriter) Print

func (r *Rewriter) Print(root string) error

Print prints the rewritten files to a tree rooted in the given path.

Not currently used ... but does look handy?

func (*Rewriter) Rewrite

func (r *Rewriter) Rewrite(mode RewriteMode, genContent bool) error

Rewrite rewrites the ASTs in r.Pkgs in place. mode==ModeReload is used to add package prefixes to all mentioned variables, and make other changes.

Jump to

Keyboard shortcuts

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