Compare commits
No commits in common. "9bdc3e0a0aff07496c37cfabfa62d5d748edc289" and "4eda1fec0c1b2f78f799ea2474b392e9004f6892" have entirely different histories.
9bdc3e0a0a
...
4eda1fec0c
2 changed files with 18 additions and 27 deletions
|
|
@ -1005,17 +1005,10 @@ fn send_completion_items(to: tp.pid_ref, file_path: []const u8, row: usize, col:
|
|||
var item: []const u8 = "";
|
||||
while (len > 0) : (len -= 1) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract_cbor(&item)))) return error.InvalidMessageField;
|
||||
try send_completion_item(to, file_path, row, col, item, if (len > 1) true else is_incomplete);
|
||||
send_completion_item(to, file_path, row, col, item, if (len > 1) true else is_incomplete) catch return error.ClientFailed;
|
||||
}
|
||||
}
|
||||
|
||||
fn invalid_field(field: []const u8) error{InvalidMessage} {
|
||||
const logger = log.logger("lsp");
|
||||
defer logger.deinit();
|
||||
logger.print("invalid completion field '{s}'", .{field});
|
||||
return error.InvalidMessage;
|
||||
}
|
||||
|
||||
fn send_completion_item(to: tp.pid_ref, file_path: []const u8, row: usize, col: usize, item: []const u8, is_incomplete: bool) (ClientError || InvalidMessageError || cbor.Error)!void {
|
||||
var label: []const u8 = "";
|
||||
var label_detail: []const u8 = "";
|
||||
|
|
@ -1036,53 +1029,53 @@ fn send_completion_item(to: tp.pid_ref, file_path: []const u8, row: usize, col:
|
|||
var field_name: []const u8 = undefined;
|
||||
if (!(try cbor.matchString(&iter, &field_name))) return error.InvalidMessage;
|
||||
if (std.mem.eql(u8, field_name, "label")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&label)))) return invalid_field("label");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&label)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "labelDetails")) {
|
||||
var len_ = cbor.decodeMapHeader(&iter) catch return;
|
||||
while (len_ > 0) : (len_ -= 1) {
|
||||
if (!(try cbor.matchString(&iter, &field_name))) return invalid_field("labelDetails");
|
||||
if (!(try cbor.matchString(&iter, &field_name))) return error.InvalidMessage;
|
||||
if (std.mem.eql(u8, field_name, "detail")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&label_detail)))) return invalid_field("labelDetails.detail");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&label_detail)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "description")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&label_description)))) return invalid_field("labelDetails.description");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&label_description)))) return error.InvalidMessageField;
|
||||
} else {
|
||||
try cbor.skipValue(&iter);
|
||||
}
|
||||
}
|
||||
} else if (std.mem.eql(u8, field_name, "kind")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&kind)))) return invalid_field("kind");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&kind)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "detail")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&detail)))) return invalid_field("detail");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&detail)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "documentation")) {
|
||||
var len_ = cbor.decodeMapHeader(&iter) catch return;
|
||||
while (len_ > 0) : (len_ -= 1) {
|
||||
if (!(try cbor.matchString(&iter, &field_name))) return invalid_field("documentation");
|
||||
if (!(try cbor.matchString(&iter, &field_name))) return error.InvalidMessage;
|
||||
if (std.mem.eql(u8, field_name, "kind")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&documentation_kind)))) return invalid_field("documentation.kind");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&documentation_kind)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "value")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&documentation)))) return invalid_field("documentation.value");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&documentation)))) return error.InvalidMessageField;
|
||||
} else {
|
||||
try cbor.skipValue(&iter);
|
||||
}
|
||||
}
|
||||
} else if (std.mem.eql(u8, field_name, "sortText")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&sortText)))) return invalid_field("sortText");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&sortText)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "insertTextFormat")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&insertTextFormat)))) return invalid_field("insertTextFormat");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&insertTextFormat)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "textEdit")) {
|
||||
// var textEdit: []const u8 = ""; // { "newText": "wait_expired(${1:timeout_ns: isize})", "insert": Range, "replace": Range },
|
||||
var len_ = cbor.decodeMapHeader(&iter) catch return;
|
||||
while (len_ > 0) : (len_ -= 1) {
|
||||
if (!(try cbor.matchString(&iter, &field_name))) return invalid_field("textEdit");
|
||||
if (!(try cbor.matchString(&iter, &field_name))) return error.InvalidMessage;
|
||||
if (std.mem.eql(u8, field_name, "newText")) {
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&textEdit_newText)))) return invalid_field("textEdit.newText");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract(&textEdit_newText)))) return error.InvalidMessageField;
|
||||
} else if (std.mem.eql(u8, field_name, "insert")) {
|
||||
var range_: []const u8 = undefined;
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract_cbor(&range_)))) return invalid_field("textEdit.insert");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract_cbor(&range_)))) return error.InvalidMessageField;
|
||||
textEdit_insert = try read_range(range_);
|
||||
} else if (std.mem.eql(u8, field_name, "replace")) {
|
||||
var range_: []const u8 = undefined;
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract_cbor(&range_)))) return invalid_field("textEdit.replace");
|
||||
if (!(try cbor.matchValue(&iter, cbor.extract_cbor(&range_)))) return error.InvalidMessageField;
|
||||
textEdit_replace = try read_range(range_);
|
||||
} else {
|
||||
try cbor.skipValue(&iter);
|
||||
|
|
@ -1092,8 +1085,8 @@ fn send_completion_item(to: tp.pid_ref, file_path: []const u8, row: usize, col:
|
|||
try cbor.skipValue(&iter);
|
||||
}
|
||||
}
|
||||
const insert = textEdit_insert orelse Range{ .start = .{ .line = 0, .character = 0 }, .end = .{ .line = 0, .character = 0 } };
|
||||
const replace = textEdit_replace orelse Range{ .start = .{ .line = 0, .character = 0 }, .end = .{ .line = 0, .character = 0 } };
|
||||
const insert = textEdit_insert orelse return error.InvalidMessageField;
|
||||
const replace = textEdit_replace orelse return error.InvalidMessageField;
|
||||
return to.send(.{
|
||||
"cmd", "add_completion", .{
|
||||
file_path,
|
||||
|
|
|
|||
|
|
@ -117,7 +117,6 @@ fn select(menu: **Type.MenuState, button: *Type.ButtonState) void {
|
|||
}
|
||||
|
||||
const CompletionItemKind = enum(u8) {
|
||||
None = 0,
|
||||
Text = 1,
|
||||
Method = 2,
|
||||
Function = 3,
|
||||
|
|
@ -147,7 +146,6 @@ const CompletionItemKind = enum(u8) {
|
|||
|
||||
fn kind_icon(kind: CompletionItemKind) []const u8 {
|
||||
return switch (kind) {
|
||||
.None => " ",
|
||||
.Text => "",
|
||||
.Method => "",
|
||||
.Function => "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue