lib/ruby_lsp/requests/support/common.rb in ruby-lsp-0.4.5 vs lib/ruby_lsp/requests/support/common.rb in ruby-lsp-0.5.0

- old
+ new

@@ -47,9 +47,45 @@ return false if node.nil? loc = node.location range.cover?(loc.start_line - 1) && range.cover?(loc.end_line - 1) end + + sig do + params( + node: SyntaxTree::Node, + title: String, + command_name: String, + path: String, + name: String, + test_command: String, + type: String, + ).returns(Interface::CodeLens) + end + def create_code_lens(node, title:, command_name:, path:, name:, test_command:, type:) + range = range_from_syntax_tree_node(node) + arguments = [ + path, + name, + test_command, + { + start_line: node.location.start_line - 1, + start_column: node.location.start_column, + end_line: node.location.end_line - 1, + end_column: node.location.end_column, + }, + ] + + Interface::CodeLens.new( + range: range, + command: Interface::Command.new( + title: title, + command: command_name, + arguments: arguments, + ), + data: { type: type }, + ) + end end end end end