class TypeProf::LSP::Message::Workspace::ExecuteCommand
Constants
- METHOD
Public Instance Methods
run()
click to toggle source
# File typeprof-0.21.3/lib/typeprof/lsp.rb, line 498 def run case @params[:command] when "typeprof.enableSignature" @server.signature_enabled = true @server.send_request("workspace/codeLens/refresh") respond(nil) when "typeprof.disableSignature" @server.signature_enabled = false @server.send_request("workspace/codeLens/refresh") respond(nil) when "typeprof.createPrototypeRBS" class_kind, class_name, sig_str = @params[:arguments] code_range = CodeRange.new( CodeLocation.new(1, 0), CodeLocation.new(1, 0), ) text = [] text << "#{ class_kind } #{ class_name.join("::") }\n" text << " #{ sig_str }\n" text << "end\n\n" text = text.join @server.send_request( "workspace/applyEdit", edit: { changes: { @server.root_uri + "/typeprof.rbs" => [ { range: code_range.to_lsp, newText: text, } ], }, }, ) do |res| code_range = CodeRange.new( CodeLocation.new(1, 0), CodeLocation.new(3, 3), # 3 = "end".size ) @server.send_request( "window/showDocument", uri: @server.root_uri + "/typeprof.rbs", takeFocus: true, selection: code_range.to_lsp, ) end respond(nil) else respond_error( code: ErrorCodes::InvalidRequest, message: "Unknown command: #{ @params[:command] }", ) end end