rewriter

package
v0.0.0-...-ee86543 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package rewriter contains Go source rewriting utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrorCallback

func NewErrorCallback(fset *token.FileSet) func(pos token.Pos, err error)

NewErrorCallback creates new error printing callback.

Types

type Printer

type Printer interface {
	PrintFile(w io.Writer, fset *token.FileSet, file *ast.File) error
}

Printer is an abstraction for Go source printer.

func DefaultPrinter

func DefaultPrinter() Printer

DefaultPrinter returns default Printer implementation

type ReWriter

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

ReWriter is a Go source rewriter.

func NewReWriter

func NewReWriter(source, output string, macros macro.Macros, printer Printer) ReWriter

NewReWriter creates new ReWriter.

func (ReWriter) Output

func (r ReWriter) Output() string

Output returns output path.

func (ReWriter) Rewrite

func (r ReWriter) Rewrite() error

Rewrite rewrites given source and output using macro list.

func (ReWriter) RewriteReader

func (r ReWriter) RewriteReader(name string, src io.Reader, w io.Writer) error

RewriteReader loads sources from given reader and writes output to given writer.

func (ReWriter) RewriteTo

func (r ReWriter) RewriteTo(w io.Writer) error

RewriteTo rewrites one package using macros to given writer.

func (ReWriter) Source

func (r ReWriter) Source() string

Source returns source path.

type Runner

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

Runner is a simple macro runner helper.

func NewRunner

func NewRunner(fset *token.FileSet) *Runner

NewRunner creates Runner.

func (Runner) Report

func (r Runner) Report(pos token.Pos, args ...interface{})

func (Runner) Reportf

func (r Runner) Reportf(pos token.Pos, f string, args ...interface{})

func (*Runner) Run

func (r *Runner) Run(handler macro.Handler, context macro.Context, node ast.Node) ast.Node

Run applies given macro.Handler using macro.Context to ast.Node.

Jump to

Keyboard shortcuts

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