@@ -289,9 +289,12 @@ fn completion_item_from_assignment(
289
289
let label = lhs. utf8_text ( context. source . as_bytes ( ) ) ?;
290
290
291
291
// TODO: Resolve functions that exist in-document here.
292
- let mut item = completion_item ( label, CompletionData :: ScopeVariable {
293
- name : label. to_string ( ) ,
294
- } ) ?;
292
+ let mut item = completion_item (
293
+ label,
294
+ CompletionData :: ScopeVariable {
295
+ name : label. to_string ( ) ,
296
+ } ,
297
+ ) ?;
295
298
296
299
let markup = MarkupContent {
297
300
kind : MarkupKind :: Markdown ,
@@ -323,9 +326,12 @@ unsafe fn completion_item_from_package(
323
326
package : & str ,
324
327
append_colons : bool ,
325
328
) -> Result < CompletionItem > {
326
- let mut item = completion_item ( package. to_string ( ) , CompletionData :: Package {
327
- name : package. to_string ( ) ,
328
- } ) ?;
329
+ let mut item = completion_item (
330
+ package. to_string ( ) ,
331
+ CompletionData :: Package {
332
+ name : package. to_string ( ) ,
333
+ } ,
334
+ ) ?;
329
335
330
336
item. kind = Some ( CompletionItemKind :: MODULE ) ;
331
337
@@ -348,10 +354,13 @@ pub fn completion_item_from_function<T: AsRef<str>>(
348
354
parameters : & [ T ] ,
349
355
) -> Result < CompletionItem > {
350
356
let label = format ! ( "{}" , name) ;
351
- let mut item = completion_item ( label, CompletionData :: Function {
352
- name : name. to_string ( ) ,
353
- package : package. map ( |s| s. to_string ( ) ) ,
354
- } ) ?;
357
+ let mut item = completion_item (
358
+ label,
359
+ CompletionData :: Function {
360
+ name : name. to_string ( ) ,
361
+ package : package. map ( |s| s. to_string ( ) ) ,
362
+ } ,
363
+ ) ?;
355
364
356
365
item. kind = Some ( CompletionItemKind :: FUNCTION ) ;
357
366
@@ -386,10 +395,13 @@ unsafe fn completion_item_from_data_variable(
386
395
owner : & str ,
387
396
enquote : bool ,
388
397
) -> Result < CompletionItem > {
389
- let mut item = completion_item ( name. to_string ( ) , CompletionData :: DataVariable {
390
- name : name. to_string ( ) ,
391
- owner : owner. to_string ( ) ,
392
- } ) ?;
398
+ let mut item = completion_item (
399
+ name. to_string ( ) ,
400
+ CompletionData :: DataVariable {
401
+ name : name. to_string ( ) ,
402
+ owner : owner. to_string ( ) ,
403
+ } ,
404
+ ) ?;
393
405
394
406
if enquote {
395
407
item. insert_text = Some ( format ! ( "\" {}\" " , name) ) ;
@@ -426,9 +438,12 @@ unsafe fn completion_item_from_object(
426
438
return completion_item_from_function ( name, package, & arguments) ;
427
439
}
428
440
429
- let mut item = completion_item ( name, CompletionData :: Object {
430
- name : name. to_string ( ) ,
431
- } ) ?;
441
+ let mut item = completion_item (
442
+ name,
443
+ CompletionData :: Object {
444
+ name : name. to_string ( ) ,
445
+ } ,
446
+ ) ?;
432
447
433
448
item. detail = Some ( "(Object)" . to_string ( ) ) ;
434
449
item. kind = Some ( CompletionItemKind :: STRUCT ) ;
@@ -462,9 +477,12 @@ unsafe fn completion_item_from_promise(
462
477
463
478
// Otherwise we never want to force promises, so we return a fairly
464
479
// generic completion item
465
- let mut item = completion_item ( name, CompletionData :: Object {
466
- name : name. to_string ( ) ,
467
- } ) ?;
480
+ let mut item = completion_item (
481
+ name,
482
+ CompletionData :: Object {
483
+ name : name. to_string ( ) ,
484
+ } ,
485
+ ) ?;
468
486
469
487
item. detail = Some ( "Promise" . to_string ( ) ) ;
470
488
item. kind = Some ( CompletionItemKind :: STRUCT ) ;
@@ -475,9 +493,12 @@ unsafe fn completion_item_from_promise(
475
493
fn completion_item_from_active_binding ( name : & str ) -> Result < CompletionItem > {
476
494
// We never want to force active bindings, so we return a fairly
477
495
// generic completion item
478
- let mut item = completion_item ( name, CompletionData :: Object {
479
- name : name. to_string ( ) ,
480
- } ) ?;
496
+ let mut item = completion_item (
497
+ name,
498
+ CompletionData :: Object {
499
+ name : name. to_string ( ) ,
500
+ } ,
501
+ ) ?;
481
502
482
503
item. detail = Some ( "Active binding" . to_string ( ) ) ;
483
504
item. kind = Some ( CompletionItemKind :: STRUCT ) ;
@@ -574,20 +595,26 @@ fn completion_item_from_scope_parameter(
574
595
parameter : & str ,
575
596
_context : & CompletionContext ,
576
597
) -> Result < CompletionItem > {
577
- let mut item = completion_item ( parameter, CompletionData :: ScopeParameter {
578
- name : parameter. to_string ( ) ,
579
- } ) ?;
598
+ let mut item = completion_item (
599
+ parameter,
600
+ CompletionData :: ScopeParameter {
601
+ name : parameter. to_string ( ) ,
602
+ } ,
603
+ ) ?;
580
604
581
605
item. kind = Some ( CompletionItemKind :: VARIABLE ) ;
582
606
Ok ( item)
583
607
}
584
608
585
609
unsafe fn completion_item_from_parameter ( parameter : & str , callee : & str ) -> Result < CompletionItem > {
586
610
let label = r_symbol_quote_invalid ( parameter) ;
587
- let mut item = completion_item ( label, CompletionData :: Parameter {
588
- name : parameter. to_string ( ) ,
589
- function : callee. to_string ( ) ,
590
- } ) ?;
611
+ let mut item = completion_item (
612
+ label,
613
+ CompletionData :: Parameter {
614
+ name : parameter. to_string ( ) ,
615
+ function : callee. to_string ( ) ,
616
+ } ,
617
+ ) ?;
591
618
592
619
// TODO: It'd be nice if we could be smarter about how '...' completions are handled,
593
620
// but evidently VSCode doesn't let us set an empty 'insert text' string here.
@@ -744,9 +771,12 @@ unsafe fn append_subset_completions(
744
771
) -> Result < ( ) > {
745
772
info ! ( "append_subset_completions({:?})" , callee) ;
746
773
747
- let value = r_parse_eval ( callee, RParseEvalOptions {
748
- forbid_function_calls : true ,
749
- } ) ?;
774
+ let value = r_parse_eval (
775
+ callee,
776
+ RParseEvalOptions {
777
+ forbid_function_calls : true ,
778
+ } ,
779
+ ) ?;
750
780
751
781
let names = RFunction :: new ( "base" , "names" )
752
782
. add ( value)
@@ -941,9 +971,12 @@ unsafe fn append_pipe_completions(
941
971
return Ok ( ( ) ) ;
942
972
} ) ;
943
973
944
- let value = r_parse_eval ( root, RParseEvalOptions {
945
- forbid_function_calls : true ,
946
- } ) ?;
974
+ let value = r_parse_eval (
975
+ root,
976
+ RParseEvalOptions {
977
+ forbid_function_calls : true ,
978
+ } ,
979
+ ) ?;
947
980
948
981
// Try to retrieve names from the resulting item
949
982
let names = RFunction :: new ( "base" , "names" )
@@ -987,14 +1020,20 @@ unsafe fn append_argument_completions(
987
1020
}
988
1021
989
1022
// Otherwise, try to retrieve completion names from the object itself.
990
- let r_callable = r_parse_eval ( callable, RParseEvalOptions {
991
- forbid_function_calls : true ,
992
- } ) ?;
1023
+ let r_callable = r_parse_eval (
1024
+ callable,
1025
+ RParseEvalOptions {
1026
+ forbid_function_calls : true ,
1027
+ } ,
1028
+ ) ?;
993
1029
994
1030
let r_object = if let Some ( object) = object {
995
- r_parse_eval ( object, RParseEvalOptions {
996
- forbid_function_calls : true ,
997
- } ) ?
1031
+ r_parse_eval (
1032
+ object,
1033
+ RParseEvalOptions {
1034
+ forbid_function_calls : true ,
1035
+ } ,
1036
+ ) ?
998
1037
} else {
999
1038
RObject :: null ( )
1000
1039
} ;
@@ -1098,9 +1137,12 @@ fn append_keyword_completions(completions: &mut Vec<CompletionItem>) -> anyhow::
1098
1137
1099
1138
for snippet in snippets {
1100
1139
let label = snippet. 0 . to_string ( ) ;
1101
- let mut item = completion_item ( label. to_string ( ) , CompletionData :: Snippet {
1102
- text : label. clone ( ) ,
1103
- } ) ?;
1140
+ let mut item = completion_item (
1141
+ label. to_string ( ) ,
1142
+ CompletionData :: Snippet {
1143
+ text : label. clone ( ) ,
1144
+ } ,
1145
+ ) ?;
1104
1146
1105
1147
item. detail = Some ( "[keyword]" . to_string ( ) ) ;
1106
1148
item. insert_text_format = Some ( InsertTextFormat :: SNIPPET ) ;
@@ -1247,9 +1289,10 @@ unsafe fn append_roxygen_completions(
1247
1289
} ) ;
1248
1290
1249
1291
let label = name. to_string ( ) ;
1250
- let mut item = completion_item ( label. clone ( ) , CompletionData :: RoxygenTag {
1251
- tag : label. clone ( ) ,
1252
- } ) ?;
1292
+ let mut item = completion_item (
1293
+ label. clone ( ) ,
1294
+ CompletionData :: RoxygenTag { tag : label. clone ( ) } ,
1295
+ ) ?;
1253
1296
1254
1297
// TODO: What is the appropriate icon for us to use here?
1255
1298
let template = entry[ "template" ] . as_str ( ) ;
0 commit comments