lspext

package
v0.0.0-...-f80c5dd Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package lspx contains extensions to the LSP protocol.

An overview of the different protocol variants:

// vanilla LSP
github.com/sourcegraph/go-langserver/pkg/lsp

// proxy (http gateway) server LSP extensions
github.com/sourcegraph/sourcegraph/xlang

// (this package) build/lang server LSP extensions
github.com/sourcegraph/sourcegraph/xlang/lspx

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WalkURIFields

func WalkURIFields(o interface{}, collect func(lsp.DocumentURI), update func(lsp.DocumentURI) lsp.DocumentURI)

WalkURIFields walks the LSP params/result object for fields containing document URIs.

If collect is non-nil, it calls collect(uri) for every URI encountered. Callers can use this to collect a list of all document URIs referenced in the params/result.

If update is non-nil, it updates all document URIs in an LSP params/result with the value of f(existingURI). Callers can use this to rewrite paths in the params/result.

TODO(sqs): does not support WorkspaceEdit (with a field whose TypeScript type is {[uri: string]: TextEdit[]}.

Types

type CacheGetParams

type CacheGetParams struct {
	// Key is the cache key. The key namespace is shared for a language
	// server, but with other language servers. For example the PHP
	// language server on different workspaces share the same key
	// namespace, but does not share the namespace with a Go language
	// server.
	Key string `json:"key"`
}

CacheGetParams is the input for 'cache/get'. The response is any or null.

type CacheSetParams

type CacheSetParams struct {
	// Key is the cache key. The key namespace is shared for a language
	// server, but with other language servers. For example the PHP
	// language server on different workspaces share the same key
	// namespace, but does not share the namespace with a Go language
	// server.
	Key string `json:"key"`

	// Value is type any. We use json.RawMessage since we expect caching
	// implementation to cache the raw bytes, and not bother with
	// Unmarshaling/Marshalling.
	Value *json.RawMessage `json:"value"`
}

CacheSetParams is the input for the notification 'cache/set'.

type ClientProxyInitializationOptions

type ClientProxyInitializationOptions struct {
	Mode string `json:"mode"`

	// Same as, but takes precedence over, InitializeParams.rootUri.
	// vscode-languageserver-node's LanguageClient doesn't allow overriding
	// InitializeParams.rootUri, so clients that use vscode-languageserver-node
	// instead set InitializeParams.initializationOptions.rootUri.
	RootURI *lsp.DocumentURI `json:"rootUri,omitempty"`

	// Session, if set, causes this session to be isolated from other
	// LSP sessions using the same workspace and mode. See
	// (contextID).session for more information.
	Session string `json:"session,omitempty"`

	// ZipURL is the zip URL to forward to the language server.
	ZipURL string `json:"zipURL,omitempty"`
}

ClientProxyInitializationOptions is the "initializationOptions" field of the "initialize" request params sent from the client to the LSP client proxy.

type ClientProxyInitializeParams

type ClientProxyInitializeParams struct {
	lsp.InitializeParams
	InitializationOptions ClientProxyInitializationOptions `json:"initializationOptions"`

	// Mode is DEPRECATED; it was moved to the subfield
	// initializationOptions.Mode. It is still here for backward
	// compatibility until the xlang service is upgraded.
	Mode string `json:"mode,omitempty"`
}

ClientProxyInitializeParams are sent by the client to the proxy in the "initialize" request. It has a non-standard field "mode", which is the name of the language (using vscode terminology); "go" or "typescript", for example.

type ContentParams

type ContentParams struct {
	TextDocument lsp.TextDocumentIdentifier `json:"textDocument"`
}

ContentParams is the input for 'textDocument/content'. The response is a 'TextDocumentItem'.

type DependencyReference

type DependencyReference struct {
	// Attributes describing the dependency that is being referenced. It is up
	// to the language server to define the schema of this object.
	Attributes map[string]interface{} `json:"attributes,omitempty"`

	// Hints is treated as an opaque object and passed directly by Sourcegraph
	// into the language server's workspace/xreferences method to help narrow
	// down the search space for the references to the symbol.
	//
	// If a language server emits no hints, Sourcegraph will pass none as a
	// parameter to workspace/xreferences which means it must search the entire
	// repository (workspace) in order to find references. workspace/xdependencies
	// should emit sufficient hints here for making all workspace/xreference
	// queries complete in a reasonable amount of time (less than a few seconds
	// for very large repositories). For example, one may include the
	// containing "package" or other build-system level "code unit". Emitting
	// the exact file is not recommended in general as that would produce more
	// data for little performance gain in most situations.
	Hints map[string]interface{} `json:"hints,omitempty"`
}

DependencyReference represents a reference to a dependency. []DependencyReference is the return type for the build server workspace/xdependencies method.

type ExecParams

type ExecParams struct {
	Command   string   `json:"command"`
	Arguments []string `json:"arguments"`
}

ExecParams contains the parameters for the exec LSP request.

type ExecResult

type ExecResult struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exitCode"`
}

