mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
cmd/guru: report start and end positions for non-PkgName Objects
Most objects are declared by an identifier, so the end position is start+len(name). However, this heuristic doesn't work for PkgName objects because a (non-renaming) import creates an object without an identifier. Fixes issue github.com/Microsoft/vscode-go#562 Change-Id: I0eb44ca33a643c910d97abbf700ea4c3cd23bb41 Reviewed-on: https://go-review.googlesource.com/32440 Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
b814a3b030
commit
1529f889eb
@ -310,6 +310,14 @@ func fprintf(w io.Writer, fset *token.FileSet, pos interface{}, format string, a
|
||||
case token.Pos:
|
||||
start = pos
|
||||
end = start
|
||||
case *types.PkgName:
|
||||
// The Pos of most PkgName objects does not coincide with an identifier,
|
||||
// so we suppress the usual start+len(name) heuristic for types.Objects.
|
||||
start = pos.Pos()
|
||||
end = start
|
||||
case types.Object:
|
||||
start = pos.Pos()
|
||||
end = start + token.Pos(len(pos.Name())) // heuristic
|
||||
case interface {
|
||||
Pos() token.Pos
|
||||
}:
|
||||
|
Loading…
Reference in New Issue
Block a user