remove old stage1 code artifacts (#831)
This commit is contained in:
parent
5d6f23b5f1
commit
d679b19676
123
src/Server.zig
123
src/Server.zig
@ -1748,42 +1748,20 @@ fn registerCapability(server: *Server, writer: anytype, method: []const u8) !voi
|
|||||||
const id = try std.fmt.allocPrint(server.arena.allocator(), "register-{s}", .{method});
|
const id = try std.fmt.allocPrint(server.arena.allocator(), "register-{s}", .{method});
|
||||||
log.debug("Dynamically registering method '{s}'", .{method});
|
log.debug("Dynamically registering method '{s}'", .{method});
|
||||||
|
|
||||||
if (zig_builtin.zig_backend == .stage1) {
|
try send(writer, server.arena.allocator(), types.Request{
|
||||||
const reg = types.RegistrationParams.Registration{
|
.id = .{ .String = id },
|
||||||
.id = id,
|
.method = "client/registerCapability",
|
||||||
.method = method,
|
.params = types.ResponseParams{
|
||||||
};
|
.RegistrationParams = types.RegistrationParams{
|
||||||
const registrations = [1]types.RegistrationParams.Registration{reg};
|
.registrations = &.{
|
||||||
const params = types.RegistrationParams{
|
.{
|
||||||
.registrations = ®istrations,
|
.id = id,
|
||||||
};
|
.method = method,
|
||||||
|
|
||||||
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",
|
|
||||||
.params = types.ResponseParams{
|
|
||||||
.RegistrationParams = types.RegistrationParams{
|
|
||||||
.registrations = &.{
|
|
||||||
.{
|
|
||||||
.id = id,
|
|
||||||
.method = method,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requestConfiguration(server: *Server, writer: anytype) !void {
|
fn requestConfiguration(server: *Server, writer: anytype) !void {
|
||||||
@ -1855,18 +1833,15 @@ fn saveDocumentHandler(server: *Server, writer: anytype, id: types.RequestId, re
|
|||||||
var workspace_edit = types.WorkspaceEdit{ .changes = .{} };
|
var workspace_edit = types.WorkspaceEdit{ .changes = .{} };
|
||||||
try workspace_edit.changes.putNoClobber(allocator, uri, text_edits);
|
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{
|
try send(writer, allocator, types.Request{
|
||||||
.id = .{ .String = "apply_edit" },
|
.id = .{ .String = "apply_edit" },
|
||||||
.method = "workspace/applyEdit",
|
.method = "workspace/applyEdit",
|
||||||
.params = params,
|
.params = .{
|
||||||
|
.ApplyEdit = .{
|
||||||
|
.label = "autofix",
|
||||||
|
.edit = workspace_edit,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2872,56 +2847,22 @@ pub fn processJsonRpc(server: *Server, writer: anytype, json: []const u8) !void
|
|||||||
.{ "textDocument/selectionRange", requests.SelectionRange, selectionRangeHandler },
|
.{ "textDocument/selectionRange", requests.SelectionRange, selectionRangeHandler },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (zig_builtin.zig_backend == .stage1) {
|
inline for (method_map) |method_info| {
|
||||||
// Hack to avoid `return`ing in the inline for, which causes bugs.
|
if (std.mem.eql(u8, method, method_info[0])) {
|
||||||
var done: ?anyerror = null;
|
if (method_info.len == 1) {
|
||||||
inline for (method_map) |method_info| {
|
log.warn("method not mapped: {s}", .{method});
|
||||||
if (done == null and std.mem.eql(u8, method, method_info[0])) {
|
} else if (method_info[1] != void) {
|
||||||
if (method_info.len == 1) {
|
const ReqT = method_info[1];
|
||||||
log.warn("method not mapped: {s}", .{method});
|
const request_obj = try requests.fromDynamicTree(&server.arena, ReqT, tree.root);
|
||||||
done = error.HackDone;
|
method_info[2](server, writer, id, request_obj) catch |err| {
|
||||||
} else if (method_info[1] != void) {
|
log.err("failed to process request: {s}", .{@errorName(err)});
|
||||||
const ReqT = method_info[1];
|
};
|
||||||
if (requests.fromDynamicTree(&server.arena, ReqT, tree.root)) |request_obj| {
|
} else {
|
||||||
done = error.HackDone;
|
method_info[2](server, writer, id) catch |err| {
|
||||||
done = extractErr(method_info[2](server, writer, id, request_obj));
|
log.err("failed to process request: {s}", .{@errorName(err)});
|
||||||
} 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) {
|
|
||||||
log.warn("method not mapped: {s}", .{method});
|
|
||||||
} else if (method_info[1] != void) {
|
|
||||||
const ReqT = method_info[1];
|
|
||||||
const request_obj = try requests.fromDynamicTree(&server.arena, ReqT, tree.root);
|
|
||||||
method_info[2](server, writer, id, request_obj) catch |err| {
|
|
||||||
log.err("failed to process request: {s}", .{@errorName(err)});
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
method_info[2](server, writer, id) catch |err| {
|
|
||||||
log.err("failed to process request: {s}", .{@errorName(err)});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,16 +243,15 @@ fn writeCallNodeHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store:
|
|||||||
|
|
||||||
/// HACK self-hosted has not implemented async yet
|
/// HACK self-hosted has not implemented async yet
|
||||||
fn callWriteNodeInlayHint(allocator: std.mem.Allocator, args: anytype) error{OutOfMemory}!void {
|
fn callWriteNodeInlayHint(allocator: std.mem.Allocator, args: anytype) error{OutOfMemory}!void {
|
||||||
_ = allocator;
|
if (zig_builtin.zig_backend == .other or zig_builtin.zig_backend == .stage1) {
|
||||||
// if (zig_builtin.zig_backend == .other or zig_builtin.zig_backend == .stage1) {
|
const FrameSize = @sizeOf(@Frame(writeNodeInlayHint));
|
||||||
// const FrameSize = @sizeOf(@Frame(writeNodeInlayHint));
|
var child_frame = try allocator.alignedAlloc(u8, std.Target.stack_align, FrameSize);
|
||||||
// var child_frame = try allocator.alignedAlloc(u8, std.Target.stack_align, FrameSize);
|
defer allocator.free(child_frame);
|
||||||
// defer allocator.free(child_frame);
|
return await @asyncCall(child_frame, {}, writeNodeInlayHint, args);
|
||||||
// return await @asyncCall(child_frame, {}, writeNodeInlayHint, args);
|
} else {
|
||||||
// } else {
|
// TODO find a non recursive solution
|
||||||
// TODO find a non recursive solution
|
return @call(.auto, writeNodeInlayHint, args);
|
||||||
return @call(.auto, writeNodeInlayHint, args);
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// iterates over the ast and writes parameter hints into `builder.hints` for every function call and builtin call
|
/// iterates over the ast and writes parameter hints into `builder.hints` for every function call and builtin call
|
||||||
|
Loading…
Reference in New Issue
Block a user