-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathlspExtensions.ts
205 lines (174 loc) · 5.16 KB
/
lspExtensions.ts
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//===----------------------------------------------------------------------===//
//
// This source file is part of the VS Code Swift open source project
//
// Copyright (c) 2021-2024 the VS Code Swift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import * as ls from "vscode-languageserver-protocol";
import * as langclient from "vscode-languageclient/node";
import * as vscode from "vscode";
// Definitions for non-standard requests used by sourcekit-lsp
// Peek Documents
export interface PeekDocumentsParams {
/**
* The `DocumentUri` of the text document in which to show the "peeked" editor
*/
uri: langclient.DocumentUri;
/**
* The `Position` in the given text document in which to show the "peeked editor"
*/
position: vscode.Position;
/**
* An array `DocumentUri` of the documents to appear inside the "peeked" editor
*/
locations: langclient.DocumentUri[];
}
/**
* Response to indicate the `success` of the `PeekDocumentsRequest`
*/
export interface PeekDocumentsResult {
success: boolean;
}
/**
* Request from the server to the client to show the given documents in a "peeked" editor.
*
* This request is handled by the client to show the given documents in a "peeked" editor (i.e. inline with / inside the editor canvas).
*
* It requires the experimental client capability `"workspace/peekDocuments"` to use.
*/
export const PeekDocumentsRequest = new langclient.RequestType<
PeekDocumentsParams,
PeekDocumentsResult,
unknown
>("workspace/peekDocuments");
// Get Reference Document
export interface LegacyGetReferenceDocumentParams {
/**
* The `DocumentUri` of the custom scheme url for which content is required
*/
uri: langclient.DocumentUri;
}
/**
* Response containing `content` of `GetReferenceDocumentRequest`
*/
export interface LegacyGetReferenceDocumentResult {
content: string;
}
/**
* Request from the client to the server asking for contents of a URI having a custom scheme
* For example: "sourcekit-lsp:"
*/
export const LegacyGetReferenceDocumentRequest = new langclient.RequestType<
LegacyGetReferenceDocumentParams,
LegacyGetReferenceDocumentResult,
unknown
>("workspace/getReferenceDocument");
// Inlay Hints (pre Swift 5.6)
export interface LegacyInlayHintsParams {
/**
* The text document.
*/
textDocument: langclient.TextDocumentIdentifier;
/**
* If set, the reange for which inlay hints are
* requested. If unset, hints for the entire document
* are returned.
*/
range?: langclient.Range;
/**
* The categories of inlay hints that are requested.
* If unset, all categories are returned.
*/
only?: string[];
}
export interface LegacyInlayHint {
/**
* The position within the code that this hint is
* attached to.
*/
position: langclient.Position;
/**
* The hint's kind, used for more flexible client-side
* styling of the hint.
*/
category?: string;
/**
* The hint's rendered label.
*/
label: string;
}
export const legacyInlayHintsRequest = new langclient.RequestType<
LegacyInlayHintsParams,
LegacyInlayHint[],
unknown
>("sourcekit-lsp/inlayHints");
// Test styles where test-target represents a test target that contains tests
export type TestStyle = "XCTest" | "swift-testing" | "test-target";
// Listing tests
export interface LSPTestItem {
/**
* This identifier uniquely identifies the test case or test suite. It can be used to run an individual test (suite).
*/
id: string;
/**
* Display name describing the test.
*/
label: string;
/**
* Optional description that appears next to the label.
*/
description?: string;
/**
* A string that should be used when comparing this item with other items.
*
* When `undefined` the `label` is used.
*/
sortText?: string;
/**
* Whether the test is disabled.
*/
disabled: boolean;
/**
* The type of test, eg. the testing framework that was used to declare the test.
*/
style: TestStyle;
/**
* The location of the test item in the source code.
*/
location: ls.Location;
/**
* The children of this test item.
*
* For a test suite, this may contain the individual test cases or nested suites.
*/
children: LSPTestItem[];
/**
* Tags associated with this test item.
*/
tags: { id: string }[];
}
export const workspaceTestsRequest = new langclient.RequestType<
Record<string, never>,
LSPTestItem[],
unknown
>("workspace/tests");
interface DocumentTestsParams {
textDocument: {
uri: ls.URI;
};
}
export const textDocumentTestsRequest = new langclient.RequestType<
DocumentTestsParams,
LSPTestItem[],
unknown
>("textDocument/tests");
export const reindexProjectRequest = new langclient.RequestType<null, unknown, unknown>(
"workspace/triggerReindex"
);