From 615c2d12a5a5e0ef3ab8227daeb35b977f4529a0 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Mon, 12 Aug 2024 10:16:23 -0400 Subject: [PATCH] Use `toggle` block style for code action instead of switch --- lib/ruby_lsp/requests/code_action_resolve.rb | 4 ++-- lib/ruby_lsp/requests/code_actions.rb | 4 ++-- .../code_action_resolve/aref_call_aref_assign.exp.json | 4 ++-- .../code_action_resolve/nested_block_calls.exp.json | 4 ++-- .../code_action_resolve/nested_oneline_blocks.exp.json | 4 ++-- test/expectations/code_actions/aref_field.exp.json | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/ruby_lsp/requests/code_action_resolve.rb b/lib/ruby_lsp/requests/code_action_resolve.rb index 68101d4a5..7880fd9d8 100644 --- a/lib/ruby_lsp/requests/code_action_resolve.rb +++ b/lib/ruby_lsp/requests/code_action_resolve.rb @@ -54,7 +54,7 @@ def perform refactor_variable when CodeActions::EXTRACT_TO_METHOD_TITLE refactor_method - when CodeActions::SWITCH_BLOCK_STYLE_TITLE + when CodeActions::TOGGLE_BLOCK_STYLE_TITLE switch_block_style else Error::UnknownCodeAction @@ -81,7 +81,7 @@ def switch_block_style indentation = " " * target.location.start_column unless node.opening_loc.slice == "do" Interface::CodeAction.new( - title: CodeActions::SWITCH_BLOCK_STYLE_TITLE, + title: CodeActions::TOGGLE_BLOCK_STYLE_TITLE, edit: Interface::WorkspaceEdit.new( document_changes: [ Interface::TextDocumentEdit.new( diff --git a/lib/ruby_lsp/requests/code_actions.rb b/lib/ruby_lsp/requests/code_actions.rb index f60aec7cf..4da1bd832 100644 --- a/lib/ruby_lsp/requests/code_actions.rb +++ b/lib/ruby_lsp/requests/code_actions.rb @@ -21,7 +21,7 @@ class CodeActions < Request EXTRACT_TO_VARIABLE_TITLE = "Refactor: Extract Variable" EXTRACT_TO_METHOD_TITLE = "Refactor: Extract Method" - SWITCH_BLOCK_STYLE_TITLE = "Refactor: Switch block style" + TOGGLE_BLOCK_STYLE_TITLE = "Refactor: Toggle block style" class << self extend T::Sig @@ -71,7 +71,7 @@ def perform data: { range: @range, uri: @uri.to_s }, ) code_actions << Interface::CodeAction.new( - title: SWITCH_BLOCK_STYLE_TITLE, + title: TOGGLE_BLOCK_STYLE_TITLE, kind: Constant::CodeActionKind::REFACTOR_REWRITE, data: { range: @range, uri: @uri.to_s }, ) diff --git a/test/expectations/code_action_resolve/aref_call_aref_assign.exp.json b/test/expectations/code_action_resolve/aref_call_aref_assign.exp.json index d9c668996..0242de2b7 100644 --- a/test/expectations/code_action_resolve/aref_call_aref_assign.exp.json +++ b/test/expectations/code_action_resolve/aref_call_aref_assign.exp.json @@ -1,7 +1,7 @@ { "params": { "kind": "refactor.rewrite", - "title": "Refactor: Switch block style", + "title": "Refactor: Toggle block style", "data": { "range": { "start": { @@ -17,7 +17,7 @@ } }, "result": { - "title": "Refactor: Switch block style", + "title": "Refactor: Toggle block style", "edit": { "documentChanges": [ { diff --git a/test/expectations/code_action_resolve/nested_block_calls.exp.json b/test/expectations/code_action_resolve/nested_block_calls.exp.json index ef1a59da8..ab3bd4a28 100644 --- a/test/expectations/code_action_resolve/nested_block_calls.exp.json +++ b/test/expectations/code_action_resolve/nested_block_calls.exp.json @@ -1,7 +1,7 @@ { "params": { "kind": "refactor.rewrite", - "title": "Refactor: Switch block style", + "title": "Refactor: Toggle block style", "data": { "range": { "start": { @@ -17,7 +17,7 @@ } }, "result": { - "title": "Refactor: Switch block style", + "title": "Refactor: Toggle block style", "edit": { "documentChanges": [ { diff --git a/test/expectations/code_action_resolve/nested_oneline_blocks.exp.json b/test/expectations/code_action_resolve/nested_oneline_blocks.exp.json index dfbe92ded..388ed3744 100644 --- a/test/expectations/code_action_resolve/nested_oneline_blocks.exp.json +++ b/test/expectations/code_action_resolve/nested_oneline_blocks.exp.json @@ -1,7 +1,7 @@ { "params": { "kind": "refactor.rewrite", - "title": "Refactor: Switch block style", + "title": "Refactor: Toggle block style", "data": { "range": { "start": { @@ -17,7 +17,7 @@ } }, "result": { - "title": "Refactor: Switch block style", + "title": "Refactor: Toggle block style", "edit": { "documentChanges": [ { diff --git a/test/expectations/code_actions/aref_field.exp.json b/test/expectations/code_actions/aref_field.exp.json index 4e7478c73..22fbe7a4b 100644 --- a/test/expectations/code_actions/aref_field.exp.json +++ b/test/expectations/code_actions/aref_field.exp.json @@ -54,7 +54,7 @@ } }, { - "title": "Refactor: Switch block style", + "title": "Refactor: Toggle block style", "kind": "refactor.rewrite", "data": { "range": {