filesystem

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Handler *filehandler.FileHandler
	Text    []byte
	Version int
}

File is a structure that contains fields and methods that the LSP uses for handling document files.

func FileFromDocumentItem

func FileFromDocumentItem(doc lsp.TextDocumentItem) *File

FileFromDocumentItem will create a File from a given LSP textdocument item.

func (*File) Dir

func (f *File) Dir() (string, error)

Dir returns the path to the directory of the file from the file handler.

func (*File) Filename

func (f *File) Filename() (string, error)

Filename returns the name of the file from the file handler.

func (*File) FullPath

func (f *File) FullPath() (string, error)

FullPath returns the file's full path from the file handler.

func (*File) URI

func (f *File) URI() string

URI returns the URI from the file handler.

type FileSystem

type FileSystem struct {
	MemoryFS afero.Fs
	OsFS     afero.Fs

	Logger *log.Logger
}

FileSystem is a file I/O pool that uses afero to create an in-memory and an OS file system to store the documents in.

func New

func New() *FileSystem

New instantiates a new file system.

func (*FileSystem) Change

func (fs *FileSystem) Change(handler *filehandler.VersionedFileHandler, changes []lsp.TextDocumentContentChangeEvent) error

Change will update a file with the changes provided by the language client.

func (*FileSystem) Create

func (fs *FileSystem) Create(fh filehandler.FileHandler, contents []byte) error

Create will create a file in the file system and add its metadata to the metadata map.

func (*FileSystem) Open

func (fs *FileSystem) Open(name string) (afero.File, error)

Open will open the raw file to perform I/O operations on it.

func (*FileSystem) ReadFile

func (fs *FileSystem) ReadFile(name string) ([]byte, error)

ReadFile will read the contents of a file with a given name.

func (*FileSystem) Remove

func (fs *FileSystem) Remove(fh *filehandler.FileHandler) error

Remove will mark the file as closed and then it will remove the file from the pool.

func (*FileSystem) SetLogger

func (fs *FileSystem) SetLogger(logger *log.Logger)

SetLogger will override the logger of the filesystem instance.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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