remove types.TextDocument (#693)
* remove types.TextDocument * resolve compile errors because of previous merge
This commit is contained in:
@@ -233,31 +233,12 @@ test "position context - empty" {
|
||||
);
|
||||
}
|
||||
|
||||
fn makeDocument(uri: []const u8, text: []const u8) !types.TextDocument {
|
||||
const mem = try allocator.alloc(u8, text.len + 1);
|
||||
std.mem.copy(u8, mem, text);
|
||||
mem[text.len] = 0;
|
||||
|
||||
return types.TextDocument{
|
||||
.uri = uri,
|
||||
.mem = mem,
|
||||
.text = mem[0..text.len :0],
|
||||
};
|
||||
}
|
||||
|
||||
fn freeDocument(doc: types.TextDocument) void {
|
||||
allocator.free(doc.text);
|
||||
}
|
||||
|
||||
fn testContext(line: []const u8, tag: std.meta.Tag(analysis.PositionContext), maybe_range: ?[]const u8) !void {
|
||||
const cursor_idx = std.mem.indexOf(u8, line, "<cursor>").?;
|
||||
const final_line = try std.mem.concat(allocator, u8, &.{ line[0..cursor_idx], line[cursor_idx + "<cursor>".len ..] });
|
||||
defer allocator.free(final_line);
|
||||
|
||||
const doc = try makeDocument("", line);
|
||||
defer freeDocument(doc);
|
||||
|
||||
const ctx = try analysis.getPositionContext(allocator, doc, cursor_idx);
|
||||
const ctx = try analysis.getPositionContext(allocator, line, cursor_idx);
|
||||
|
||||
if (std.meta.activeTag(ctx) != tag) {
|
||||
std.debug.print("Expected tag `{s}`, got `{s}`\n", .{ @tagName(tag), @tagName(std.meta.activeTag(ctx)) });
|
||||
@@ -273,7 +254,7 @@ fn testContext(line: []const u8, tag: std.meta.Tag(analysis.PositionContext), ma
|
||||
|
||||
const expected_range = maybe_range orelse {
|
||||
std.debug.print("Expected null range, got `{s}`\n", .{
|
||||
doc.text[actual_loc.start..actual_loc.end],
|
||||
line[actual_loc.start..actual_loc.end],
|
||||
});
|
||||
return error.DifferentRange;
|
||||
};
|
||||
@@ -283,8 +264,8 @@ fn testContext(line: []const u8, tag: std.meta.Tag(analysis.PositionContext), ma
|
||||
|
||||
if (expected_range_start != actual_loc.start or expected_range_end != actual_loc.end) {
|
||||
std.debug.print("Expected range `{s}` ({}..{}), got `{s}` ({}..{})\n", .{
|
||||
doc.text[expected_range_start..expected_range_end], expected_range_start, expected_range_end,
|
||||
doc.text[actual_loc.start..actual_loc.end], actual_loc.start, actual_loc.end,
|
||||
line[expected_range_start..expected_range_end], expected_range_start, expected_range_end,
|
||||
line[actual_loc.start..actual_loc.end], actual_loc.start, actual_loc.end,
|
||||
});
|
||||
return error.DifferentRange;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user