internal

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2018 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AssertImportIdent = &ast.Ident{Name: "assert"}
	Testdata          = "testdata"
	TermWidth         = 0
	WorkingDir        = ""
	Verbose           = false
)

Functions

func ContainsDirectory

func ContainsDirectory(files []os.FileInfo) bool

func ContainsGoFile

func ContainsGoFile(files []os.FileInfo) bool

func CopyFile

func CopyFile(path string, out io.Writer) error

func CreateBoolIdent

func CreateBoolIdent(v bool) *ast.Ident

func CreateMemorizedFuncCall

func CreateMemorizedFuncCall(filename string, line int, pos token.Pos, n *ast.CallExpr, returnType string) *ast.CallExpr

CreateMemorizedFuncCall creates memorized *ast.CallExpr. f(a, b) -> translatedassert.FRVInterface(translatedassert.MFCall(filename, line, pos, f, translatedassert.RVOf(a), translatedassert.RVOf(b)))

func CreatePosValuePairExpr

func CreatePosValuePairExpr(ps []printExpr) []ast.Expr

func CreateRawStringLit

func CreateRawStringLit(s string) ast.Expr

CreateRawStringLit creates raw string literal(ast.Expr) from string. VALUE:"foo" ---> AST:`foo` VALUE:"foo`bar" ---> AST:`foo` + "`" + `bar` (because we can't escape ` in “)

func CreateReflectBoolExpr

func CreateReflectBoolExpr(rv ast.Expr) *ast.CallExpr

func CreateReflectInterfaceExpr

func CreateReflectInterfaceExpr(rv ast.Expr) *ast.CallExpr

func CreateReflectTypeExprFromTypeExpr

func CreateReflectTypeExprFromTypeExpr(t ast.Expr) ast.Expr

CreateReflectTypeExprFromTypeExpr create ast of reflect.Type from ast of type.

func CreateReflectTypeOfExpr

func CreateReflectTypeOfExpr(v ast.Expr) *ast.CallExpr

func CreateReflectValueOfExpr

func CreateReflectValueOfExpr(v ast.Expr) *ast.CallExpr

func CreateUntypedCallExprFromBuiltinCallExpr

func CreateUntypedCallExprFromBuiltinCallExpr(n *ast.CallExpr) *ast.CallExpr

func CreateUntypedExprFromBinaryExpr

func CreateUntypedExprFromBinaryExpr(n *ast.BinaryExpr) ast.Expr

CreateUntypedExprFromBinaryExpr creates untyped operator-func(translatedassert.Op*()) from BinaryExpr if given BinaryExpr is untyped, returns it.

func CreateUntypedExprFromUnaryExpr added in v1.1.0

func CreateUntypedExprFromUnaryExpr(n *ast.UnaryExpr) ast.Expr

CreateUntypedExprFromUnaryExpr creates untyped operator-func(translatedassert.UnaryOp*()) from UnaryExpr if given UnaryExpr is untyped, returns it.

func DeterminantExprOfIsTypeConversion

func DeterminantExprOfIsTypeConversion(e ast.Expr) ast.Expr

func DropGopwtEmpower

func DropGopwtEmpower(a *ast.File) (dropped bool)

DropGopwtEmpower drops `gopwt.Empower()` and drops `import "github.com/ToQoz/gopwt"`.

func ExtractPrintExprs

func ExtractPrintExprs(typesInfo *types.Info, filename string, line int, offset token.Pos, parent ast.Expr, n ast.Expr) []printExpr

func FprintCode

func FprintCode(out io.Writer, n ast.Node) error

func GetAssertImport

func GetAssertImport(a *ast.File) *ast.ImportSpec

GetAssertImport returns *ast.ImportSpec of "github.com/ToQoz/gopwt/assert" if it is not found, this returns nil

func GetTypeInfo

func GetTypeInfo(pkgDir, importPath, tempGoSrcDir string, fset *token.FileSet, files []*ast.File) (*types.Info, error)

func HandleGlobalOrLocalImportPath

func HandleGlobalOrLocalImportPath(globalOrLocalImportPath string) (importpath, _filepath string, err error)

func InspectAssert

func InspectAssert(root ast.Node, fn func(*ast.CallExpr))

func IsAssert

func IsAssert(x *ast.Ident, c *ast.CallExpr) bool

IsAssert returns ok if given CallExpr is github.com/ToQoz/gopwt/assert.OK or Require

func IsBuildableFileName

func IsBuildableFileName(name string) bool

func IsBuildableFileSet

func IsBuildableFileSet(s *token.FileSet) bool

func IsBuiltinFunc

func IsBuiltinFunc(n *ast.CallExpr) bool

func IsEqualExpr

func IsEqualExpr(expr ast.Expr) bool

func IsGoFileName

func IsGoFileName(name string) bool

func IsMapType

func IsMapType(n ast.Node) bool

func IsRawStringLit

func IsRawStringLit(n *ast.BasicLit) bool

func IsReflectDeepEqual

func IsReflectDeepEqual(expr ast.Expr) bool

func IsTestGoFileName

func IsTestGoFileName(name string) bool

func IsTypeConversion

func IsTypeConversion(info *types.Info, e *ast.CallExpr) bool

func Must

func Must(err error)

func ReplaceAllRawStringLitByStringLit

func ReplaceAllRawStringLitByStringLit(root ast.Node)

ReplaceAllRawStringLitByStringLit replaces all raw string literals in root by string literals.

func ReplaceBinaryExpr

func ReplaceBinaryExpr(parent ast.Node, oldExpr *ast.BinaryExpr, newExpr ast.Expr)

ReplaceBinaryExpr replace oldExpr by newExpr in parent

func ReplaceUnaryExpr added in v1.1.0

func ReplaceUnaryExpr(parent ast.Node, oldExpr *ast.UnaryExpr, newExpr ast.Expr)

ReplaceUnaryExpr replace oldExpr by newExpr in parent

func ResultPosOf

func ResultPosOf(n ast.Expr) token.Pos

ResultPosOf returns result position of given expr. "a" -> 0 "obj.Fn" -> 3 "1 + 2" -> 2 "(1)" -> 1

func Rewrite

func Rewrite(gopath string, importpath, _filepath string, recursive bool) error

func RewriteAssert

func RewriteAssert(typesInfo *types.Info, position token.Position, n *ast.CallExpr)

RewriteAssert rewrites assert to translatedassert

func RewriteFile

func RewriteFile(typesInfo *types.Info, fset, originalFset *token.FileSet, file, origFile *ast.File, out io.Writer) error

func SprintCode

func SprintCode(n ast.Node) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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