...

Package analysisutil

import "cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil"
Overview
Index

Overview ▾

Package analysisutil defines various helper functions used by two or more packages beneath go/analysis.

Variables

var MustExtractDoc = analysisinternal.MustExtractDoc

func Format

func Format(fset *token.FileSet, x ast.Expr) string

Format returns a string representation of the expression.

func HasSideEffects

func HasSideEffects(info *types.Info, e ast.Expr) bool

HasSideEffects reports whether evaluation of e has side effects.

func Imports

func Imports(pkg *types.Package, path string) bool

Imports returns true if path is imported by pkg.

func IsFunctionNamed

func IsFunctionNamed(f *types.Func, pkgPath string, names ...string) bool

IsFunctionNamed reports whether f is a top-level function defined in the given package and has one of the given names. It returns false if f is nil or a method.

func IsNamedType

func IsNamedType(t types.Type, pkgPath string, names ...string) bool

IsNamedType reports whether t is the named type with the given package path and one of the given names. This function avoids allocating the concatenation of "pkg.Name", which is important for the performance of syntax matching.

func LineStart

func LineStart(f *token.File, line int) token.Pos

LineStart returns the position of the start of the specified line within file f, or NoPos if there is no line of that number.

func ReadFile

func ReadFile(pass *analysis.Pass, filename string) ([]byte, *token.File, error)

ReadFile reads a file and adds it to the FileSet so that we can report errors against it using lineStart.