eg

package
v0.0.0-...-2f1d035 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2016 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package eg implements the example-based refactoring tool whose command-line is defined in golang.org/x/tools/cmd/eg.

Index

Constants

View Source
const Help = `` /* 4316-byte string literal not displayed */

Variables

This section is empty.

Functions

func WriteAST

func WriteAST(fset *token.FileSet, filename string, f *ast.File) (err error)

WriteAST is a convenience function that writes AST f to the specified file.

Types

type Transformer

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

A Transformer represents a single example-based transformation.

func NewTransformer

func NewTransformer(fset *token.FileSet, tmplPkg *types.Package, tmplFile *ast.File, tmplInfo *types.Info, verbose bool) (*Transformer, error)

NewTransformer returns a transformer based on the specified template, a single-file package containing "before" and "after" functions as described in the package documentation. tmplInfo is the type information for tmplFile.

func (*Transformer) Transform

func (tr *Transformer) Transform(info *types.Info, pkg *types.Package, file *ast.File) int

Transform applies the transformation to the specified parsed file, whose type information is supplied in info, and returns the number of replacements that were made.

It mutates the AST in place (the identity of the root node is unchanged), and may add nodes for which no type information is available in info.

Derived from rewriteFile in $GOROOT/src/cmd/gofmt/rewrite.go.

Jump to

Keyboard shortcuts

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