remove old stage1 code artifacts (#831)

This commit is contained in:
Techatrix 2022-12-17 09:02:31 +01:00 committed by GitHub
parent 5d6f23b5f1
commit d679b19676
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 101 deletions

View File

@ -1748,27 +1748,6 @@ fn registerCapability(server: *Server, writer: anytype, method: []const u8) !voi
const id = try std.fmt.allocPrint(server.arena.allocator(), "register-{s}", .{method});
log.debug("Dynamically registering method '{s}'", .{method});
if (zig_builtin.zig_backend == .stage1) {
const reg = types.RegistrationParams.Registration{
.id = id,
.method = method,
};
const registrations = [1]types.RegistrationParams.Registration{reg};
const params = types.RegistrationParams{
.registrations = &registrations,
};
const respp = types.ResponseParams{
.RegistrationParams = params,
};
const req = types.Request{
.id = .{ .String = id },
.method = "client/registerCapability",
.params = respp,
};
try send(writer, server.arena.allocator(), req);
} else {
try send(writer, server.arena.allocator(), types.Request{
.id = .{ .String = id },
.method = "client/registerCapability",
@ -1784,7 +1763,6 @@ fn registerCapability(server: *Server, writer: anytype, method: []const u8) !voi
},
});
}
}
fn requestConfiguration(server: *Server, writer: anytype) !void {
const configuration_items = comptime confi: {
@ -1855,18 +1833,15 @@ fn saveDocumentHandler(server: *Server, writer: anytype, id: types.RequestId, re
var workspace_edit = types.WorkspaceEdit{ .changes = .{} };
try workspace_edit.changes.putNoClobber(allocator, uri, text_edits);
// NOTE: stage1 moment
const params = types.ResponseParams{
.ApplyEdit = types.ApplyWorkspaceEditParams{
.label = "autofix",
.edit = workspace_edit,
},
};
try send(writer, allocator, types.Request{
.id = .{ .String = "apply_edit" },
.method = "workspace/applyEdit",
.params = params,
.params = .{
.ApplyEdit = .{
.label = "autofix",
.edit = workspace_edit,
},
},
});
}
@ -2872,39 +2847,6 @@ pub fn processJsonRpc(server: *Server, writer: anytype, json: []const u8) !void
.{ "textDocument/selectionRange", requests.SelectionRange, selectionRangeHandler },
};
if (zig_builtin.zig_backend == .stage1) {
// Hack to avoid `return`ing in the inline for, which causes bugs.
var done: ?anyerror = null;
inline for (method_map) |method_info| {
if (done == null and std.mem.eql(u8, method, method_info[0])) {
if (method_info.len == 1) {
log.warn("method not mapped: {s}", .{method});
done = error.HackDone;
} else if (method_info[1] != void) {
const ReqT = method_info[1];
if (requests.fromDynamicTree(&server.arena, ReqT, tree.root)) |request_obj| {
done = error.HackDone;
done = extractErr(method_info[2](server, writer, id, request_obj));
} else |err| {
if (err == error.MalformedJson) {
log.warn("Could not create request type {s} from JSON {s}", .{ @typeName(ReqT), json });
}
done = err;
}
} else {
done = error.HackDone;
(method_info[2])(server, writer, id) catch |err| {
done = err;
};
}
}
}
if (done) |err| switch (err) {
error.MalformedJson => return try respondGeneric(writer, id, null_result_response),
error.HackDone => return,
else => return err,
};
} else {
inline for (method_map) |method_info| {
if (std.mem.eql(u8, method, method_info[0])) {
if (method_info.len == 1) {
@ -2923,7 +2865,6 @@ pub fn processJsonRpc(server: *Server, writer: anytype, json: []const u8) !void
return;
}
}
}
// Boolean value is true if the method is a request (and thus the client
// needs a response) or false if the method is a notification (in which

View File

@ -243,16 +243,15 @@ fn writeCallNodeHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store:
/// HACK self-hosted has not implemented async yet
fn callWriteNodeInlayHint(allocator: std.mem.Allocator, args: anytype) error{OutOfMemory}!void {
_ = allocator;
// if (zig_builtin.zig_backend == .other or zig_builtin.zig_backend == .stage1) {
// const FrameSize = @sizeOf(@Frame(writeNodeInlayHint));
// var child_frame = try allocator.alignedAlloc(u8, std.Target.stack_align, FrameSize);
// defer allocator.free(child_frame);
// return await @asyncCall(child_frame, {}, writeNodeInlayHint, args);
// } else {
if (zig_builtin.zig_backend == .other or zig_builtin.zig_backend == .stage1) {
const FrameSize = @sizeOf(@Frame(writeNodeInlayHint));
var child_frame = try allocator.alignedAlloc(u8, std.Target.stack_align, FrameSize);
defer allocator.free(child_frame);
return await @asyncCall(child_frame, {}, writeNodeInlayHint, args);
} else {
// TODO find a non recursive solution
return @call(.auto, writeNodeInlayHint, args);
// }
}
}
/// iterates over the ast and writes parameter hints into `builder.hints` for every function call and builtin call