cmd/oracle: minor fixes.
- print "oracle:" not "Error:" in error messages; remove period.
- allocate token.FileSet correctly.
- remove stale TODO (multiple test packages)
- fix typo and omission ('what') in usage message.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/178860043
This commit is contained in:
parent
4162082cba
commit
d75c6bdb8f
|
|
@ -60,9 +60,10 @@ The mode argument determines the query to perform:
|
||||||
callstack show path from callgraph root to selected function
|
callstack show path from callgraph root to selected function
|
||||||
describe describe selected syntax: definition, methods, etc
|
describe describe selected syntax: definition, methods, etc
|
||||||
freevars show free variables of selection
|
freevars show free variables of selection
|
||||||
implements show 'implements' relation for selected package
|
implements show 'implements' relation for selected type
|
||||||
peers show send/receive corresponding to selected channel op
|
peers show send/receive corresponding to selected channel op
|
||||||
referrers show all refs to entity denoted by selected identifier
|
referrers show all refs to entity denoted by selected identifier
|
||||||
|
what show basic information about the selected syntax node
|
||||||
|
|
||||||
The user manual is available here: http://golang.org/s/oracle-user-manual
|
The user manual is available here: http://golang.org/s/oracle-user-manual
|
||||||
|
|
||||||
|
|
@ -111,7 +112,7 @@ func main() {
|
||||||
|
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
if len(args) == 0 || args[0] == "" {
|
if len(args) == 0 || args[0] == "" {
|
||||||
fmt.Fprint(os.Stderr, "Error: a mode argument is required.\n"+useHelp)
|
fmt.Fprint(os.Stderr, "oracle: a mode argument is required.\n"+useHelp)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,7 +124,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) == 0 && mode != "what" {
|
if len(args) == 0 && mode != "what" {
|
||||||
fmt.Fprint(os.Stderr, "Error: no package arguments.\n"+useHelp)
|
fmt.Fprint(os.Stderr, "oracle: no package arguments.\n"+useHelp)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,14 +158,14 @@ func main() {
|
||||||
case "json", "plain", "xml":
|
case "json", "plain", "xml":
|
||||||
// ok
|
// ok
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(os.Stderr, "Error: illegal -format value: %q.\n"+useHelp, *formatFlag)
|
fmt.Fprintf(os.Stderr, "oracle: illegal -format value: %q.\n"+useHelp, *formatFlag)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask the oracle.
|
// Ask the oracle.
|
||||||
res, err := oracle.Query(args, mode, *posFlag, ptalog, &build.Default, *reflectFlag)
|
res, err := oracle.Query(args, mode, *posFlag, ptalog, &build.Default, *reflectFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %s.\n", err)
|
fmt.Fprintf(os.Stderr, "oracle: %s.\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +174,7 @@ func main() {
|
||||||
case "json":
|
case "json":
|
||||||
b, err := json.MarshalIndent(res.Serial(), "", "\t")
|
b, err := json.MarshalIndent(res.Serial(), "", "\t")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "JSON error: %s.\n", err)
|
fmt.Fprintf(os.Stderr, "oracle: JSON error: %s.\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
os.Stdout.Write(b)
|
os.Stdout.Write(b)
|
||||||
|
|
@ -181,7 +182,7 @@ func main() {
|
||||||
case "xml":
|
case "xml":
|
||||||
b, err := xml.MarshalIndent(res.Serial(), "", "\t")
|
b, err := xml.MarshalIndent(res.Serial(), "", "\t")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "XML error: %s.\n", err)
|
fmt.Fprintf(os.Stderr, "oracle: XML error: %s.\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
os.Stdout.Write(b)
|
os.Stdout.Write(b)
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@ tools, which should act as if they were saved.
|
||||||
|
|
||||||
Fix: make the guessImportPath hack work with external _test.go files too.
|
Fix: make the guessImportPath hack work with external _test.go files too.
|
||||||
|
|
||||||
Allow the analysis scope to include multiple test packages at once.
|
|
||||||
|
|
||||||
Include complete pos/end information Serial output.
|
Include complete pos/end information Serial output.
|
||||||
But beware that sometimes a single token (e.g. +) is more helpful
|
But beware that sometimes a single token (e.g. +) is more helpful
|
||||||
than the pos/end of the containing expression (e.g. x \n + \n y).
|
than the pos/end of the containing expression (e.g. x \n + \n y).
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ func parseQueries(t *testing.T, filename string) []*query {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the file once to discover the test queries.
|
// Parse the file once to discover the test queries.
|
||||||
var fset token.FileSet
|
fset := token.NewFileSet()
|
||||||
f, err := parser.ParseFile(&fset, filename, filedata, parser.ParseComments)
|
f, err := parser.ParseFile(fset, filename, filedata, parser.ParseComments)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue