document

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyChanges

func ApplyChanges(original []byte, changes Changes) ([]byte, error)

func ByteOffsetForPos

func ByteOffsetForPos(lines source.Lines, pos Pos) (int, error)

Types

type Change

type Change interface {
	Text() string
	Range() *Range
}

type Changes

type Changes []Change

type DirHandle

type DirHandle struct {
	URI string
}

DirHandle represents a directory location

This may be received via LSP from the client (as URI) or constructed from a file path on OS FS.

func DirHandleFromPath

func DirHandleFromPath(dirPath string) DirHandle

DirHandleFromPath creates a DirHandle from a given path.

dirPath is expected to be a directory path (rather than document). It is however outside the scope of the function to verify this is actually the case or whether the directory exists.

func DirHandleFromURI

func DirHandleFromURI(dirUri string) DirHandle

DirHandleFromURI creates a DirHandle from a given URI.

dirUri is expected to be a directory URI (rather than document). It is however outside the scope of the function to verify this is actually the case or whether the directory exists.

func (DirHandle) Path

func (dh DirHandle) Path() string

type Document

type Document struct {
	Dir      DirHandle
	Filename string

	ModTime    time.Time
	LanguageID string
	Version    int

	// Text contains the document body stored as bytes.
	// It originally comes as string from the client via LSP
	// but bytes are accepted by HCL and io/fs APIs, hence preferred.
	Text []byte

	// Lines contains Text separated into lines to enable byte offset
	// computation for any position-based operations within HCL, such as
	// completion, hover, semantic token based highlighting, etc.
	// and to aid in calculating diff when formatting document.
	// LSP positions contain just line+column but hcl.Pos requires offset.
	Lines source.Lines
}

func (*Document) Copy

func (d *Document) Copy() *Document

func (*Document) FullPath

func (doc *Document) FullPath() string

type DocumentNotFound

type DocumentNotFound struct {
	URI string
}

func (*DocumentNotFound) Error

func (e *DocumentNotFound) Error() string

func (*DocumentNotFound) Is

func (e *DocumentNotFound) Is(err error) bool

type Handle

type Handle struct {
	Dir      DirHandle
	Filename string
}

Handle represents a document location

This may be received via LSP from the client (as URI) or constructed from a file path on OS FS.

func HandleFromPath

func HandleFromPath(docPath string) Handle

HandleFromPath creates a Handle from a given path.

docPath is expected to be a document path (rather than dir). It is however outside the scope of the function to verify this is actually the case or whether the file exists.

func HandleFromURI

func HandleFromURI(docUri string) Handle

HandleFromURI creates a Handle from a given URI.

docURI is expected to be a document URI (rather than dir). It is however outside the scope of the function to verify this is actually the case or whether the file exists.

func (Handle) FullPath

func (h Handle) FullPath() string

func (Handle) FullURI

func (h Handle) FullURI() string

type InvalidPosErr

type InvalidPosErr struct {
	Pos Pos
}

func (*InvalidPosErr) Error

func (e *InvalidPosErr) Error() string

type Pos

type Pos struct {
	Line, Column int
}

Pos represents LSP-style position (zero-indexed)

func (Pos) String

func (p Pos) String() string

type Range

type Range struct {
	Start, End Pos
}

Range represents LSP-style range between two positions Positions are zero-indexed

Jump to

Keyboard shortcuts

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