Added label renaming

This commit is contained in:
Alexandros Naskos
2020-06-27 03:16:14 +03:00
parent 4952c34481
commit beb900f1d9
3 changed files with 104 additions and 13 deletions

View File

@@ -61,6 +61,7 @@ pub const ResponseParams = union(enum) {
DocumentSymbols: []DocumentSymbol,
SemanticTokens: struct { data: []const u32 },
TextEdits: []TextEdit,
WorkspaceEdit: WorkspaceEdit,
};
/// JSONRPC error
@@ -201,6 +202,33 @@ pub const TextDocument = struct {
}
};
pub const WorkspaceEdit = struct {
changes: ?std.StringHashMap([]TextEdit),
pub fn jsonStringify(
self: WorkspaceEdit,
options: std.json.StringifyOptions,
writer: var,
) @TypeOf(writer).Error!void {
try writer.writeByte('{');
if (self.changes) |changes| {
try writer.writeAll("\"changes\": {");
var it = changes.iterator();
var idx: usize = 0;
while (it.next()) |entry| : (idx += 1) {
if (idx != 0) try writer.writeAll(", ");
try writer.writeByte('"');
try writer.writeAll(entry.key);
try writer.writeAll("\":");
try std.json.stringify(entry.value, options, writer);
}
try writer.writeByte('}');
}
try writer.writeByte('}');
}
};
pub const TextEdit = struct {
range: Range,
newText: String,