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

7 Commits

Author SHA1 Message Date
Ian Cottrell
e88138204b internal/span: change URI.Filename so it just returns the filename
We panic if the uri was not a valid file uri instead
They always are a valid file URI, and we would fail miserably to cope if they were
not anyway, and there are lots of places where we need to be able to get the filename
and don't want to cope with an error that cannot occur.
If we ever have not file uri's, you will have to check if it is a file before calling
.Filename, which seems reasonable anyway.

Change-Id: Ifb26a165bd43c2d310378314550b5749b09e2ebd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181017
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-10 21:39:43 +00:00
Ian Cottrell
9cb3dcf692 internal/span: update the offset if the end offset should be valid but is not
It used to be that when the start offset was valid, it was presumed the end was
as well.
This was not true in the case where the start offset was not supplied but could
be inferred (at the very start of the file).

Fixes golang/go#31797

Change-Id: Ie5a079796fa0f77cef5571a4e5b309c798e1e06b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174943
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-03 18:46:43 +00:00
Ian Cottrell
83df196e57 internal/span: add a filename only print for spans
This prints the base of the path rather than the whole path when printing a
span.
This is useful for places where you are printing for the user rather than for
machines.
The format is %f

Change-Id: I6d1a52e4583099ff298c1fb645272578a49472eb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174942
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-03 02:58:08 +00:00
Rebecca Stambler
a5870b4038 internal/lsp/protocol: add a compare function for span.URI
Add an additional check to handle URI comparisons. This fixes Hover on
Windows.

Change-Id: Ibfc816f1ec374144377a873c5b52867fafa3d7e8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172659
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-17 22:30:02 +00:00
Ian Cottrell
183b688ac4 internal/lsp: add compare functions for spans
Needed in order to sort lists of spans for stable tests, also used for span
equality tests.

Change-Id: Id2bedff4d7136494e2302c02bcb9bdc662ccfeb1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172660
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-17 22:21:04 +00:00
Ian Cottrell
2f43c6d1a2 internal/span: change to private fields
Change span to hide its fields and have validating accessors
This catches the cases where either the offset or the position is being used
when it was not set.
It also normalizes the forms as the API now controls them, and allows us to
simplify some of the logic.
The converters are now allowed to return an error, which lets us cleanly
propagate bad cases.
The lsp was then converted to the new format, and also had some error checking
of its own added on the top.
All this allowed me to find and fix a few issues, most notably a case where the
wrong column mapper was being used during the conversion of definition results.

Change-Id: Iebdf8901e8269b28aaef60caf76574baa25c46d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167858
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-15 18:05:47 +00:00
Ian Cottrell
b40df0fb21 internal/span: adding a source location package to unify the pos conversions
This implements a standard way of describing source locations along with
printing and parsing of those locations and conversion to and from the token.Pos
forms.

Change-Id: Ibb3df0a282bc2effb0fa8bd3a51bb0d281b2ffb1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/163778
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-08 14:21:31 +00:00