1
0
mirror of https://github.com/golang/go synced 2024-09-30 14:18:32 -06:00
go/cmd
Alan Donovan 2336c53cf0 cmd/guru: compute referrers as packages are type checked
This CL makes little observable difference to the behavior but paves the
way for streaming 'referrers' and (later) 'implements' queries which
scan the entire workspace, but print each result as soon as it is found.

The go/loader package now exposes a hook, AfterTypeCheck, that lets
clients inspect each package as soon as it is type-checked, and also
modify it, for instance to release unneeded data structures.

A 'referrers' query applied to an exported object must scan the entire
workspace.  It uses this hook so to gather uses of the query object in
streaming fashion.  However, for now, it still accumulates the results
and prints them all at the end, though I propose to change that in a
follow-up.

Code details:
- The referrers logic had a 2-iteration loop to load first the query
  package and then if necessary the enlarged program.  The second
  iteration has now been unrolled and split into globalReferrers.
- Queries for package names (whether in a package declaration or
  a qualified identifier) have been split off into packageReferrers.
  It now loads all direct importers of the query package,
  which catches some references that were missing before.
  (It used to inspect only the forward dependencies of the query
  package.)

Also:
- Referrers.Pos (the position of query identifier) was removed from the
  JSON output.  It's a nuisance to compute now, and it's already
  absent from the plain output.
  (In a follow-up, I plan to simplify the information content of the
  JSON output exactly what is currently printed in the plain output.)

Change-Id: Ia5677636dc7b0fe4461a5d393107665757fb9a97
Reviewed-on: https://go-review.googlesource.com/19794
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
2016-03-04 21:13:08 +00:00
..
benchcmp benchmark/parser, cmd/benchcmp: improve names of exported identifiers 2015-01-15 01:28:17 +00:00
bundle cmd/bundle: fix broken test 2016-02-22 20:47:44 +00:00
callgraph x/tools/cmd/callgraph: add -ptalog flag 2015-12-04 17:49:28 +00:00
cover x/tools: disable tests not supported on Android 2015-08-06 00:36:03 +00:00
digraph tools: add import comments. 2014-12-09 22:42:16 +00:00
eg refactor/eg: refactor to break dependency on go/loader 2015-09-01 14:26:06 +00:00
fiximports cmd/fiximports: -replace flag specifies canonical packages in absence of import comments 2015-09-01 14:23:39 +00:00
godex x/tools/cmd/godex: prepare sources for switch to 1.5 go/types 2015-10-09 20:47:08 +00:00
godoc cmd/godoc: accept GOOS and GOARCH URL parameters in -http mode 2016-02-04 22:11:53 +00:00
goimports imports: add support for vendor directories 2016-02-18 16:47:46 +00:00
gomvpkg go/buildutil: TagsFlag provides a flag.Value for setting build.Context.BuildTags from -tags flag. 2015-04-23 14:10:21 +00:00
gorename cmd/gorename: -d flag prints diffs instead of rewriting files 2015-12-30 15:25:00 +00:00
gotype cmd/gotype: keep gotype working with Go1.4 2015-08-25 03:53:50 +00:00
guru cmd/guru: compute referrers as packages are type checked 2016-03-04 21:13:08 +00:00
html2article all: address vet reports 2014-12-29 06:08:34 +00:00
oracle cmd/oracle: add pointsto, whicherrs to help message 2016-02-11 22:30:21 +00:00
present x/tools/present: add video element for slides 2016-01-13 03:34:37 +00:00
ssadump tools: switch to standard go/types at tip 2016-01-06 22:15:26 +00:00
stress all: fix plan9 failures 2016-01-28 00:31:03 +00:00
stringer cmd/stringer: fork and tag for go1.4 2016-01-11 14:24:22 +00:00
tip cmd/tip: update deploy instructions 2016-01-27 02:50:12 +00:00
vet cmd/vet: roll back update of go/types import 2016-01-07 20:27:05 +00:00