lsp

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindRelevantChildNode added in v0.0.6

func FindRelevantChildNode(currentNode *sitter.Node, pointToLookUp sitter.Point) *sitter.Node

func GetDiagnosticFromLinterErr

func GetDiagnosticFromLinterErr(supMsg support.Message) (*lsp.Diagnostic, string, error)

func GetDiagnostics

func GetDiagnostics(uri uri.URI) ([]lsp.Diagnostic, error)

GetDiagnostics will run helm linter against the currect document URI and converts the helm.support.Message to lsp.Diagnostics

func GetFieldIdentifierPath added in v0.0.4

func GetFieldIdentifierPath(node *sitter.Node, doc *Document) (path string)

func GetLspRangeForNode added in v0.0.4

func GetLspRangeForNode(node *sitter.Node) lsp.Range

func GetVariableDefinition added in v0.0.6

func GetVariableDefinition(variableName string, node *sitter.Node, template string) *sitter.Node

func GetVariableDefinitionOfNode added in v0.0.6

func GetVariableDefinitionOfNode(node *sitter.Node, template string) *sitter.Node

func NodeAtPosition added in v0.0.4

func NodeAtPosition(tree *sitter.Tree, position lsp.Position) *sitter.Node

func NotifcationFromLint

func NotifcationFromLint(ctx context.Context, conn jsonrpc2.Conn, uri uri.URI) (*jsonrpc2.Notification, error)

func ParseAst added in v0.0.4

func ParseAst(content string) *sitter.Tree

func TraverseIdentifierPathUp added in v0.0.4

func TraverseIdentifierPathUp(node *sitter.Node, doc *Document) string

Types

type Document added in v0.0.5

type Document struct {
	URI                     lsp.DocumentURI
	Path                    string
	NeedsRefreshDiagnostics bool
	Content                 string

	Ast *sitter.Tree
	// contains filtered or unexported fields
}

Document represents an opened file.

func (*Document) ApplyChanges added in v0.0.5

func (d *Document) ApplyChanges(changes []lsp.TextDocumentContentChangeEvent)

ApplyChanges updates the content of the document from LSP textDocument/didChange events.

func (*Document) ApplyChangesToAst added in v0.0.5

func (d *Document) ApplyChangesToAst(newContent string)

func (*Document) ContentAtRange added in v0.0.5

func (d *Document) ContentAtRange(rng lsp.Range) string

ContentAtRange returns the document text at given range.

func (*Document) GetLine added in v0.0.5

func (d *Document) GetLine(index int) (string, bool)

GetLine returns the line at the given index.

func (*Document) GetLines added in v0.0.5

func (d *Document) GetLines() []string

GetLines returns all the lines in the document.

func (*Document) LookBehind added in v0.0.5

func (d *Document) LookBehind(pos lsp.Position, length int) string

LookBehind returns the n characters before the given position, on the same line.

func (*Document) LookForward added in v0.0.5

func (d *Document) LookForward(pos lsp.Position, length int) string

LookForward returns the n characters after the given position, on the same line.

func (*Document) ValueAt added in v0.0.5

func (d *Document) ValueAt(pos lsp.Position) string

func (*Document) WordAt added in v0.0.5

func (d *Document) WordAt(pos lsp.Position) string

WordAt returns the word found at the given location.

type DocumentStore

type DocumentStore struct {
	// contains filtered or unexported fields
}

documentStore holds opened documents.

func NewDocumentStore

func NewDocumentStore(fs FileStorage) *DocumentStore

func (*DocumentStore) Close

func (s *DocumentStore) Close(uri lsp.DocumentURI)

func (*DocumentStore) DidOpen

func (s *DocumentStore) DidOpen(params lsp.DidOpenTextDocumentParams) (*Document, error)

func (*DocumentStore) Get

func (s *DocumentStore) Get(docuri uri.URI) (*Document, bool)

type FileStorage

type FileStorage interface {

	// WorkingDir returns the current working directory.
	WorkingDir() string

	// Abs makes the given file path absolute if needed, using the FileStorage
	// working directory.
	Abs(path string) (string, error)

	// Rel makes the given absolute file path relative to the current working
	// directory.
	Rel(path string) (string, error)

	// Canonical returns the canonical version of this path, resolving any
	// symbolic link.
	Canonical(path string) string

	// FileExists returns whether a file exists at the given file path.
	FileExists(path string) (bool, error)

	// DirExists returns whether a directory exists at the given file path.
	DirExists(path string) (bool, error)

	// IsDescendantOf returns whether the given path is dir or one of its descendants.
	IsDescendantOf(dir string, path string) (bool, error)

	// Read returns the bytes content of the file at the given file path.
	Read(path string) ([]byte, error)

	// Write creates or overwrite the content at the given file path, creating
	// any intermediate directories if needed.
	Write(path string, content []byte) error
}

FileStorage is a port providing read and write access to a file storage.

Jump to

Keyboard shortcuts

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