config-lsp/doc-values/value-custom.go
2024-08-10 22:33:14 +02:00

38 lines
961 B
Go

package docvalues
import (
protocol "github.com/tliron/glsp/protocol_3_16"
)
type CustomValueContext interface {
GetIsContext() bool
}
type EmptyValueContext struct{}
func (EmptyValueContext) GetIsContext() bool {
return true
}
var EmptyValueContextInstance = EmptyValueContext{}
type CustomValue struct {
FetchValue func(context CustomValueContext) Value
}
func (v CustomValue) GetTypeDescription() []string {
return v.FetchValue(EmptyValueContextInstance).GetTypeDescription()
}
func (v CustomValue) CheckIsValid(value string) []*InvalidValue {
return v.FetchValue(EmptyValueContextInstance).CheckIsValid(value)
}
func (v CustomValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem {
return v.FetchValue(EmptyValueContextInstance).FetchCompletions(line, cursor)
}
func (v CustomValue) FetchHoverInfo(line string, cursor uint32) []string {
return v.FetchValue(EmptyValueContextInstance).FetchHoverInfo(line, cursor)
}