filesystem

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MPL-2.0 Imports: 15 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 added in v0.10.0

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

func NewDocumentMetadata added in v0.6.0

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

func NewFilesystem

func NewFilesystem() *fsystem

Types

type Document added in v0.6.0

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

type DocumentChange added in v0.6.0

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

type DocumentChanges added in v0.6.0

type DocumentChanges []DocumentChange

type DocumentHandler added in v0.6.0

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

type DocumentNotOpenErr added in v0.6.0

type DocumentNotOpenErr struct {
	DocumentHandler DocumentHandler
}

func (*DocumentNotOpenErr) Error added in v0.6.0

func (e *DocumentNotOpenErr) Error() string

type DocumentStorage added in v0.6.0

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 added in v0.10.0

type InvalidPosErr struct {
	Pos Pos
}

func (*InvalidPosErr) Error added in v0.10.0

func (e *InvalidPosErr) Error() string

type MetadataAlreadyExistsErr added in v0.6.0

type MetadataAlreadyExistsErr struct {
	DocumentHandler DocumentHandler
}

func (*MetadataAlreadyExistsErr) Error added in v0.6.0

func (e *MetadataAlreadyExistsErr) Error() string

type Pos added in v0.10.0

type Pos struct {
	Line, Column int
}

Pos represents LSP-style position (zero-indexed)

func (Pos) String added in v0.10.0

func (p Pos) String() string

type Range added in v0.10.0

type Range struct {
	Start, End Pos
}

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

type UnknownDocumentErr added in v0.6.0

type UnknownDocumentErr struct {
	DocumentHandler DocumentHandler
}

func (*UnknownDocumentErr) Error added in v0.6.0

func (e *UnknownDocumentErr) Error() string

type VersionedDocumentHandler added in v0.6.0

type VersionedDocumentHandler interface {
	DocumentHandler
	Version() int
}

Jump to

Keyboard shortcuts

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