Documentation ¶
Overview ¶
Package oracle contains the implementation of the oracle tool whose command-line is provided by code.google.com/p/go.tools/cmd/oracle.
http://golang.org/s/oracle-design http://golang.org/s/oracle-user-manual
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
An Oracle holds the program state required for one or more queries.
type QueryPos ¶
type QueryPos struct {
// contains filtered or unexported fields
}
A QueryPos represents the position provided as input to a query: a textual extent in the program's source code, the AST node it corresponds to, and the package to which it belongs. Instances are created by ParseQueryPos.
func ParseQueryPos ¶
ParseQueryPos parses the source query position pos. If needExact, it must identify a single AST subtree; this is appropriate for queries that allow fairly arbitrary syntax, e.g. "describe".
func (*QueryPos) ObjectString ¶
ObjectString prints object obj relative to the query position.
func (*QueryPos) SelectionString ¶
SelectionString prints selection sel relative to the query position.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
A Result encapsulates the result of an oracle.Query.
func Query ¶
func Query(args []string, mode, pos string, ptalog io.Writer, buildContext *build.Context, reflection bool) (*Result, error)
Query runs a single oracle query.
args specify the main package in (*loader.Config).FromArgs syntax. mode is the query mode ("callers", etc). ptalog is the (optional) pointer-analysis log file. buildContext is the go/build configuration for locating packages. reflection determines whether to model reflection soundly (currently slow).
Clients that intend to perform multiple queries against the same analysis scope should use this pattern instead:
conf := loader.Config{Build: buildContext, SourceImports: true} ... populate config, e.g. conf.FromArgs(args) ... iprog, err := conf.Load() if err != nil { ... } o, err := oracle.New(iprog, nil, false) if err != nil { ... } for ... { qpos, err := oracle.ParseQueryPos(imp, pos, needExact) if err != nil { ... } res, err := o.Query(mode, qpos) if err != nil { ... } // use res }
TODO(adonovan): the ideal 'needsExact' parameter for ParseQueryPos depends on the query mode; how should we expose this?