Documentation ¶
Overview ¶
Package lsppos provides utilities for working with LSP positions. Much of this functionality is duplicated from the internal/span package, but this package is simpler and more accurate with respect to newline terminated content.
See https://microsoft.github.io/language-server-protocol/specification#textDocuments for a description of LSP positions. Notably:
- Positions are specified by a 0-based line count and 0-based utf-16 character offset.
- Positions are line-ending agnostic: there is no way to specify \r|\n or \n|. Instead the former maps to the end of the current line, and the latter to the start of the next line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper maps utf-8 byte offsets to LSP positions for a single file.
func (*Mapper) LineColUTF16 ¶ added in v0.1.11
LineColUTF16 returns the 0-based UTF-16 line and character index for the given offset. It returns -1, -1 if offset is out of bounds for the file being mapped.
type TokenMapper ¶ added in v0.1.11
type TokenMapper struct {
// contains filtered or unexported fields
}
TokenMapper maps token.Pos to LSP positions for a single file.
func NewTokenMapper ¶ added in v0.1.11
func NewTokenMapper(content []byte, file *token.File) *TokenMapper
NewMapper creates a new TokenMapper for the given content, using the provided file to compute offsets.