protocol

package
v0.1.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 6 Imported by: 0

README

protocol package

This directory contains selected content from the gopls/internal/lsp/protocol package, which we can use to supplement the go.lsp.dev/protocol package. We do not import the whole package as it is internal to gopls and contains significant gopls-specific logic.

However, as it contains various utility functions and mappers that are more generic, the code can be borrowed and added here as needed, in some cases with minor revision to remove dependency on other gopls internal packages.

Issue proposing changes needed to make the gopls version external: https://github.com/golang/go/issues/61338

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UTF16Len

func UTF16Len(s []byte) int

UTF16Len returns the number of codes in the UTF-16 transcoding of s.

Types

type TextOffsetMapper

type TextOffsetMapper struct {
	Content []byte
	// contains filtered or unexported fields
}

TextOffsetMapper is used for conversions related to text offsets.

func NewTextOffsetMapper

func NewTextOffsetMapper(content []byte) *TextOffsetMapper

NewTextOffsetMapper creates a new mapper for the given URI and content.

func (*TextOffsetMapper) OffsetPosition

func (m *TextOffsetMapper) OffsetPosition(offset int) (protocol.Position, error)

OffsetPosition converts a byte offset to a protocol (UTF-16) position.

func (*TextOffsetMapper) PositionOffset

func (m *TextOffsetMapper) PositionOffset(p protocol.Position) (int, error)

PositionOffset converts a protocol (UTF-16) position to a byte offset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL