filesystem

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package filesystem implements a virtual filesystem which reflects the needs of both the language server and the HCL parser.

- creates in-memory files based on data received from the language client - allows updating in-memory files via diffs received from the language client - maintains file metadata (e.g. version, or whether it's open by the client)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteOffsetForPos

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

func NewDocumentMetadata

func NewDocumentMetadata(dh DocumentHandler, langId string, content []byte) *documentMetadata

func NewFilesystem

func NewFilesystem() *fsystem

Types

type Document

type Document interface {
	DocumentHandler
	Text() ([]byte, error)
	Lines() source.Lines
	LanguageID() string
	Version() int
}

type DocumentChange

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

type DocumentChanges

type DocumentChanges []DocumentChange

type DocumentHandler

type DocumentHandler interface {
	URI() string
	FullPath() string
	Dir() string
	Filename() string
}

type DocumentNotOpenErr

type DocumentNotOpenErr struct {
	DocumentHandler DocumentHandler
}

func (*DocumentNotOpenErr) Error

func (e *DocumentNotOpenErr) Error() string

type DocumentStorage

type DocumentStorage interface {
	// LS-specific methods
	CreateDocument(DocumentHandler, string, []byte) error
	CreateAndOpenDocument(DocumentHandler, string, []byte) error
	GetDocument(DocumentHandler) (Document, error)
	CloseAndRemoveDocument(DocumentHandler) error
	ChangeDocument(VersionedDocumentHandler, DocumentChanges) error
	HasOpenFiles(path string) (bool, error)
}

type Filesystem

type Filesystem interface {
	DocumentStorage
	SetLogger(*log.Logger)

	// direct FS methods
	ReadFile(name string) ([]byte, error)
	ReadDir(name string) ([]fs.DirEntry, error)
	Open(name string) (fs.File, error)
	Stat(name string) (os.FileInfo, error)
}

type InvalidPosErr

type InvalidPosErr struct {
	Pos Pos
}

func (*InvalidPosErr) Error

func (e *InvalidPosErr) Error() string

type MetadataAlreadyExistsErr

type MetadataAlreadyExistsErr struct {
	DocumentHandler DocumentHandler
}

func (*MetadataAlreadyExistsErr) Error

func (e *MetadataAlreadyExistsErr) 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

type UnknownDocumentErr

type UnknownDocumentErr struct {
	DocumentHandler DocumentHandler
}

func (*UnknownDocumentErr) Error

func (e *UnknownDocumentErr) Error() string

type VersionedDocumentHandler

type VersionedDocumentHandler interface {
	DocumentHandler
	Version() int
}

Jump to

Keyboard shortcuts

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