1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/**
* This file mirrors `crates/rust-analyzer/src/req.rs` declarations.
*/
import * as lc from "vscode-languageclient";
type Option<T> = null | T;
type Vec<T> = T[];
type FxHashMap<K extends PropertyKey, V> = Record<K, V>;
function request<TParams, TResult>(method: string) {
return new lc.RequestType<TParams, TResult, unknown>(`rust-analyzer/${method}`);
}
function notification<TParam>(method: string) {
return new lc.NotificationType<TParam>(method);
}
export const analyzerStatus = request<null, string>("analyzerStatus");
export const collectGarbage = request<null, null>("collectGarbage");
export interface SyntaxTreeParams {
textDocument: lc.TextDocumentIdentifier;
range: Option<lc.Range>;
}
export const syntaxTree = request<SyntaxTreeParams, string>("syntaxTree");
export interface ExpandMacroParams {
textDocument: lc.TextDocumentIdentifier;
position: Option<lc.Position>;
}
export interface ExpandedMacro {
name: string;
expansion: string;
}
export const expandMacro = request<ExpandMacroParams, Option<ExpandedMacro>>("expandMacro");
export interface FindMatchingBraceParams {
textDocument: lc.TextDocumentIdentifier;
offsets: Vec<lc.Position>;
}
export const findMatchingBrace = request<FindMatchingBraceParams, Vec<lc.Position>>("findMatchingBrace");
export interface PublishDecorationsParams {
uri: string;
decorations: Vec<Decoration>;
}
export interface Decoration {
range: lc.Range;
tag: string;
bindingHash: Option<string>;
}
export const decorationsRequest = request<lc.TextDocumentIdentifier, Vec<Decoration>>("decorationsRequest");
export const parentModule = request<lc.TextDocumentPositionParams, Vec<lc.Location>>("parentModule");
export interface JoinLinesParams {
textDocument: lc.TextDocumentIdentifier;
ranges: lc.Range[];
}
export const joinLines = new lc.RequestType<JoinLinesParams, lc.TextEdit[], unknown>('experimental/joinLines');
export const onEnter = request<lc.TextDocumentPositionParams, Option<lc.WorkspaceEdit>>("onEnter");
export interface RunnablesParams {
textDocument: lc.TextDocumentIdentifier;
position: Option<lc.Position>;
}
export interface Runnable {
range: lc.Range;
label: string;
bin: string;
args: Vec<string>;
extraArgs: Vec<string>;
env: FxHashMap<string, string>;
cwd: Option<string>;
}
export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables");
export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint;
export namespace InlayHint {
export const enum Kind {
TypeHint = "TypeHint",
ParamHint = "ParameterHint",
ChainingHint = "ChainingHint",
}
interface Common {
range: lc.Range;
label: string;
}
export type TypeHint = Common & { kind: Kind.TypeHint };
export type ParamHint = Common & { kind: Kind.ParamHint };
export type ChainingHint = Common & { kind: Kind.ChainingHint };
}
export interface InlayHintsParams {
textDocument: lc.TextDocumentIdentifier;
}
export const inlayHints = request<InlayHintsParams, Vec<InlayHint>>("inlayHints");
export interface SsrParams {
query: string;
parseOnly: boolean;
}
export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, unknown>('experimental/ssr');
export const publishDecorations = notification<PublishDecorationsParams>("publishDecorations");
export interface SourceChange {
label: string;
workspaceEdit: lc.WorkspaceEdit;
cursorPosition: Option<lc.TextDocumentPositionParams>;
}
|