@@ -34,21 +34,24 @@ export const LINKED_COMMANDS = new Map<string, ra.CommandLink>();
34
34
// add code to remove a target command from the map after the link is
35
35
// clicked, but assuming most links in hover sheets won't be clicked anyway
36
36
// this code won't change the overall memory use much.
37
- setInterval ( function cleanupOlderCommandLinks ( ) {
38
- // keys are returned in insertion order, we'll keep a few
39
- // of recent keys available, and clean the rest
40
- const keys = [ ...LINKED_COMMANDS . keys ( ) ] ;
41
- const keysToRemove = keys . slice ( 0 , keys . length - 10 ) ;
42
- for ( const key of keysToRemove ) {
43
- LINKED_COMMANDS . delete ( key ) ;
44
- }
45
- } , 10 * 60 * 1000 ) ;
37
+ setInterval (
38
+ function cleanupOlderCommandLinks ( ) {
39
+ // keys are returned in insertion order, we'll keep a few
40
+ // of recent keys available, and clean the rest
41
+ const keys = [ ...LINKED_COMMANDS . keys ( ) ] ;
42
+ const keysToRemove = keys . slice ( 0 , keys . length - 10 ) ;
43
+ for ( const key of keysToRemove ) {
44
+ LINKED_COMMANDS . delete ( key ) ;
45
+ }
46
+ } ,
47
+ 10 * 60 * 1000 ,
48
+ ) ;
46
49
47
50
function renderCommand ( cmd : ra . CommandLink ) : string {
48
51
const commandId = randomUUID ( ) ;
49
52
LINKED_COMMANDS . set ( commandId , cmd ) ;
50
53
return `[${ cmd . title } ](command:rust-analyzer.linkToCommand?${ encodeURIComponent (
51
- JSON . stringify ( [ commandId ] )
54
+ JSON . stringify ( [ commandId ] ) ,
52
55
) } '${ cmd . tooltip } ')`;
53
56
}
54
57
@@ -57,7 +60,7 @@ function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownStri
57
60
. map (
58
61
( group ) =>
59
62
( group . title ? group . title + " " : "" ) +
60
- group . commands . map ( renderCommand ) . join ( " | " )
63
+ group . commands . map ( renderCommand ) . join ( " | " ) ,
61
64
)
62
65
. join ( "___" ) ;
63
66
@@ -72,7 +75,7 @@ export async function createClient(
72
75
initializationOptions : vscode . WorkspaceConfiguration ,
73
76
serverOptions : lc . ServerOptions ,
74
77
config : Config ,
75
- unlinkedFiles : vscode . Uri [ ]
78
+ unlinkedFiles : vscode . Uri [ ] ,
76
79
) : Promise < lc . LanguageClient > {
77
80
const clientOptions : lc . LanguageClientOptions = {
78
81
documentSelector : [ { scheme : "file" , language : "rust" } ] ,
@@ -93,7 +96,7 @@ export async function createClient(
93
96
async configuration (
94
97
params : lc . ConfigurationParams ,
95
98
token : vscode . CancellationToken ,
96
- next : lc . ConfigurationRequest . HandlerSignature
99
+ next : lc . ConfigurationRequest . HandlerSignature ,
97
100
) {
98
101
const resp = await next ( params , token ) ;
99
102
if ( resp && Array . isArray ( resp ) ) {
@@ -117,7 +120,7 @@ export async function createClient(
117
120
async handleDiagnostics (
118
121
uri : vscode . Uri ,
119
122
diagnosticList : vscode . Diagnostic [ ] ,
120
- next : lc . HandleDiagnosticsSignature
123
+ next : lc . HandleDiagnosticsSignature ,
121
124
) {
122
125
const preview = config . previewRustcOutput ;
123
126
const errorCode = config . useRustcErrorCode ;
@@ -137,20 +140,20 @@ export async function createClient(
137
140
const folder = vscode . workspace . getWorkspaceFolder ( uri ) ?. uri . fsPath ;
138
141
if ( folder ) {
139
142
const parentBackslash = uri . fsPath . lastIndexOf (
140
- pathSeparator + "src"
143
+ pathSeparator + "src" ,
141
144
) ;
142
145
const parent = uri . fsPath . substring ( 0 , parentBackslash ) ;
143
146
144
147
if ( parent . startsWith ( folder ) ) {
145
148
const path = vscode . Uri . file (
146
- parent + pathSeparator + "Cargo.toml"
149
+ parent + pathSeparator + "Cargo.toml" ,
147
150
) ;
148
151
void vscode . workspace . fs . stat ( path ) . then ( async ( ) => {
149
152
const choice = await vscode . window . showInformationMessage (
150
153
`This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${ path . path } , do you want to add it to the linked Projects?` ,
151
154
"Yes" ,
152
155
"No" ,
153
- "Don't show this again"
156
+ "Don't show this again" ,
154
157
) ;
155
158
switch ( choice ) {
156
159
case undefined :
@@ -168,14 +171,14 @@ export async function createClient(
168
171
config
169
172
. get < any [ ] > ( "linkedProjects" )
170
173
?. concat ( pathToInsert ) ,
171
- false
174
+ false ,
172
175
) ;
173
176
break ;
174
177
case "Don't show this again" :
175
178
await config . update (
176
179
"showUnlinkedFileNotification" ,
177
180
false ,
178
- false
181
+ false ,
179
182
) ;
180
183
break ;
181
184
}
@@ -222,7 +225,7 @@ export async function createClient(
222
225
document : vscode . TextDocument ,
223
226
position : vscode . Position ,
224
227
token : vscode . CancellationToken ,
225
- _next : lc . ProvideHoverSignature
228
+ _next : lc . ProvideHoverSignature ,
226
229
) {
227
230
const editor = vscode . window . activeTextEditor ;
228
231
const positionOrRange = editor ?. selection ?. contains ( position )
@@ -236,7 +239,7 @@ export async function createClient(
236
239
client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ,
237
240
position : positionOrRange ,
238
241
} ,
239
- token
242
+ token ,
240
243
)
241
244
. then (
242
245
( result ) => {
@@ -250,7 +253,7 @@ export async function createClient(
250
253
( error ) => {
251
254
client . handleFailedRequest ( lc . HoverRequest . type , token , error , null ) ;
252
255
return Promise . resolve ( null ) ;
253
- }
256
+ } ,
254
257
) ;
255
258
} ,
256
259
// Using custom handling of CodeActions to support action groups and snippet edits.
@@ -260,14 +263,14 @@ export async function createClient(
260
263
range : vscode . Range ,
261
264
context : vscode . CodeActionContext ,
262
265
token : vscode . CancellationToken ,
263
- _next : lc . ProvideCodeActionsSignature
266
+ _next : lc . ProvideCodeActionsSignature ,
264
267
) {
265
268
const params : lc . CodeActionParams = {
266
269
textDocument : client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ,
267
270
range : client . code2ProtocolConverter . asRange ( range ) ,
268
271
context : await client . code2ProtocolConverter . asCodeActionContext (
269
272
context ,
270
- token
273
+ token ,
271
274
) ,
272
275
} ;
273
276
return client . sendRequest ( lc . CodeActionRequest . type , params , token ) . then (
@@ -283,21 +286,21 @@ export async function createClient(
283
286
if ( lc . CodeAction . is ( item ) ) {
284
287
assert (
285
288
! item . command ,
286
- "We don't expect to receive commands in CodeActions"
289
+ "We don't expect to receive commands in CodeActions" ,
287
290
) ;
288
291
const action = await client . protocol2CodeConverter . asCodeAction (
289
292
item ,
290
- token
293
+ token ,
291
294
) ;
292
295
result . push ( action ) ;
293
296
continue ;
294
297
}
295
298
assert (
296
299
isCodeActionWithoutEditsAndCommands ( item ) ,
297
- "We don't expect edits or commands here"
300
+ "We don't expect edits or commands here" ,
298
301
) ;
299
302
const kind = client . protocol2CodeConverter . asCodeActionKind (
300
- ( item as any ) . kind
303
+ ( item as any ) . kind ,
301
304
) ;
302
305
const action = new vscode . CodeAction ( item . title , kind ) ;
303
306
const group = ( item as any ) . group ;
@@ -351,7 +354,7 @@ export async function createClient(
351
354
}
352
355
return result ;
353
356
} ,
354
- ( _error ) => undefined
357
+ ( _error ) => undefined ,
355
358
) ;
356
359
} ,
357
360
} ,
@@ -364,7 +367,7 @@ export async function createClient(
364
367
"rust-analyzer" ,
365
368
"Rust Analyzer Language Server" ,
366
369
serverOptions ,
367
- clientOptions
370
+ clientOptions ,
368
371
) ;
369
372
370
373
// To turn on all proposed features use: client.registerProposedFeatures();
@@ -400,7 +403,7 @@ class ExperimentalFeatures implements lc.StaticFeature {
400
403
}
401
404
initialize (
402
405
_capabilities : lc . ServerCapabilities ,
403
- _documentSelector : lc . DocumentSelector | undefined
406
+ _documentSelector : lc . DocumentSelector | undefined ,
404
407
) : void { }
405
408
dispose ( ) : void { }
406
409
}
@@ -419,7 +422,7 @@ class OverrideFeatures implements lc.StaticFeature {
419
422
}
420
423
initialize (
421
424
_capabilities : lc . ServerCapabilities ,
422
- _documentSelector : lc . DocumentSelector | undefined
425
+ _documentSelector : lc . DocumentSelector | undefined ,
423
426
) : void { }
424
427
dispose ( ) : void { }
425
428
}
0 commit comments