1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00

cmd/guru: remove vestiges of -pos flag

It's a positional parameter now.

Also, update -help message to address
https://go-review.googlesource.com/#/c/19474 comments

Change-Id: Ie5947aa3c37180961e780747ca02be54f7030c21
Reviewed-on: https://go-review.googlesource.com/19493
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Alan Donovan 2016-02-12 16:57:12 -05:00
parent 00b8b1eb95
commit 1d6b8698af
4 changed files with 17 additions and 17 deletions

View File

@ -247,8 +247,8 @@ func pkgContainsFile(bp *build.Package, filename string) byte {
// this is appropriate for queries that allow fairly arbitrary syntax,
// e.g. "describe".
//
func parseQueryPos(lprog *loader.Program, posFlag string, needExact bool) (*queryPos, error) {
filename, startOffset, endOffset, err := parsePosFlag(posFlag)
func parseQueryPos(lprog *loader.Program, pos string, needExact bool) (*queryPos, error) {
filename, startOffset, endOffset, err := parsePos(pos)
if err != nil {
return nil, err
}

View File

@ -52,9 +52,9 @@ var updateFlag = flag.Bool("update", false, "Update the golden files.")
type query struct {
id string // unique id
verb string // query mode, e.g. "callees"
posn token.Position // position of of query
posn token.Position // query position
filename string
queryPos string // value of -pos flag
queryPos string // query position in command-line syntax
}
func parseRegexp(text string) (*regexp.Regexp, error) {

View File

@ -29,7 +29,7 @@ import (
// flags
var (
scopeFlag = flag.String("scope", "", "comma-separated list of `packages` to which the analysis should be limited (default=all)")
scopeFlag = flag.String("scope", "", "comma-separated list of `packages` the analysis should be limited to (default=all)")
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)")
@ -55,7 +55,7 @@ The mode argument determines the query to perform:
freevars show free variables of selection
implements show 'implements' relation for selected type or method
peers show send/receive corresponding to selected channel op
pointsto show variables to which the selected pointer may point
pointsto show variables the selected pointer may point to
referrers show all refs to entity denoted by selected identifier
what show basic information about the selected syntax node
whicherrs show possible values of the selected error variable

View File

@ -29,25 +29,25 @@ func parseOctothorpDecimal(s string) int {
return -1
}
// parsePosFlag parses a string of the form "file:pos" or
// parsePos parses a string of the form "file:pos" or
// file:start,end" where pos, start, end match #%d and represent byte
// offsets, and returns its components.
//
// (Numbers without a '#' prefix are reserved for future use,
// e.g. to indicate line/column positions.)
//
func parsePosFlag(posFlag string) (filename string, startOffset, endOffset int, err error) {
if posFlag == "" {
err = fmt.Errorf("no source position specified (-pos flag)")
func parsePos(pos string) (filename string, startOffset, endOffset int, err error) {
if pos == "" {
err = fmt.Errorf("no source position specified")
return
}
colon := strings.LastIndex(posFlag, ":")
colon := strings.LastIndex(pos, ":")
if colon < 0 {
err = fmt.Errorf("invalid source position -pos=%q", posFlag)
err = fmt.Errorf("bad position syntax %q", pos)
return
}
filename, offset := posFlag[:colon], posFlag[colon+1:]
filename, offset := pos[:colon], pos[colon+1:]
startOffset = -1
endOffset = -1
if hyphen := strings.Index(offset, ","); hyphen < 0 {
@ -60,7 +60,7 @@ func parsePosFlag(posFlag string) (filename string, startOffset, endOffset int,
endOffset = parseOctothorpDecimal(offset[hyphen+1:])
}
if startOffset < 0 || endOffset < 0 {
err = fmt.Errorf("invalid -pos offset %q", offset)
err = fmt.Errorf("invalid offset %q in query position", offset)
return
}
return
@ -119,10 +119,10 @@ func sameFile(x, y string) bool {
return false
}
// fastQueryPos parses the -pos flag and returns a QueryPos.
// fastQueryPos parses the position string and returns a QueryPos.
// It parses only a single file, and does not run the type checker.
func fastQueryPos(posFlag string) (*queryPos, error) {
filename, startOffset, endOffset, err := parsePosFlag(posFlag)
func fastQueryPos(pos string) (*queryPos, error) {
filename, startOffset, endOffset, err := parsePos(pos)
if err != nil {
return nil, err
}