]> git.lizzy.rs Git - rust.git/blob - crates/ra_lsp_server/src/req.rs
add option to disable notify
[rust.git] / crates / ra_lsp_server / src / req.rs
1 use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url};
2 use rustc_hash::FxHashMap;
3 use serde::{Deserialize, Serialize};
4
5 pub use lsp_types::{
6     notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
7     CodeLensParams, CompletionParams, CompletionResponse, DidChangeConfigurationParams,
8     DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions,
9     DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse,
10     FileSystemWatcher, Hover, InitializeResult, MessageType, PublishDiagnosticsParams,
11     ReferenceParams, Registration, RegistrationParams, ShowMessageParams, SignatureHelp,
12     TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams,
13 };
14
15 pub enum AnalyzerStatus {}
16
17 impl Request for AnalyzerStatus {
18     type Params = ();
19     type Result = String;
20     const METHOD: &'static str = "rust-analyzer/analyzerStatus";
21 }
22
23 pub enum CollectGarbage {}
24
25 impl Request for CollectGarbage {
26     type Params = ();
27     type Result = ();
28     const METHOD: &'static str = "rust-analyzer/collectGarbage";
29 }
30
31 pub enum SyntaxTree {}
32
33 impl Request for SyntaxTree {
34     type Params = SyntaxTreeParams;
35     type Result = String;
36     const METHOD: &'static str = "rust-analyzer/syntaxTree";
37 }
38
39 #[derive(Deserialize, Debug)]
40 #[serde(rename_all = "camelCase")]
41 pub struct SyntaxTreeParams {
42     pub text_document: TextDocumentIdentifier,
43     pub range: Option<Range>,
44 }
45
46 pub enum SelectionRangeRequest {}
47
48 impl Request for SelectionRangeRequest {
49     type Params = SelectionRangeParams;
50     type Result = Vec<SelectionRange>;
51     const METHOD: &'static str = "textDocument/selectionRange";
52 }
53
54 #[derive(Deserialize, Debug)]
55 #[serde(rename_all = "camelCase")]
56 pub struct SelectionRangeParams {
57     pub text_document: TextDocumentIdentifier,
58     pub positions: Vec<Position>,
59 }
60
61 #[derive(Serialize, Debug)]
62 #[serde(rename_all = "camelCase")]
63 pub struct SelectionRange {
64     pub range: Range,
65     pub parent: Option<Box<SelectionRange>>,
66 }
67
68 pub enum FindMatchingBrace {}
69
70 impl Request for FindMatchingBrace {
71     type Params = FindMatchingBraceParams;
72     type Result = Vec<Position>;
73     const METHOD: &'static str = "rust-analyzer/findMatchingBrace";
74 }
75
76 #[derive(Deserialize, Debug)]
77 #[serde(rename_all = "camelCase")]
78 pub struct FindMatchingBraceParams {
79     pub text_document: TextDocumentIdentifier,
80     pub offsets: Vec<Position>,
81 }
82
83 pub enum DecorationsRequest {}
84
85 impl Request for DecorationsRequest {
86     type Params = TextDocumentIdentifier;
87     type Result = Vec<Decoration>;
88     const METHOD: &'static str = "rust-analyzer/decorationsRequest";
89 }
90
91 pub enum PublishDecorations {}
92
93 impl Notification for PublishDecorations {
94     type Params = PublishDecorationsParams;
95     const METHOD: &'static str = "rust-analyzer/publishDecorations";
96 }
97
98 #[derive(Serialize, Debug)]
99 #[serde(rename_all = "camelCase")]
100 pub struct PublishDecorationsParams {
101     pub uri: Url,
102     pub decorations: Vec<Decoration>,
103 }
104
105 #[derive(Serialize, Debug)]
106 #[serde(rename_all = "camelCase")]
107 pub struct Decoration {
108     pub range: Range,
109     pub tag: &'static str,
110     pub binding_hash: Option<String>,
111 }
112
113 pub enum ParentModule {}
114
115 impl Request for ParentModule {
116     type Params = TextDocumentPositionParams;
117     type Result = Vec<Location>;
118     const METHOD: &'static str = "rust-analyzer/parentModule";
119 }
120
121 pub enum JoinLines {}
122
123 impl Request for JoinLines {
124     type Params = JoinLinesParams;
125     type Result = SourceChange;
126     const METHOD: &'static str = "rust-analyzer/joinLines";
127 }
128
129 #[derive(Deserialize, Debug)]
130 #[serde(rename_all = "camelCase")]
131 pub struct JoinLinesParams {
132     pub text_document: TextDocumentIdentifier,
133     pub range: Range,
134 }
135
136 pub enum OnEnter {}
137
138 impl Request for OnEnter {
139     type Params = TextDocumentPositionParams;
140     type Result = Option<SourceChange>;
141     const METHOD: &'static str = "rust-analyzer/onEnter";
142 }
143
144 pub enum Runnables {}
145
146 impl Request for Runnables {
147     type Params = RunnablesParams;
148     type Result = Vec<Runnable>;
149     const METHOD: &'static str = "rust-analyzer/runnables";
150 }
151
152 #[derive(Serialize, Deserialize, Debug)]
153 #[serde(rename_all = "camelCase")]
154 pub struct RunnablesParams {
155     pub text_document: TextDocumentIdentifier,
156     pub position: Option<Position>,
157 }
158
159 #[derive(Serialize, Debug)]
160 #[serde(rename_all = "camelCase")]
161 pub struct Runnable {
162     pub range: Range,
163     pub label: String,
164     pub bin: String,
165     pub args: Vec<String>,
166     pub env: FxHashMap<String, String>,
167     pub cwd: Option<String>,
168 }
169
170 #[derive(Serialize, Debug)]
171 #[serde(rename_all = "camelCase")]
172 pub struct SourceChange {
173     pub label: String,
174     pub workspace_edit: WorkspaceEdit,
175     pub cursor_position: Option<TextDocumentPositionParams>,
176 }
177
178 pub enum InlayHints {}
179
180 impl Request for InlayHints {
181     type Params = InlayHintsParams;
182     type Result = Vec<InlayHint>;
183     const METHOD: &'static str = "rust-analyzer/inlayHints";
184 }
185
186 #[derive(Serialize, Deserialize, Debug)]
187 #[serde(rename_all = "camelCase")]
188 pub struct InlayHintsParams {
189     pub text_document: TextDocumentIdentifier,
190 }
191
192 #[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
193 pub enum InlayKind {
194     TypeHint,
195 }
196
197 #[derive(Debug, Deserialize, Serialize)]
198 pub struct InlayHint {
199     pub range: Range,
200     pub kind: InlayKind,
201     pub label: String,
202 }