ExecResult contains the result for the exec LSP response.

type FileInfo

type FileInfo struct {
	Name_ string `json:"name"`
	Size_ int64  `json:"size"`
	Dir_  bool   `json:"dir"`
}

FileInfo is the map-based implementation of FileInfo.

func (FileInfo) IsDir

func (fi FileInfo) IsDir() bool

func (FileInfo) ModTime

func (fi FileInfo) ModTime() time.Time

func (FileInfo) Mode

func (fi FileInfo) Mode() os.FileMode

func (FileInfo) Name

func (fi FileInfo) Name() string

func (FileInfo) Size

func (fi FileInfo) Size() int64

func (FileInfo) Sys

func (fi FileInfo) Sys() interface{}

type FilesParams

type FilesParams struct {
	Base string `json:"base,omitempty"`
}

FilesParams is the input for 'workspace/xfiles'. The response is '[]TextDocumentIdentifier'

type ImplementationLocation

type ImplementationLocation struct {
	lsp.Location // the location of the implementation

	// Type is the type of implementation relationship described by this location.
	//
	// If a type T was queried, the set of possible values are:
	//
	// - "to": named or ptr-to-named types assignable to interface T
	// - "from": named interfaces assignable from T (or only from *T if Ptr == true)
	//
	// If a method M on type T was queried, the same set of values above is used, except they refer
	// to methods on the described type (not the described type itself).
	//
	// (This type description is taken from golang.org/x/tools/cmd/guru.)
	Type string `json:"type,omitempty"`

	// Ptr is whether this implementation location is only assignable from a pointer *T (where T is
	// the queried type).
	Ptr bool `json:"ptr,omitempty"`

	// Method is whether a method was queried. If so, then the implementation locations refer to the
	// corresponding methods on the types found by the implementation query (not the types
	// themselves).
	Method bool `json:"method"`
}

ImplementationLocation is a superset of lsp.Location with additional Go-specific information about the implementation.

type InitializeParams

type InitializeParams struct {
	lsp.InitializeParams

	// OriginalRootURI is the original rootUri for this LSP session,
	// before any path rewriting occurred. It is typically a Git clone
	// URL of the form
	// "git://github.com/facebook/react.git?rev=master#lib".
	//
	// The Go lang/build server uses this to infer the import path
	// root (and directory structure) to use for a workspace.
	OriginalRootURI lsp.DocumentURI `json:"originalRootUri"`

	// Mode is the name of the language. It is used to determine the correct
	// language server to route a request to, and to inform a language server
	// what languages it should contribute.
	Mode string `json:"mode"`
}

type PackageDescriptor

type PackageDescriptor map[string]interface{}

PackageDescriptor identifies a package (usually but not always uniquely).

func (PackageDescriptor) String

func (s PackageDescriptor) String() string

String returns a consistently ordered string representation of the PackageDescriptor. It is useful for testing.

type PackageInformation

type PackageInformation struct {
	// Package is the set of attributes of the package
	Package PackageDescriptor `json:"package,omitempty"`

	// Dependencies is the list of dependency attributes
	Dependencies []DependencyReference `json:"dependencies,omitempty"`
}

