cache

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0, BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndOfLine

func EndOfLine(p protocol.Position) protocol.Position

EndOfLine returns the end of the Line of the given protocol.Position

Types

type CompiledQuery

type CompiledQuery struct {
	Pos     token.Pos
	Ast     promql.Node
	Err     promql.ParseErrors
	Content string
	Record  string
}

CompiledQuery stores the results of compiling one query

type DocumentCache

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

DocumentCache caches the documents and compile Results associated with one server-client connection

func (*DocumentCache) AddDocument

func (c *DocumentCache) AddDocument(serverLifetime context.Context, doc *protocol.TextDocumentItem) (*DocumentHandle, error)

AddDocument adds a Document to the cache

func (*DocumentCache) Find added in v0.4.3

func (c *DocumentCache) Find(where *protocol.TextDocumentPositionParams) (there *Location, err error)

func (*DocumentCache) GetDocument

func (c *DocumentCache) GetDocument(uri protocol.DocumentURI) (*DocumentHandle, error)

GetDocument retrieve a Document from the cache Additionally returns a context that expires as soon as the document changes

func (*DocumentCache) Init

func (c *DocumentCache) Init()

Init Initializes a Document cache

func (*DocumentCache) RemoveDocument

func (c *DocumentCache) RemoveDocument(uri protocol.DocumentURI) error

RemoveDocument removes a Document from the cache

type DocumentHandle

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

DocumentHandle bundles a Document together with a context.Context that expires when the document changes

func (*DocumentHandle) AddCompileResult

func (d *DocumentHandle) AddCompileResult(pos token.Pos, ast promql.Node, err promql.ParseErrors, record string, content string) error

AddCompileResult updates the compilation Results of a Document. Discards the Result if the DocumentHandle is expired

func (*DocumentHandle) AddDiagnostic

func (d *DocumentHandle) AddDiagnostic(diagnostic *protocol.Diagnostic) error

AddDiagnostic updates the compilation Results of a Document. Discards the Result if the context is expired

func (*DocumentHandle) ApplyIncrementalChanges

func (d *DocumentHandle) ApplyIncrementalChanges(changes []protocol.TextDocumentContentChangeEvent, version float64) (string, error)

ApplyIncrementalChanges applies giver changes to a given Document Content The context in the DocumentHandle is ignored

func (*DocumentHandle) GetContent

func (d *DocumentHandle) GetContent() (string, error)

GetContent returns the content of a document and returns an error if that context has expired, i.e. the Document has changed since

func (*DocumentHandle) GetContext

func (d *DocumentHandle) GetContext() context.Context

func (*DocumentHandle) GetDiagnostics

func (d *DocumentHandle) GetDiagnostics() ([]protocol.Diagnostic, error)

GetDiagnostics returns the Compilation Results of a document and returns an error if that context has expired, i.e. the Document has changed since It blocks until all compile tasks are finished

func (*DocumentHandle) GetLanguageID

func (d *DocumentHandle) GetLanguageID() string

GetLanguageID returns the content of a document Since the URI never changes, it does not block or return errors

func (*DocumentHandle) GetQueries

func (d *DocumentHandle) GetQueries() ([]*CompiledQuery, error)

GetQueries returns the Compilation Results of a document and returns an error if that context has expired, i.e. the Document has changed since It blocks until all compile tasks are finished

func (*DocumentHandle) GetQuery

func (d *DocumentHandle) GetQuery(pos token.Pos) (*CompiledQuery, error)

GetQuery returns a successfully compiled query at the given position, if there is one Otherwise an error will be returned and returns an error if that context has expired, i.e. the Document has changed since It blocks until all compile tasks are finished

func (*DocumentHandle) GetSubstring

func (d *DocumentHandle) GetSubstring(pos token.Pos, endPos token.Pos) (string, error)

GetSubstring returns a substring of the content of a document and returns an error if that context has expired, i.e. the Document has changed since The remaining parameters are the start and end of the substring, encoded as token.Pos

func (*DocumentHandle) GetURI

func (d *DocumentHandle) GetURI() string

GetURI returns the content of a document Since the URI never changes, it does not block or return errors

func (*DocumentHandle) GetVersion

func (d *DocumentHandle) GetVersion() (float64, error)

GetVersion returns the content of a document and returns an error if that context has expired, i.e. the Document has changed since

func (*DocumentHandle) GetYamls

func (d *DocumentHandle) GetYamls() ([]*YamlDoc, error)

GetYamls returns the yaml documents found in the document and returns an error if that context has expired, i.e. the Document has changed since It blocks until all compile tasks are finished

func (*DocumentHandle) LineStartSafe

func (d *DocumentHandle) LineStartSafe(line int) (pos token.Pos, err error)

LineStartSafe is a wrapper around token.File.LineStart() that does not panic on Error

func (*DocumentHandle) PosToProtocolPosition

func (d *DocumentHandle) PosToProtocolPosition(pos token.Pos) (protocol.Position, error)

PosToProtocolPosition converts a token.Pos to a protocol.Position

func (*DocumentHandle) PositionToProtocolPosition

func (d *DocumentHandle) PositionToProtocolPosition(pos token.Position) (protocol.Position, error)

PositionToProtocolPosition converts a token.Position to a protocol.Position

func (*DocumentHandle) ProtocolPositionToTokenPos

func (d *DocumentHandle) ProtocolPositionToTokenPos(pos protocol.Position) (token.Pos, error)

ProtocolPositionToTokenPos converts a token.Pos to a protocol.Position

func (*DocumentHandle) SetContent

func (d *DocumentHandle) SetContent(serverLifetime context.Context, content string, version float64, new bool) error

SetContent sets the content of a document

func (*DocumentHandle) TokenPosToTokenPosition

func (d *DocumentHandle) TokenPosToTokenPosition(pos token.Pos) (token.Position, error)

TokenPosToTokenPosition converts a token.Pos to a token.Position

func (*DocumentHandle) YamlPositionToTokenPos

func (d *DocumentHandle) YamlPositionToTokenPos(line int, column int, lineOffset int) (token.Pos, error)

YamlPositionToTokenPos converts a position of the format used by the yaml parser to a token.Pos

type Location added in v0.4.3

type Location struct {
	Doc   *DocumentHandle
	Pos   token.Pos
	Query *CompiledQuery
	Node  promql.Node
}

Location bundles all the context that the cache can provide for a given protocol.Location

type YamlDoc

type YamlDoc struct {
	AST yaml.Node
	Err error
	// Not encoded in the AST
	End token.Pos
	// Offset that has to be added to every line number before translating into a token.Pos
	LineOffset int
}

YamlDoc contains the results of compiling a yaml document

Jump to

Keyboard shortcuts

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