docsync

package
v0.0.0-...-366fccf Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	StartupInfo(ctx context.Context) (ulspplugin.PluginInfo, error)

	// Returns the current version of the text document as of the last received DidChange event.
	GetTextDocument(ctx context.Context, doc protocol.TextDocumentIdentifier) (protocol.TextDocumentItem, error)

	// Returns the current status of a given document within a session.
	GetDocumentState(ctx context.Context, doc protocol.TextDocumentIdentifier) (DocumentState, error)

	// Adds edits to the pending edits for the current version of the text document.
	// Returns true if the edits were added, false if edits were ignored (e.g. due to outdated document version).
	AddPendingEdits(ctx context.Context, doc protocol.TextDocumentItem, edits []protocol.TextEdit) (bool, error)

	// Returns a position mapper that can be used to LSP positions between base and current versions of the document..
	GetPositionMapper(ctx context.Context, doc protocol.TextDocumentIdentifier) (PositionMapper, error)

	// ResetBase resets the base for a given document.
	ResetBase(ctx context.Context, workspaceRoot string, doc protocol.TextDocumentIdentifier) error
}

Controller defines the interface for a document sync controller.

func New

func New(p Params) Controller

New creates a new controller for document sync.

type DocumentState

type DocumentState int

DocumentState keeps track of the current state of a document.

const (
	// DocumentStateOpenClean indicates that the document is open and has no modifications in the editor.
	DocumentStateOpenClean DocumentState = iota
	// DocumentStateOpenDirty indicates that the document is open and has unsaved modifications in the editor.
	DocumentStateOpenDirty
	// DocumentStateClosed indicates that the document is closed.
	DocumentStateClosed
)

type Params

type Params struct {
	fx.In

	Sessions   session.Repository
	IdeGateway ideclient.Gateway
	Logger     *zap.SugaredLogger
	Stats      tally.Scope
	Config     config.Provider
	FS         fs.UlspFS
}

Params are inbound parameters to initialize a new plugin.

type PositionMapper

type PositionMapper interface {
	// MapCurrentPositionToBase maps a position in the current document to the equivalent position in the base version
	MapCurrentPositionToBase(currentPosition protocol.Position) (basePosition protocol.Position, isNew bool, err error)

	// MapBasePositionToCurrent maps a position in the base document to the equivalent position in the current version
	MapBasePositionToCurrent(basePosition protocol.Position) (currentPosition protocol.Position, err error)
}

PositionMapper is used to map corresponding LSP protocol positions between two versions of the same document.

func NewPositionMapper

func NewPositionMapper(baseText, updatedText string) PositionMapper

NewPositionMapper creates a new position mapper using precomputed diffs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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