|
42 | 42 | if TYPE_CHECKING:
|
43 | 43 | from robotcode.language_server.robotframework.protocol import RobotLanguageServerProtocol # pragma: no cover
|
44 | 44 |
|
45 |
| -QUICK_FIX_OTHER = "other" |
46 | 45 |
|
47 | 46 | KEYWORD_WITH_ARGS_TEMPLATE = Template(
|
48 | 47 | """\
|
@@ -109,7 +108,7 @@ def __init__(self, parent: RobotLanguageServerProtocol) -> None:
|
109 | 108 | self.parent.commands.register_all(self)
|
110 | 109 |
|
111 | 110 | @language_id("robotframework")
|
112 |
| - @code_action_kinds([CodeActionKind.QUICK_FIX, QUICK_FIX_OTHER]) |
| 111 | + @code_action_kinds([CodeActionKind.QUICK_FIX]) |
113 | 112 | async def collect(
|
114 | 113 | self, sender: Any, document: TextDocument, range: Range, context: CodeActionContext
|
115 | 114 | ) -> Optional[List[Union[Command, CodeAction]]]:
|
@@ -308,100 +307,6 @@ async def _apply_create_keyword(self, document: TextDocument, insert_text: str)
|
308 | 307 | insert_range.end.character += len(lines[-1])
|
309 | 308 | await self.parent.window.show_document(str(document.uri), take_focus=True, selection=insert_range)
|
310 | 309 |
|
311 |
| - async def code_action_assign_result_to_variable( |
312 |
| - self, document: TextDocument, range: Range, context: CodeActionContext |
313 |
| - ) -> Optional[List[Union[Command, CodeAction]]]: |
314 |
| - from robot.parsing.lexer import Token as RobotToken |
315 |
| - from robot.parsing.model.statements import ( |
316 |
| - Fixture, |
317 |
| - KeywordCall, |
318 |
| - Template, |
319 |
| - TestTemplate, |
320 |
| - ) |
321 |
| - |
322 |
| - if range.start.line == range.end.line and ( |
323 |
| - (context.only and QUICK_FIX_OTHER in context.only) |
324 |
| - or context.trigger_kind |
325 |
| - in [ |
326 |
| - CodeActionTriggerKind.INVOKED, |
327 |
| - CodeActionTriggerKind.AUTOMATIC, |
328 |
| - ] |
329 |
| - ): |
330 |
| - model = await self.parent.documents_cache.get_model(document, False) |
331 |
| - node = await get_node_at_position(model, range.start) |
332 |
| - |
333 |
| - if not isinstance(node, KeywordCall) or node.assign: |
334 |
| - return None |
335 |
| - |
336 |
| - keyword_token = ( |
337 |
| - node.get_token(RobotToken.NAME) |
338 |
| - if isinstance(node, (TestTemplate, Template, Fixture)) |
339 |
| - else node.get_token(RobotToken.KEYWORD) |
340 |
| - ) |
341 |
| - |
342 |
| - if keyword_token is None or range.start not in range_from_token(keyword_token): |
343 |
| - return None |
344 |
| - |
345 |
| - return [ |
346 |
| - CodeAction( |
347 |
| - "Assign result to variable", |
348 |
| - kind=QUICK_FIX_OTHER, |
349 |
| - command=Command( |
350 |
| - self.parent.commands.get_command_name(self.assign_result_to_variable_command), |
351 |
| - self.parent.commands.get_command_name(self.assign_result_to_variable_command), |
352 |
| - [document.document_uri, range], |
353 |
| - ), |
354 |
| - ) |
355 |
| - ] |
356 |
| - |
357 |
| - return None |
358 |
| - |
359 |
| - @command("robotcode.assignResultToVariable") |
360 |
| - async def assign_result_to_variable_command(self, document_uri: DocumentUri, range: Range) -> None: |
361 |
| - from robot.parsing.lexer import Token as RobotToken |
362 |
| - from robot.parsing.model.statements import ( |
363 |
| - Fixture, |
364 |
| - KeywordCall, |
365 |
| - Template, |
366 |
| - TestTemplate, |
367 |
| - ) |
368 |
| - |
369 |
| - if range.start.line == range.end.line and range.start.character <= range.end.character: |
370 |
| - document = await self.parent.documents.get(document_uri) |
371 |
| - if document is None: |
372 |
| - return |
373 |
| - |
374 |
| - model = await self.parent.documents_cache.get_model(document, False) |
375 |
| - node = await get_node_at_position(model, range.start) |
376 |
| - |
377 |
| - if not isinstance(node, KeywordCall) or node.assign: |
378 |
| - return |
379 |
| - |
380 |
| - keyword_token = ( |
381 |
| - node.get_token(RobotToken.NAME) |
382 |
| - if isinstance(node, (TestTemplate, Template, Fixture)) |
383 |
| - else node.get_token(RobotToken.KEYWORD) |
384 |
| - ) |
385 |
| - |
386 |
| - if keyword_token is None or range.start not in range_from_token(keyword_token): |
387 |
| - return |
388 |
| - |
389 |
| - start = range_from_token(keyword_token).start |
390 |
| - we = WorkspaceEdit( |
391 |
| - document_changes=[ |
392 |
| - TextDocumentEdit( |
393 |
| - OptionalVersionedTextDocumentIdentifier(str(document.uri), document.version), |
394 |
| - [AnnotatedTextEdit("assign_result_to_variable", Range(start, start), "${result} ")], |
395 |
| - ) |
396 |
| - ], |
397 |
| - change_annotations={"assign_result_to_variable": ChangeAnnotation("Assign result to variable", False)}, |
398 |
| - ) |
399 |
| - |
400 |
| - if (await self.parent.workspace.apply_edit(we)).applied: |
401 |
| - insert_range = Range(start, start).extend(start_character=2, end_character=8) |
402 |
| - |
403 |
| - await self.parent.window.show_document(str(document.uri), take_focus=True, selection=insert_range) |
404 |
| - |
405 | 310 | async def code_action_disable_robotcode_diagnostics_for_line(
|
406 | 311 | self, document: TextDocument, range: Range, context: CodeActionContext
|
407 | 312 | ) -> Optional[List[Union[Command, CodeAction]]]:
|
|
0 commit comments