lsp

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeEdits added in v0.21.0

func ComputeEdits(before, after string) []types.TextEdit

ComputeEdits computes diff edits from 2 string inputs.

func DirectoryStructureMismatchCommand added in v0.26.0

func DirectoryStructureMismatchCommand(args []string) types.Command

func FmtCommand added in v0.21.0

func FmtCommand(args []string) types.Command

func FmtV1Command added in v0.21.0

func FmtV1Command(args []string) types.Command

func NewConnectionFromLanguageServer added in v0.21.0

func NewConnectionFromLanguageServer(
	ctx context.Context,
	handler ConnectionHandlerFunc,
	opts *ConnectionOptions,
) *jsonrpc2.Conn

func NewRegalStore added in v0.24.0

func NewRegalStore() storage.Store

func NoWhiteSpaceCommentCommand added in v0.21.0

func NoWhiteSpaceCommentCommand(args []string) types.Command

func PutFileMod added in v0.24.0

func PutFileMod(ctx context.Context, store storage.Store, fileURI string, mod *ast.Module) error

func PutFileRefs added in v0.24.0

func PutFileRefs(ctx context.Context, store storage.Store, fileURI string, refs []string) error

func RemoveFileMod added in v0.24.0

func RemoveFileMod(ctx context.Context, store storage.Store, fileURI string) error

func TokenFoldingRanges added in v0.21.0

func TokenFoldingRanges(policy string) []types.FoldingRange

nolint:gosec

func UseAssignmentOperatorCommand added in v0.21.0

func UseAssignmentOperatorCommand(args []string) types.Command

Types

type ConnectionHandlerFunc added in v0.21.0

type ConnectionHandlerFunc func(context.Context, *jsonrpc2.Conn, *jsonrpc2.Request) (result interface{}, err error)

type ConnectionLoggingConfig added in v0.21.0

type ConnectionLoggingConfig struct {
	Writer io.Writer

	// IncludeMethods is a list of methods to include in the request log.
	// If empty, all methods are included. IncludeMethods takes precedence
	// over ExcludeMethods.
	IncludeMethods []string
	// ExcludeMethods is a list of methods to exclude from the request log.
	ExcludeMethods []string

	LogInbound  bool
	LogOutbound bool
}

func (*ConnectionLoggingConfig) ShouldLog added in v0.21.0

func (cfg *ConnectionLoggingConfig) ShouldLog(method string) bool

type ConnectionOptions added in v0.21.0

type ConnectionOptions struct {
	LoggingConfig ConnectionLoggingConfig
}

type EvalPathResult added in v0.25.0

type EvalPathResult struct {
	Value       any                         `json:"value"`
	PrintOutput map[string]map[int][]string `json:"printOutput"`
	IsUndefined bool                        `json:"isUndefined"`
}

type HoverResponse added in v0.20.0

type HoverResponse struct {
	Contents types.MarkupContent `json:"contents"`
	Range    types.Range         `json:"range"`
}

type LanguageServer

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

func NewLanguageServer

func NewLanguageServer(ctx context.Context, opts *LanguageServerOptions) *LanguageServer

func (*LanguageServer) Eval added in v0.25.0

func (l *LanguageServer) Eval(
	ctx context.Context,
	query string,
	input io.Reader,
	printHook print.Hook,
	dataBundles map[string]bundle.Bundle,
) (rego.ResultSet, error)

func (*LanguageServer) EvalWorkspacePath added in v0.25.0

func (l *LanguageServer) EvalWorkspacePath(
	ctx context.Context,
	query string,
	input io.Reader,
) (EvalPathResult, error)

func (*LanguageServer) Handle

func (l *LanguageServer) Handle(
	ctx context.Context,
	conn *jsonrpc2.Conn,
	req *jsonrpc2.Request,
) (result any, err error)

func (*LanguageServer) SetConn

func (l *LanguageServer) SetConn(conn *jsonrpc2.Conn)

func (*LanguageServer) StartCommandWorker added in v0.21.0

func (l *LanguageServer) StartCommandWorker(ctx context.Context)

func (*LanguageServer) StartConfigWorker added in v0.21.0

func (l *LanguageServer) StartConfigWorker(ctx context.Context)

func (*LanguageServer) StartDiagnosticsWorker

func (l *LanguageServer) StartDiagnosticsWorker(ctx context.Context)

func (*LanguageServer) StartHoverWorker added in v0.20.0

func (l *LanguageServer) StartHoverWorker(ctx context.Context)

func (*LanguageServer) StartTemplateWorker added in v0.26.0

func (l *LanguageServer) StartTemplateWorker(ctx context.Context)

StartTemplateWorker runs the process of the server that templates newly created Rego files.

func (*LanguageServer) StartWebServer added in v0.27.0

func (l *LanguageServer) StartWebServer(ctx context.Context)

func (*LanguageServer) StartWorkspaceStateWorker added in v0.25.0

func (l *LanguageServer) StartWorkspaceStateWorker(ctx context.Context)

StartWorkspaceStateWorker will poll for changes to the workspaces state that are not sent from the client. For example, when a file a is removed from the workspace after changing branch.

type LanguageServerOptions

type LanguageServerOptions struct {
	// LogWriter is the io.Writer where all logged messages will be written.
	LogWriter io.Writer

	// log.Level controls the verbosity of the logs, with log.LevelOff, no messages
	// are logged, log.LevelMessage logs only messages and errors, and log.LevelDebug
	// Logs all messages.
	LogLevel log.Level

	// WorkspaceDiagnosticsPoll, if set > 0 will cause a full workspace lint
	// to run on this interval. This is intended to be used where eventing
	// is not working, as expected. E.g. with a client that does not send
	// changes or when running in extremely slow environments like GHA with
	// the go race detector on. TODO, work out why this is required.
	WorkspaceDiagnosticsPoll time.Duration
}

type OpKind added in v0.21.0

type OpKind int

OpKind is used to denote the type of operation a line represents.

const (
	// Delete is the operation kind for a line that is present in the input
	// but not in the output.
	Delete OpKind = iota
	// Insert is the operation kind for a line that is new in the output.
	Insert
	// Equal is the operation kind for a line that is the same in the input and
	// output, often used to provide context around edited lines.
	Equal
)

type PrintHook added in v0.25.0

type PrintHook struct {
	Output map[string]map[int][]string
}

func (PrintHook) Print added in v0.25.0

func (h PrintHook) Print(ctx print.Context, msg string) error

type StdOutReadWriteCloser

type StdOutReadWriteCloser struct{}

func (StdOutReadWriteCloser) Close

func (StdOutReadWriteCloser) Close() error

func (StdOutReadWriteCloser) Read

func (StdOutReadWriteCloser) Read(p []byte) (int, error)

func (StdOutReadWriteCloser) Write

func (StdOutReadWriteCloser) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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