Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/lsp_ext.ts')
-rw-r--r--editors/code/src/lsp_ext.ts240
1 files changed, 107 insertions, 133 deletions
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 29349cc20f..f6f5124dc4 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -4,130 +4,134 @@
import * as lc from "vscode-languageclient";
-export interface AnalyzerStatusParams {
- textDocument?: lc.TextDocumentIdentifier;
-}
+// rust-analyzer overrides
+
+export const hover = new lc.RequestType<
+ HoverParams,
+ (lc.Hover & { actions: CommandLinkGroup[] }) | null,
+ void
+>("textDocument/hover");
+export type HoverParams = { position: lc.Position | lc.Range } & Omit<
+ lc.TextDocumentPositionParams,
+ "position"
+> &
+ lc.WorkDoneProgressParams;
+export type CommandLink = {
+ /**
+ * A tooltip for the command, when represented in the UI.
+ */
+ tooltip?: string;
+} & lc.Command;
+export type CommandLinkGroup = {
+ title?: string;
+ commands: CommandLink[];
+};
+
+// rust-analyzer extensions
+
export const analyzerStatus = new lc.RequestType<AnalyzerStatusParams, string, void>(
"rust-analyzer/analyzerStatus"
);
+export const cancelFlycheck = new lc.NotificationType0("rust-analyzer/cancelFlycheck");
+export const clearFlycheck = new lc.NotificationType0("rust-analyzer/clearFlycheck");
+export const expandMacro = new lc.RequestType<ExpandMacroParams, ExpandedMacro | null, void>(
+ "rust-analyzer/expandMacro"
+);
export const memoryUsage = new lc.RequestType0<string, void>("rust-analyzer/memoryUsage");
-export const shuffleCrateGraph = new lc.RequestType0<null, void>("rust-analyzer/shuffleCrateGraph");
-
-export interface ServerStatusParams {
- health: "ok" | "warning" | "error";
- quiescent: boolean;
- message?: string;
-}
-export const serverStatus = new lc.NotificationType<ServerStatusParams>(
- "experimental/serverStatus"
+export const openServerLogs = new lc.NotificationType0("rust-analyzer/openServerLogs");
+export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>(
+ "rust-analyzer/relatedTests"
);
-
export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
-
-export const hover = new lc.RequestType<HoverParams, lc.Hover | null, void>("textDocument/hover");
-
-export interface HoverParams extends lc.WorkDoneProgressParams {
- textDocument: lc.TextDocumentIdentifier;
- position: lc.Range | lc.Position;
-}
-
-export interface SyntaxTreeParams {
- textDocument: lc.TextDocumentIdentifier;
- range: lc.Range | null;
-}
+export const runFlycheck = new lc.NotificationType<{
+ textDocument: lc.TextDocumentIdentifier | null;
+}>("rust-analyzer/runFlycheck");
+export const shuffleCrateGraph = new lc.RequestType0<null, void>("rust-analyzer/shuffleCrateGraph");
export const syntaxTree = new lc.RequestType<SyntaxTreeParams, string, void>(
"rust-analyzer/syntaxTree"
);
-
-export const viewHir = new lc.RequestType<lc.TextDocumentPositionParams, string, void>(
- "rust-analyzer/viewHir"
+export const viewCrateGraph = new lc.RequestType<ViewCrateGraphParams, string, void>(
+ "rust-analyzer/viewCrateGraph"
);
-
export const viewFileText = new lc.RequestType<lc.TextDocumentIdentifier, string, void>(
"rust-analyzer/viewFileText"
);
-
-export interface ViewItemTreeParams {
- textDocument: lc.TextDocumentIdentifier;
-}
-
+export const viewHir = new lc.RequestType<lc.TextDocumentPositionParams, string, void>(
+ "rust-analyzer/viewHir"
+);
export const viewItemTree = new lc.RequestType<ViewItemTreeParams, string, void>(
"rust-analyzer/viewItemTree"
);
-export interface ViewCrateGraphParams {
- full: boolean;
-}
+export type AnalyzerStatusParams = { textDocument?: lc.TextDocumentIdentifier };
-export const viewCrateGraph = new lc.RequestType<ViewCrateGraphParams, string, void>(
- "rust-analyzer/viewCrateGraph"
-);
-
-export interface ExpandMacroParams {
+export type ExpandMacroParams = {
textDocument: lc.TextDocumentIdentifier;
position: lc.Position;
-}
-export interface ExpandedMacro {
+};
+export type ExpandedMacro = {
name: string;
expansion: string;
-}
-export const expandMacro = new lc.RequestType<ExpandMacroParams, ExpandedMacro | null, void>(
- "rust-analyzer/expandMacro"
-);
-
-export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>(
- "rust-analyzer/relatedTests"
-);
-
-export const cancelFlycheck = new lc.NotificationType0("rust-analyzer/cancelFlycheck");
-export const clearFlycheck = new lc.NotificationType0("rust-analyzer/clearFlycheck");
-export const runFlycheck = new lc.NotificationType<{
- textDocument: lc.TextDocumentIdentifier | null;
-}>("rust-analyzer/runFlycheck");
-
-// Experimental extensions
-
-export interface SsrParams {
- query: string;
- parseOnly: boolean;
+};
+export type TestInfo = { runnable: Runnable };
+export type SyntaxTreeParams = {
textDocument: lc.TextDocumentIdentifier;
- position: lc.Position;
- selections: readonly lc.Range[];
-}
-export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>("experimental/ssr");
+ range: lc.Range | null;
+};
+export type ViewCrateGraphParams = { full: boolean };
+export type ViewItemTreeParams = { textDocument: lc.TextDocumentIdentifier };
-export interface MatchingBraceParams {
- textDocument: lc.TextDocumentIdentifier;
- positions: lc.Position[];
-}
+// experimental extensions
+
+export const joinLines = new lc.RequestType<JoinLinesParams, lc.TextEdit[], void>(
+ "experimental/joinLines"
+);
export const matchingBrace = new lc.RequestType<MatchingBraceParams, lc.Position[], void>(
"experimental/matchingBrace"
);
-
+export const moveItem = new lc.RequestType<MoveItemParams, lc.TextEdit[], void>(
+ "experimental/moveItem"
+);
+export const onEnter = new lc.RequestType<lc.TextDocumentPositionParams, lc.TextEdit[], void>(
+ "experimental/onEnter"
+);
+export const openCargoToml = new lc.RequestType<OpenCargoTomlParams, lc.Location, void>(
+ "experimental/openCargoToml"
+);
+export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>(
+ "experimental/externalDocs"
+);
export const parentModule = new lc.RequestType<
lc.TextDocumentPositionParams,
lc.LocationLink[] | null,
void
>("experimental/parentModule");
-
-export interface JoinLinesParams {
- textDocument: lc.TextDocumentIdentifier;
- ranges: lc.Range[];
-}
-export const joinLines = new lc.RequestType<JoinLinesParams, lc.TextEdit[], void>(
- "experimental/joinLines"
+export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>(
+ "experimental/runnables"
);
-
-export const onEnter = new lc.RequestType<lc.TextDocumentPositionParams, lc.TextEdit[], void>(
- "experimental/onEnter"
+export const serverStatus = new lc.NotificationType<ServerStatusParams>(
+ "experimental/serverStatus"
);
+export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>("experimental/ssr");
-export interface RunnablesParams {
+export type JoinLinesParams = {
textDocument: lc.TextDocumentIdentifier;
- position: lc.Position | null;
-}
-
-export interface Runnable {
+ ranges: lc.Range[];
+};
+export type MatchingBraceParams = {
+ textDocument: lc.TextDocumentIdentifier;
+ positions: lc.Position[];
+};
+export type MoveItemParams = {
+ textDocument: lc.TextDocumentIdentifier;
+ range: lc.Range;
+ direction: Direction;
+};
+export type Direction = "Up" | "Down";
+export type OpenCargoTomlParams = {
+ textDocument: lc.TextDocumentIdentifier;
+};
+export type Runnable = {
label: string;
location?: lc.LocationLink;
kind: "cargo";
@@ -139,50 +143,20 @@ export interface Runnable {
expectTest?: boolean;
overrideCargo?: string;
};
-}
-export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>(
- "experimental/runnables"
-);
-
-export interface TestInfo {
- runnable: Runnable;
-}
-
-export interface CommandLink extends lc.Command {
- /**
- * A tooltip for the command, when represented in the UI.
- */
- tooltip?: string;
-}
-
-export interface CommandLinkGroup {
- title?: string;
- commands: CommandLink[];
-}
-
-export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>(
- "experimental/externalDocs"
-);
-
-export const openCargoToml = new lc.RequestType<OpenCargoTomlParams, lc.Location, void>(
- "experimental/openCargoToml"
-);
-
-export interface OpenCargoTomlParams {
+};
+export type RunnablesParams = {
textDocument: lc.TextDocumentIdentifier;
-}
-
-export const moveItem = new lc.RequestType<MoveItemParams, lc.TextEdit[], void>(
- "experimental/moveItem"
-);
-
-export interface MoveItemParams {
+ position: lc.Position | null;
+};
+export type ServerStatusParams = {
+ health: "ok" | "warning" | "error";
+ quiescent: boolean;
+ message?: string;
+};
+export type SsrParams = {
+ query: string;
+ parseOnly: boolean;
textDocument: lc.TextDocumentIdentifier;
- range: lc.Range;
- direction: Direction;
-}
-
-export const enum Direction {
- Up = "Up",
- Down = "Down",
-}
+ position: lc.Position;
+ selections: readonly lc.Range[];
+};