Skip to content

Commit 1627e95

Browse files
committed
gopls/internal/lsp: more comment tweaks post-//line support
Change-Id: Ia44de7449fd0d60112dd71e372813bd8b3846175 Reviewed-on: https://go-review.googlesource.com/c/tools/+/458556 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> Run-TryBot: Alan Donovan <[email protected]>
1 parent 21f6100 commit 1627e95

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

gopls/internal/lsp/protocol/span.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
// TODO(adonovan): simplify this picture. Eliminate the optionality of
3030
// span.{Span,Point}'s position and offset fields: work internally in
3131
// terms of offsets (like span.Range), and require a mapper to convert
32-
// them to protocol (UTF-16) line/col form. Stop honoring //line
33-
// directives.
32+
// them to protocol (UTF-16) line/col form.
3433

3534
package protocol
3635

@@ -162,7 +161,6 @@ func (m *ColumnMapper) Position(p span.Point) (Position, error) {
162161
// offset within m.Content.
163162
func (m *ColumnMapper) OffsetPosition(offset int) (Position, error) {
164163
// We use span.ToPosition for its "line+1 at EOF" workaround.
165-
// TODO(adonovan): ToPosition honors //line directives. It probably shouldn't.
166164
line, _, err := span.ToPosition(m.TokFile, offset)
167165
if err != nil {
168166
return Position{}, fmt.Errorf("OffsetPosition: %v", err)

gopls/internal/lsp/source/util.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@ import (
2626
// MappedRange provides mapped protocol.Range for a span.Range, accounting for
2727
// UTF-16 code points.
2828
//
29-
// TOOD(adonovan): eliminate this type. All callers need either m, or a protocol.Range.
29+
// TOOD(adonovan): eliminate this type. Replace all uses by an
30+
// explicit pair (span.Range, protocol.ColumnMapper), and an operation
31+
// to map both to a protocol.Range.
3032
type MappedRange struct {
3133
spanRange span.Range // the range in the compiled source (package.CompiledGoFiles)
3234
m *protocol.ColumnMapper // a mapper of the edited source (package.GoFiles)
3335
}
3436

35-
// NewMappedRange returns a MappedRange for the given file and valid start/end token.Pos.
36-
//
37-
// By convention, start and end are assumed to be positions in the compiled (==
38-
// type checked) source, whereas the column mapper m maps positions in the
39-
// user-edited source. Note that these may not be the same, as when using goyacc or CGo:
40-
// CompiledGoFiles contains generated files, whose positions (via
41-
// token.File.Position) point to locations in the edited file -- the file
42-
// containing `import "C"`.
37+
// NewMappedRange returns a MappedRange for the given file and
38+
// start/end positions, which must be valid within m.TokFile.
4339
func NewMappedRange(m *protocol.ColumnMapper, start, end token.Pos) MappedRange {
4440
return MappedRange{
4541
spanRange: span.NewRange(m.TokFile, start, end),

0 commit comments

Comments
 (0)