lsp

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 31 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 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 NoWhiteSpaceCommentCommand added in v0.21.0

func NoWhiteSpaceCommentCommand(args []string) types.Command

func TokenFoldingRanges added in v0.21.0

func TokenFoldingRanges(policy string) []types.FoldingRange

func UseAssignmentOperatorCommand added in v0.21.0

func UseAssignmentOperatorCommand(args []string) types.Command

Types

type BuiltInCall added in v0.20.0

type BuiltInCall struct {
	Builtin  *ast.Builtin
	Location *ast.Location
	Args     []*ast.Term
}

func AllBuiltinCalls added in v0.20.0

func AllBuiltinCalls(module *ast.Module) []BuiltInCall

AllBuiltinCalls returns all built-in calls in the module, excluding operators and any other function identified by an infix.

type BuiltinPosition added in v0.20.0

type BuiltinPosition struct {
	Builtin *ast.Builtin
	Line    uint
	Start   uint
	End     uint
}

type Cache

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

Cache is used to store: current file contents (which includes unsaved changes), the latest parsed modules, and diagnostics for each file (including diagnostics gathered from linting files alongside other files).

func NewCache

func NewCache() *Cache

func (*Cache) ClearAggregateDiagnostics

func (c *Cache) ClearAggregateDiagnostics()

func (*Cache) ClearFileDiagnostics

func (c *Cache) ClearFileDiagnostics()

func (*Cache) Delete

func (c *Cache) Delete(uri string)

Delete removes all cached data for a given URI.

func (*Cache) GetAggregateDiagnostics

func (c *Cache) GetAggregateDiagnostics(uri string) ([]types.Diagnostic, bool)

func (*Cache) GetAllDiagnosticsForURI

func (c *Cache) GetAllDiagnosticsForURI(uri string) []types.Diagnostic

func (*Cache) GetAllFiles

func (c *Cache) GetAllFiles() map[string]string

func (*Cache) GetAllModules

func (c *Cache) GetAllModules() map[string]*ast.Module

func (*Cache) GetBuiltinPositions added in v0.20.0

func (c *Cache) GetBuiltinPositions(uri string) (map[uint][]BuiltinPosition, bool)

func (*Cache) GetFileContents

func (c *Cache) GetFileContents(uri string) (string, bool)

func (*Cache) GetFileDiagnostics

func (c *Cache) GetFileDiagnostics(uri string) ([]types.Diagnostic, bool)

func (*Cache) GetModule

func (c *Cache) GetModule(uri string) (*ast.Module, bool)

func (*Cache) GetParseErrors

func (c *Cache) GetParseErrors(uri string) ([]types.Diagnostic, bool)

func (*Cache) SetAggregateDiagnostics

func (c *Cache) SetAggregateDiagnostics(uri string, diags []types.Diagnostic)

func (*Cache) SetBuiltinPositions added in v0.20.0

func (c *Cache) SetBuiltinPositions(uri string, positions map[uint][]BuiltinPosition)

func (*Cache) SetFileContents

func (c *Cache) SetFileContents(uri string, content string)

func (*Cache) SetFileDiagnostics

func (c *Cache) SetFileDiagnostics(uri string, diags []types.Diagnostic)

func (*Cache) SetModule

func (c *Cache) SetModule(uri string, module *ast.Module)

func (*Cache) SetParseErrors

func (c *Cache) SetParseErrors(uri string, diags []types.Diagnostic)

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

	LogInbound  bool
	LogOutbound bool

	// 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
}

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 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(opts *LanguageServerOptions) *LanguageServer

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)

type LanguageServerOptions

type LanguageServerOptions struct {
	ErrorLog io.Writer
}

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 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)

Directories

Path Synopsis
opa

Jump to

Keyboard shortcuts

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