Self hosted fixes (#682)
* fix compiler errors when using self-hosted * move parameters into builder struct * simplify code when using self hosted * fix stage2 error `cast discards const qualifier` * correctly return after finding method * fix position context tests on self hosted * remove unnecessary comptime in position context tests
This commit is contained in:
@@ -249,10 +249,10 @@ fn freeDocument(doc: types.TextDocument) void {
|
||||
allocator.free(doc.text);
|
||||
}
|
||||
|
||||
|
||||
fn testContext(comptime line: []const u8, comptime tag: std.meta.Tag(analysis.PositionContext), comptime maybe_range: ?[]const u8) !void {
|
||||
const cursor_idx = comptime std.mem.indexOf(u8, line, "<cursor>").?;
|
||||
const final_line = line[0..cursor_idx] ++ line[cursor_idx + "<cursor>".len ..];
|
||||
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);
|
||||
@@ -264,7 +264,7 @@ fn testContext(comptime line: []const u8, comptime tag: std.meta.Tag(analysis.Po
|
||||
return error.DifferentTag;
|
||||
}
|
||||
|
||||
const actual_loc = ctx.loc() orelse if(maybe_range) |expected_range| {
|
||||
const actual_loc = ctx.loc() orelse if (maybe_range) |expected_range| {
|
||||
std.debug.print("Expected `{s}`, got null range\n", .{
|
||||
expected_range,
|
||||
});
|
||||
@@ -277,14 +277,14 @@ fn testContext(comptime line: []const u8, comptime tag: std.meta.Tag(analysis.Po
|
||||
});
|
||||
return error.DifferentRange;
|
||||
};
|
||||
|
||||
const expected_range_start = comptime std.mem.indexOf(u8, final_line, expected_range).?;
|
||||
|
||||
const expected_range_start = std.mem.indexOf(u8, final_line, expected_range).?;
|
||||
const expected_range_end = expected_range_start + expected_range.len;
|
||||
|
||||
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,
|
||||
doc.text[actual_loc.start..actual_loc.end], actual_loc.start, actual_loc.end,
|
||||
});
|
||||
return error.DifferentRange;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user