mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -07:00
cmd/guru: allow foo/... and -foo patterns in scope argument
Also, document -scope argument. Depends on CL 19746 (buildutil.ExpandPatterns) Change-Id: I3c9000e94d87cca5c2c49fe8de12a77fc43f7257 Reviewed-on: https://go-review.googlesource.com/19747 Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
a69e659f44
commit
3f95c66345
@ -22,6 +22,7 @@ import (
|
||||
|
||||
"golang.org/x/tools/cmd/guru/serial"
|
||||
"golang.org/x/tools/go/ast/astutil"
|
||||
"golang.org/x/tools/go/buildutil"
|
||||
"golang.org/x/tools/go/loader"
|
||||
"golang.org/x/tools/go/pointer"
|
||||
"golang.org/x/tools/go/ssa"
|
||||
@ -129,18 +130,13 @@ func Run(q *Query) error {
|
||||
}
|
||||
|
||||
func setPTAScope(lconf *loader.Config, scope []string) error {
|
||||
if len(scope) == 0 {
|
||||
pkgs := buildutil.ExpandPatterns(lconf.Build, scope)
|
||||
if len(pkgs) == 0 {
|
||||
return fmt.Errorf("no packages specified for pointer analysis scope")
|
||||
}
|
||||
|
||||
// Determine initial packages for PTA.
|
||||
args, err := lconf.FromArgs(scope, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(args) > 0 {
|
||||
return fmt.Errorf("surplus arguments: %q", args)
|
||||
}
|
||||
// The value of each entry in pkgs is true,
|
||||
// giving ImportWithTests (not Import) semantics.
|
||||
lconf.ImportPkgs = pkgs
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
// flags
|
||||
var (
|
||||
modifiedFlag = flag.Bool("modified", false, "read archive of modified files from standard input")
|
||||
scopeFlag = flag.String("scope", "", "comma-separated list of `packages` the analysis should be limited to (default=all)")
|
||||
scopeFlag = flag.String("scope", "", "comma-separated list of `packages` the analysis should be limited to")
|
||||
ptalogFlag = flag.String("ptalog", "", "write points-to analysis log to `file`")
|
||||
formatFlag = flag.String("format", "plain", "output `format`; one of {plain,json,xml}")
|
||||
reflectFlag = flag.Bool("reflect", false, "analyze reflection soundly (slow)")
|
||||
@ -78,13 +78,21 @@ The -format flag controls the output format:
|
||||
xml structured data in XML syntax.
|
||||
|
||||
The -modified flag causes guru to read an archive from standard input.
|
||||
|
||||
Files in this archive will be used in preference to those in
|
||||
the file system. In this way, a text editor may supply guru
|
||||
with the contents of its unsaved buffers. Each archive entry
|
||||
consists of the file name, a newline, the decimal file size,
|
||||
another newline, and the contents of the file.
|
||||
|
||||
The -scope flag restricts analysis to the specified packages.
|
||||
Its value is a comma-separated list of patterns of these forms:
|
||||
golang.org/x/tools/cmd/guru # a single package
|
||||
golang.org/x/tools/... # all packages beneath dir
|
||||
... # the entire workspace.
|
||||
A pattern preceded by '-' is negative, so the scope
|
||||
encoding/...,-encoding/xml
|
||||
matches all encoding packages except encoding/xml:
|
||||
|
||||
User manual: http://golang.org/s/oracle-user-manual
|
||||
|
||||
Example: describe syntax at offset 530 in this file (an import spec):
|
||||
|
Loading…
Reference in New Issue
Block a user