1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:48:32 -06:00
Commit Graph

9 Commits

Author SHA1 Message Date
Gordon Tyler
2dc4ef2775 cmd/guru: fix guessImportPath for Windows
Import paths in Go use forward slashes, not the operating system's path separator.

Fixes golang/go#24699.
Fixes golang/go#23318.

Change-Id: I190224f6b7236e8ee19893f3589dd9686cbf116a
GitHub-Last-Rev: 751b29ca5f2e52ee1124c4baca6e45eecf4a3052
GitHub-Pull-Request: golang/tools#56
Reviewed-on: https://go-review.googlesource.com/c/151057
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-25 23:45:24 +00:00
Alan Donovan
3537037b0b cmd/guru: report 'whicherrs' in modes of 'what' query
A 'what' query reports which other query modes are applicable to the
selected syntax.  A 'whicherrs' query is similar to a 'pointsto'
query, so we enable it using the same criteria.

Fixes issue golang/go#18938

Change-Id: Iae062e0c933c7764bc335488adabf816d63ac837
Reviewed-on: https://go-review.googlesource.com/37349
Reviewed-by: Dominik Honnef <dominik@honnef.co>
2017-03-04 02:31:33 +00:00
Rebecca Stambler
366e27042d cmd/guru: handle source file aliasing gracefully
Resolve symlinks in GOPATH or source file path in order to find correct package.

Fixes golang/go#17515

Change-Id: Iaf7e85578fce040b329427ce6f51948a69e57a39
Reviewed-on: https://go-review.googlesource.com/33858
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-12-02 22:01:05 +00:00
Alan Donovan
ef6b6ebf3b cmd/guru: what: include imported package names in sameids
+ Test.

Change-Id: Ib7ef99786f5b60bb3e56ced9588d2ba5725576e1
Reviewed-on: https://go-review.googlesource.com/24949
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-15 18:55:24 +00:00
Alan Donovan
2da0720e4f cmd/guru: support streaming plain and -json output
Visible changes:
- "referrers" queries now emit a stream of results,
  so they start appearing quickly even in large queries.
  We no longer report the total number of matches.
- packageReferrers now also uses AfterTypeCheck hook and streaming.
- XML support has been dropped.
- The -format flag has been replaced by -json.

JSON protocol changes:
- The enclosing Result struct has been removed.
- Likewise the 'mode' field (since the caller knows it already)
- "freevars" and "referrers" now emit a stream of objects
  In the case of referrers, the first object has a different from the rest.
- The "referrers" results include the text of the matching line
  (parity with -json=false)

Implementation details:
- the concurrency-safe q.Output function can be called
  many times, each with a queryResult to print.
- fset is no longer saved in Query (cleaner)
- queryResult methods renamed PrintPlain, JSON

Change-Id: I41a4e3f57f266fcf043ece4045bca82c6f6a356f
Reviewed-on: https://go-review.googlesource.com/21397
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-04-11 19:51:55 +00:00
Alan Donovan
6c84e9e3e0 cmd/guru: make fastQueryPos indirect through the -modified map
This fixes a bug in which guru reports a "query position beyond end of
file" error when making a query from an unsaved editor buffer at an
offset greater than the length of the file on disk.

Change-Id: I908c024d8dd14baa657b4227e3231fa760443732
Reviewed-on: https://go-review.googlesource.com/20167
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
2016-03-03 19:00:43 +00:00
Alan Donovan
ee8cb08bfe cmd/guru: what: report identifiers equivalent to the selected one
This information is useful for editor UIs that highlight all
uses of the local variable under the cursor.

Change-Id: I718d648d407468509e6d12f932ae6cdef368830a
Reviewed-on: https://go-review.googlesource.com/19512
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-20 21:18:35 +00:00
Alan Donovan
fb3df4a89d cmd/guru: definition: try parser-based resolution first
The parser does intra-file resolution.  It's only a best-effort but
it's extremely fast, so we try it first and fall back to the loader-based
implementation if it fails.

Also:
- factor definitionResult so it doesn't depend on either go/types.Object
  or go/ast.Object.
- guessImportPath: make importPath=="" result an error,
  since you can't import the empty string.  Simplify importQueryPackage.
- Make fastQueryPos continue in face of minor parse errors.
- describe: eliminate old TODO; suppress log statement.

Change-Id: I30a32487e9fd9d5308b1580ec12220cad2c16299
Reviewed-on: https://go-review.googlesource.com/19507
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
2016-02-16 00:29:23 +00:00
Alan Donovan
7347379304 cmd/guru: rename oracle to guru, copying it to a single package
See plans at:
https://docs.google.com/document/d/1UErU12vR7jTedYvKHVNRzGPmXqdMASZ6PfE7B-p6sIg/edit#heading=h.t5rbcuy7di7j

Change-Id: I369747e0ce8cd42a2975eb0f651a2e5fba47cf9e
Reviewed-on: https://go-review.googlesource.com/19475
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-12 03:38:58 +00:00