ufcs
This commit is contained in:
@@ -204,7 +204,18 @@ pub const DocumentSymbol = struct {
|
||||
|
||||
/// Build completion items JSON array.
|
||||
pub fn completionItemsJson(allocator: std.mem.Allocator, items: []const CompletionItem) ![]const u8 {
|
||||
return completionItemsJsonInner(allocator, items, false);
|
||||
}
|
||||
|
||||
/// Build a CompletionList object with isIncomplete: false, preventing the client
|
||||
/// from supplementing results with its own word-based suggestions.
|
||||
pub fn completionListJson(allocator: std.mem.Allocator, items: []const CompletionItem) ![]const u8 {
|
||||
return completionItemsJsonInner(allocator, items, true);
|
||||
}
|
||||
|
||||
fn completionItemsJsonInner(allocator: std.mem.Allocator, items: []const CompletionItem, as_list: bool) ![]const u8 {
|
||||
var buf = std.ArrayList(u8).empty;
|
||||
if (as_list) try buf.appendSlice(allocator, "{\"isIncomplete\":false,\"items\":");
|
||||
try buf.append(allocator, '[');
|
||||
for (items, 0..) |item, idx| {
|
||||
if (idx > 0) try buf.append(allocator, ',');
|
||||
@@ -225,6 +236,7 @@ pub fn completionItemsJson(allocator: std.mem.Allocator, items: []const Completi
|
||||
}
|
||||
}
|
||||
try buf.append(allocator, ']');
|
||||
if (as_list) try buf.append(allocator, '}');
|
||||
return buf.items;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user