class RubyLsp::Requests::CodeActionResolve
def switch_block_style
def switch_block_style source_range = @code_action.dig(:data, :range) raise EmptySelectionError, "Invalid selection for refactor" if source_range[:start] == source_range[:end] target = @document.locate_first_within_range( @code_action.dig(:data, :range), node_types: [Prism::CallNode], ) unless target.is_a?(Prism::CallNode) raise InvalidTargetRangeError, "Couldn't find an appropriate location to place extracted refactor" end node = target.block unless node.is_a?(Prism::BlockNode) raise InvalidTargetRangeError, "Couldn't find an appropriate location to place extracted refactor" end indentation = " " * target.location.start_column unless node.opening_loc.slice == "do" Interface::CodeAction.new( title: CodeActions::TOGGLE_BLOCK_STYLE_TITLE, edit: Interface::WorkspaceEdit.new( document_changes: [ Interface::TextDocumentEdit.new( text_document: Interface::OptionalVersionedTextDocumentIdentifier.new( uri: @code_action.dig(:data, :uri), version: nil, ), edits: [ Interface::TextEdit.new( range: range_from_location(node.location), new_text: recursively_switch_nested_block_styles(node, indentation), ), ], ), ], ), ) end