Documentation
¶
Index ¶
- func EndOfLine(p protocol.Position) protocol.Position
- type CompiledQuery
- type DocumentCache
- func (c *DocumentCache) AddDocument(serverLifetime context.Context, doc *protocol.TextDocumentItem) (*DocumentHandle, error)
- func (c *DocumentCache) Find(where *protocol.TextDocumentPositionParams) (there *Location, err error)
- func (c *DocumentCache) GetDocument(uri protocol.DocumentURI) (*DocumentHandle, error)
- func (c *DocumentCache) Init()
- func (c *DocumentCache) RemoveDocument(uri protocol.DocumentURI) error
- type DocumentHandle
- func (d *DocumentHandle) AddCompileResult(pos token.Pos, ast promql.Node, err promql.ParseErrors, record string, ...) error
- func (d *DocumentHandle) AddDiagnostic(diagnostic *protocol.Diagnostic) error
- func (d *DocumentHandle) ApplyIncrementalChanges(changes []protocol.TextDocumentContentChangeEvent, version float64) (string, error)
- func (d *DocumentHandle) GetContent() (string, error)
- func (d *DocumentHandle) GetContext() context.Context
- func (d *DocumentHandle) GetDiagnostics() ([]protocol.Diagnostic, error)
- func (d *DocumentHandle) GetLanguageID() string
- func (d *DocumentHandle) GetQueries() ([]*CompiledQuery, error)
- func (d *DocumentHandle) GetQuery(pos token.Pos) (*CompiledQuery, error)
- func (d *DocumentHandle) GetSubstring(pos token.Pos, endPos token.Pos) (string, error)
- func (d *DocumentHandle) GetURI() string
- func (d *DocumentHandle) GetVersion() (float64, error)
- func (d *DocumentHandle) GetYamls() ([]*YamlDoc, error)
- func (d *DocumentHandle) LineStartSafe(line int) (pos token.Pos, err error)
- func (d *DocumentHandle) PosToProtocolPosition(pos token.Pos) (protocol.Position, error)
- func (d *DocumentHandle) PositionToProtocolPosition(pos token.Position) (protocol.Position, error)
- func (d *DocumentHandle) ProtocolPositionToTokenPos(pos protocol.Position) (token.Pos, error)
- func (d *DocumentHandle) SetContent(serverLifetime context.Context, content string, version float64, new bool) error
- func (d *DocumentHandle) TokenPosToTokenPosition(pos token.Pos) (token.Position, error)
- func (d *DocumentHandle) YamlPositionToTokenPos(line int, column int, lineOffset int) (token.Pos, error)
- type Location
- type YamlDoc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) 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 ¶
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 ¶
PosToProtocolPosition converts a token.Pos to a protocol.Position
func (*DocumentHandle) PositionToProtocolPosition ¶
PositionToProtocolPosition converts a token.Position to a protocol.Position
func (*DocumentHandle) ProtocolPositionToTokenPos ¶
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 ¶
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