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>
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>
The -modified flag causes guru to read a simple archive file from stdin.
This archive specifies alternative contents for one or more file names.
The build.Context checks this table before delegating to the usual
behavior.
This will not work for files that import "C" since cgo accesses the
file system directly.
Added end-to-end test via Emacs.
Simplify findQueryPos (now: fileOffsetToPos)
Credit: Daniel Morsing, for the prototype of this feature.
Change-Id: I5ae818ed5e8bb81001781893dded2d085e9cf8d6
Reviewed-on: https://go-review.googlesource.com/19498
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>