Documentation ¶
Index ¶
- Constants
- func FindPackageMember(ctxt *build.Context, fset *token.FileSet, srcdir, pkg, member string) (token.Token, token.Pos, error)
- func GuessImportPath(filename string, buildContext *build.Context) (srcdir, importPath string, err error)
- func PackageForQualIdent(path []ast.Node, id *ast.Ident) string
- func Run(mode string, q *Query) error
- type Query
- type QueryResult
Constants ¶
const HasAlias = true
Variables ¶
This section is empty.
Functions ¶
func FindPackageMember ¶
func FindPackageMember(ctxt *build.Context, fset *token.FileSet, srcdir, pkg, member string) (token.Token, token.Pos, error)
FindPackageMember returns the type and position of the declaration of pkg.member by loading and parsing the files of that package. srcdir is the directory in which the import appears.
func GuessImportPath ¶
func GuessImportPath(filename string, buildContext *build.Context) (srcdir, importPath string, err error)
GuessImportPath finds the package containing filename, and returns its source directory (an element of $GOPATH) and its import path relative to it.
TODO(adonovan): what about _test.go files that are not part of the package?
func PackageForQualIdent ¶
PackageForQualIdent returns the package p if id is X in a qualified identifier p.X; it returns "" otherwise.
Precondition: id is path[0], and the parser did not resolve id to a local object. For speed, PackageForQualIdent assumes that p is a package iff it is the basename of an import path (and not, say, a package-level decl in another file or a predeclared identifier).
Types ¶
type Query ¶
type Query struct { Pos string // query position Build *build.Context // package loading configuration // pointer analysis options Scope []string // main packages in (*loader.Config).FromArgs syntax PTALog io.Writer // (optional) pointer-analysis log file Reflection bool // model reflection soundly (currently slow). // result-printing function, safe for concurrent use Output func(*token.FileSet, QueryResult) }
A Query specifies a single guru query.
type QueryResult ¶
type QueryResult interface { // JSON returns the QueryResult in JSON form. JSON(fset *token.FileSet) []byte // PrintPlain prints the QueryResult in plain text form. // The implementation calls printfFunc to print each line of output. PrintPlain(printf printfFunc) Result(fset *token.FileSet) interface{} }
A QueryResult is an item of output. Each query produces a stream of query results, calling Query.Output for each one.