PackageInformation is the metadata associated with a build-system- or package-manager-level package. Sometimes, languages have abstractions called "packages" as well, but this refers specifically to packages as defined by the build system or package manager. E.g., Python pip packages (NOT Python language packages or modules), Go packages, Maven packages (NOT Java language packages), npm modules (NOT JavaScript language modules). PackageInformation includes both attributes of the package itself and attributes of the package's dependencies.

type PartialResultParams

type PartialResultParams struct {
	// ID is the jsonrpc2 ID of the request we are returning partial
	// results for.
	ID lsp.ID `json:"id"`

	// Patch is a JSON patch as specified at http://jsonpatch.com/
	//
	// It is an interface{}, since our only requirement is that it JSON
	// marshals to a valid list of JSON Patch operations.
	Patch interface{} `json:"patch"`
}

PartialResultParams is the input for "$/partialResult", a notification.

type ReferenceInformation

type ReferenceInformation struct {
	// Reference is the location in the workspace where the `symbol` has been
	// referenced.
	Reference lsp.Location `json:"reference"`

	// Symbol is metadata information describing the symbol being referenced.
	Symbol SymbolDescriptor `json:"symbol"`
}

ReferenceInformation represents information about a reference to programming constructs like variables, classes, interfaces etc.

type SymbolDescriptor

type SymbolDescriptor map[string]interface{}

SymbolDescriptor represents information about a programming construct like a variable, class, interface, etc that has a reference to it. It is up to the language server to define the schema of this object.

SymbolDescriptor usually uniquely identifies a symbol, but it is not guaranteed to do so.

func (SymbolDescriptor) Contains

func (s SymbolDescriptor) Contains(other SymbolDescriptor) bool

Contains tells if this SymbolDescriptor fully contains all of the keys and values in the other symbol descriptor.

func (SymbolDescriptor) String

func (s SymbolDescriptor) String() string

String returns a consistently ordered string representation of the SymbolDescriptor. It is useful for testing.

type SymbolLocationInformation

type SymbolLocationInformation struct {
	// A concrete location at which the definition is located, if any.
	Location lsp.Location `json:"location,omitempty"`
	// Metadata about the definition.
	Symbol SymbolDescriptor `json:"symbol"`
}

SymbolLocationInformation is the response type for the `textDocument/xdefinition` extension.

type TelemetryEventParams

type TelemetryEventParams struct {
	Op        string            `json:"op"`             // the operation name
	StartTime time.Time         `json:"startTime"`      // when the operation started
	EndTime   time.Time         `json:"endTime"`        // when the operation ended
	Tags      map[string]string `json:"tags,omitempty"` // other metadata
}

TelemetryEventParams is a telemetry/event message sent from a build/lang server back to the proxy. The information here is forwarded to our opentracing system.

type WorkspacePackagesParams

type WorkspacePackagesParams struct{}

WorkspacePackagesParams is parameters for the `workspace/xpackages` extension.

See: https://github.com/sourcegraph/language-server-protocol/blob/7fd3c1/extension-workspace-references.md

type WorkspaceReferencesParams

type WorkspaceReferencesParams struct {
	// Query represents metadata about the symbol that is being searched for.
	Query SymbolDescriptor `json:"query"`

	// Hints provides optional hints about where the language server should
	// look in order to find the symbol (this is an optimization). It is up to
	// the language server to define the schema of this object.
	Hints map[string]interface{} `json:"hints,omitempty"`

	// Limit if positive will limit the number of results returned.
	Limit int `json:"limit,omitempty"`
}

WorkspaceReferencesParams is parameters for the `workspace/xreferences` extension

See: https://github.com/sourcegraph/language-server-protocol/blob/master/extension-workspace-reference.md

type WorkspaceSymbolParams

type WorkspaceSymbolParams struct {
	Query  string           `json:"query,omitempty"`
	Limit  int              `json:"limit"`
	Symbol SymbolDescriptor `json:"symbol,omitempty"`
}

WorkspaceSymbolParams is the extension workspace/symbol parameter type.

Jump to

Keyboard shortcuts

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