1
- from __future__ import annotations
2
-
3
1
from collections import defaultdict
4
2
from dataclasses import dataclass
5
3
from string import Template as StringTemplate
@@ -91,7 +89,7 @@ class CodeActionData(CodeActionDataBase):
91
89
class RobotCodeActionQuickFixesProtocolPart (RobotLanguageServerProtocolPart , ModelHelperMixin , CodeActionHelperMixin ):
92
90
_logger = LoggingDescriptor ()
93
91
94
- def __init__ (self , parent : RobotLanguageServerProtocol ) -> None :
92
+ def __init__ (self , parent : " RobotLanguageServerProtocol" ) -> None :
95
93
super ().__init__ (parent )
96
94
97
95
parent .code_action .collect .add (self .collect )
@@ -101,12 +99,12 @@ def __init__(self, parent: RobotLanguageServerProtocol) -> None:
101
99
102
100
@language_id ("robotframework" )
103
101
@code_action_kinds ([CodeActionKind .QUICK_FIX ])
104
- async def collect (
102
+ def collect (
105
103
self , sender : Any , document : TextDocument , range : Range , context : CodeActionContext
106
104
) -> Optional [List [Union [Command , CodeAction ]]]:
107
105
result = []
108
106
for method in iter_methods (self , lambda m : m .__name__ .startswith ("code_action_" )):
109
- code_actions = await method (document , range , context )
107
+ code_actions = method (document , range , context )
110
108
if code_actions :
111
109
result .extend (code_actions )
112
110
@@ -115,17 +113,17 @@ async def collect(
115
113
116
114
return None
117
115
118
- async def resolve (self , sender : Any , code_action : CodeAction ) -> Optional [CodeAction ]:
116
+ def resolve (self , sender : Any , code_action : CodeAction ) -> Optional [CodeAction ]:
119
117
if code_action .data is not None and isinstance (code_action .data , Mapping ):
120
118
type = code_action .data .get ("type" , None )
121
119
if type == "quickfix" :
122
120
method_name = code_action .data .get ("method" )
123
121
method = next (iter_methods (self , lambda m : m .__name__ == f"resolve_code_action_{ method_name } " ))
124
- await method (code_action , data = from_dict (code_action .data , CodeActionData ))
122
+ method (code_action , data = from_dict (code_action .data , CodeActionData ))
125
123
126
124
return None
127
125
128
- async def code_action_create_keyword (
126
+ def code_action_create_keyword (
129
127
self , document : TextDocument , range : Range , context : CodeActionContext
130
128
) -> Optional [List [Union [Command , CodeAction ]]]:
131
129
result : List [Union [Command , CodeAction ]] = []
@@ -184,9 +182,7 @@ async def code_action_create_keyword(
184
182
185
183
return result if result else None
186
184
187
- async def resolve_code_action_create_keyword (
188
- self , code_action : CodeAction , data : CodeActionData
189
- ) -> Optional [CodeAction ]:
185
+ def resolve_code_action_create_keyword (self , code_action : CodeAction , data : CodeActionData ) -> Optional [CodeAction ]:
190
186
document = self .parent .documents .get (data .document_uri )
191
187
if document is None :
192
188
return None
@@ -240,7 +236,7 @@ async def resolve_code_action_create_keyword(
240
236
else :
241
237
dest_document = document
242
238
243
- code_action .edit , select_range = await self ._apply_create_keyword (dest_document , insert_text )
239
+ code_action .edit , select_range = self ._apply_create_keyword (dest_document , insert_text )
244
240
245
241
code_action .command = Command (
246
242
SHOW_DOCUMENT_SELECT_AND_RENAME_COMMAND ,
@@ -251,13 +247,11 @@ async def resolve_code_action_create_keyword(
251
247
252
248
return None
253
249
254
- async def _apply_create_keyword (self , document : TextDocument , insert_text : str ) -> Tuple [WorkspaceEdit , Range ]:
250
+ def _apply_create_keyword (self , document : TextDocument , insert_text : str ) -> Tuple [WorkspaceEdit , Range ]:
255
251
model = self .parent .documents_cache .get_model (document , False )
256
252
namespace = self .parent .documents_cache .get_namespace (document )
257
253
258
- insert_text , insert_range = await self .create_insert_keyword_workspace_edit (
259
- document , model , namespace , insert_text
260
- )
254
+ insert_text , insert_range = self .create_insert_keyword_workspace_edit (document , model , namespace , insert_text )
261
255
262
256
we = WorkspaceEdit (
263
257
document_changes = [
@@ -276,7 +270,7 @@ async def _apply_create_keyword(self, document: TextDocument, insert_text: str)
276
270
277
271
return we , selection_range
278
272
279
- async def code_action_disable_robotcode_diagnostics_for_line (
273
+ def code_action_disable_robotcode_diagnostics_for_line (
280
274
self , document : TextDocument , range : Range , context : CodeActionContext
281
275
) -> Optional [List [Union [Command , CodeAction ]]]:
282
276
if (
@@ -313,7 +307,7 @@ async def code_action_disable_robotcode_diagnostics_for_line(
313
307
314
308
return None
315
309
316
- async def resolve_code_action_disable_robotcode_diagnostics_for_line (
310
+ def resolve_code_action_disable_robotcode_diagnostics_for_line (
317
311
self , code_action : CodeAction , data : CodeActionData
318
312
) -> Optional [CodeAction ]:
319
313
if data .range .start .line == data .range .end .line and data .range .start .character <= data .range .end .character :
@@ -350,7 +344,7 @@ async def resolve_code_action_disable_robotcode_diagnostics_for_line(
350
344
351
345
return None
352
346
353
- async def code_action_create_local_variable (
347
+ def code_action_create_local_variable (
354
348
self , document : TextDocument , range : Range , context : CodeActionContext
355
349
) -> Optional [List [Union [Command , CodeAction ]]]:
356
350
result : List [Union [Command , CodeAction ]] = []
@@ -405,7 +399,7 @@ async def code_action_create_local_variable(
405
399
406
400
return result if result else None
407
401
408
- async def resolve_code_action_create_local_variable (
402
+ def resolve_code_action_create_local_variable (
409
403
self , code_action : CodeAction , data : CodeActionData
410
404
) -> Optional [CodeAction ]:
411
405
if data .range .start .line == data .range .end .line and data .range .start .character <= data .range .end .character :
@@ -457,7 +451,7 @@ async def resolve_code_action_create_local_variable(
457
451
458
452
return None
459
453
460
- async def code_action_create_suite_variable (
454
+ def code_action_create_suite_variable (
461
455
self , document : TextDocument , range : Range , context : CodeActionContext
462
456
) -> Optional [List [Union [Command , CodeAction ]]]:
463
457
result : List [Union [Command , CodeAction ]] = []
@@ -499,7 +493,7 @@ async def code_action_create_suite_variable(
499
493
500
494
return result if result else None
501
495
502
- async def resolve_code_action_create_suite_variable (
496
+ def resolve_code_action_create_suite_variable (
503
497
self , code_action : CodeAction , data : CodeActionData
504
498
) -> Optional [CodeAction ]:
505
499
if data .range .start .line == data .range .end .line and data .range .start .character <= data .range .end .character :
@@ -589,7 +583,7 @@ async def resolve_code_action_create_suite_variable(
589
583
return code_action
590
584
return None
591
585
592
- async def code_action_add_argument (
586
+ def code_action_add_argument (
593
587
self , document : TextDocument , range : Range , context : CodeActionContext
594
588
) -> Optional [List [Union [Command , CodeAction ]]]:
595
589
result : List [Union [Command , CodeAction ]] = []
@@ -638,9 +632,7 @@ async def code_action_add_argument(
638
632
639
633
return result if result else None
640
634
641
- async def resolve_code_action_add_argument (
642
- self , code_action : CodeAction , data : CodeActionData
643
- ) -> Optional [CodeAction ]:
635
+ def resolve_code_action_add_argument (self , code_action : CodeAction , data : CodeActionData ) -> Optional [CodeAction ]:
644
636
if data .range .start .line == data .range .end .line and data .range .start .character <= data .range .end .character :
645
637
document = self .parent .documents .get (data .document_uri )
646
638
if document is None :
0 commit comments