lsp-rename: minor cosmetic cleanups
This commit is contained in:
parent
860c36266c
commit
bfdeffc70f
3 changed files with 14 additions and 10 deletions
|
@ -807,9 +807,9 @@ pub fn rename_symbol(self: *Self, from: tp.pid_ref, file_path: []const u8, row:
|
||||||
if (try cbor.match(response.buf, .{ tp.any, tp.any, tp.any, tp.extract_cbor(&result) })) {
|
if (try cbor.match(response.buf, .{ tp.any, tp.any, tp.any, tp.extract_cbor(&result) })) {
|
||||||
try self.decode_rename_symbol_map(result, &renames);
|
try self.decode_rename_symbol_map(result, &renames);
|
||||||
// write the renames message manually since there doesn't appear to be an array helper
|
// write the renames message manually since there doesn't appear to be an array helper
|
||||||
var m = std.ArrayList(u8).init(self.allocator);
|
var msg_buf = std.ArrayList(u8).init(self.allocator);
|
||||||
const w = m.writer();
|
defer msg_buf.deinit();
|
||||||
defer m.deinit();
|
const w = msg_buf.writer();
|
||||||
try cbor.writeArrayHeader(w, 3);
|
try cbor.writeArrayHeader(w, 3);
|
||||||
try cbor.writeValue(w, "cmd");
|
try cbor.writeValue(w, "cmd");
|
||||||
try cbor.writeValue(w, "rename_symbol_item");
|
try cbor.writeValue(w, "rename_symbol_item");
|
||||||
|
@ -824,7 +824,7 @@ pub fn rename_symbol(self: *Self, from: tp.pid_ref, file_path: []const u8, row:
|
||||||
rename.new_text,
|
rename.new_text,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
from.send_raw(.{ .buf = m.items }) catch return error.ClientFailed;
|
from.send_raw(.{ .buf = msg_buf.items }) catch return error.ClientFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ pub const ArgumentType = enum {
|
||||||
integer,
|
integer,
|
||||||
float,
|
float,
|
||||||
object,
|
object,
|
||||||
|
array,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn Closure(comptime T: type) type {
|
pub fn Closure(comptime T: type) type {
|
||||||
|
|
|
@ -562,18 +562,18 @@ const cmds = struct {
|
||||||
var len = try cbor.decodeArrayHeader(&iter);
|
var len = try cbor.decodeArrayHeader(&iter);
|
||||||
var mroot: ?@import("Buffer").Root = null;
|
var mroot: ?@import("Buffer").Root = null;
|
||||||
while (len != 0) {
|
while (len != 0) {
|
||||||
var file_uri: []const u8 = undefined;
|
|
||||||
var sel: ed.Selection = .{};
|
|
||||||
var new_text: []const u8 = undefined;
|
|
||||||
len -= 1;
|
len -= 1;
|
||||||
std.debug.assert(try cbor.decodeArrayHeader(&iter) == 6);
|
std.debug.assert(try cbor.decodeArrayHeader(&iter) == 6);
|
||||||
|
var file_uri: []const u8 = undefined;
|
||||||
if (!try cbor.matchString(&iter, &file_uri)) return error.MissingArgument;
|
if (!try cbor.matchString(&iter, &file_uri)) return error.MissingArgument;
|
||||||
|
var sel: ed.Selection = .{};
|
||||||
if (!try cbor.matchInt(usize, &iter, &sel.begin.row)) return error.MissingArgument;
|
if (!try cbor.matchInt(usize, &iter, &sel.begin.row)) return error.MissingArgument;
|
||||||
if (!try cbor.matchInt(usize, &iter, &sel.begin.col)) return error.MissingArgument;
|
if (!try cbor.matchInt(usize, &iter, &sel.begin.col)) return error.MissingArgument;
|
||||||
if (!try cbor.matchInt(usize, &iter, &sel.end.row)) return error.MissingArgument;
|
if (!try cbor.matchInt(usize, &iter, &sel.end.row)) return error.MissingArgument;
|
||||||
if (!try cbor.matchInt(usize, &iter, &sel.end.col)) return error.MissingArgument;
|
if (!try cbor.matchInt(usize, &iter, &sel.end.col)) return error.MissingArgument;
|
||||||
|
var new_text: []const u8 = undefined;
|
||||||
if (!try cbor.matchString(&iter, &new_text)) return error.MissingArgument;
|
if (!try cbor.matchString(&iter, &new_text)) return error.MissingArgument;
|
||||||
file_uri = project_manager.normalize_file_path(file_uri);
|
|
||||||
if (self.get_active_editor()) |editor| {
|
if (self.get_active_editor()) |editor| {
|
||||||
// TODO match file_uri correctly. endsWith() isn't correct because 'path' is a
|
// TODO match file_uri correctly. endsWith() isn't correct because 'path' is a
|
||||||
// short, relative path while 'file_uri' is an absolute path starting with 'file://'
|
// short, relative path while 'file_uri' is an absolute path starting with 'file://'
|
||||||
|
@ -581,12 +581,15 @@ const cmds = struct {
|
||||||
if (match) {
|
if (match) {
|
||||||
try editor.rename_symbol_item(sel, new_text, &mroot, len == 0);
|
try editor.rename_symbol_item(sel, new_text, &mroot, len == 0);
|
||||||
} else {
|
} else {
|
||||||
log.logger("LSP").print("TODO perform renames in other files\n", .{});
|
const logger = log.logger("LSP");
|
||||||
|
defer logger.deinit();
|
||||||
|
logger.print("TODO perform renames in other files\n", .{});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const rename_symbol_item_meta = .{ .arguments = &.{ .string, .integer, .integer, .integer, .integer, .string } };
|
pub const rename_symbol_item_meta = .{ .arguments = &.{.array} };
|
||||||
|
pub const rename_symbol_item_elem_meta = .{ .arguments = &.{ .string, .integer, .integer, .integer, .integer, .string } };
|
||||||
|
|
||||||
pub fn clear_diagnostics(self: *Self, ctx: Ctx) Result {
|
pub fn clear_diagnostics(self: *Self, ctx: Ctx) Result {
|
||||||
var file_path: []const u8 = undefined;
|
var file_path: []const u8 = undefined;
|
||||||
|
|
Loading…
Add table
Reference in a new issue