Merge pull request #584 from InKryption/master
2 minor tidy-ups + fix for over-eager unused parameter error in function types
This commit is contained in:
commit
9161397b82
@ -239,11 +239,7 @@ fn publishDiagnostics(server: *Server, writer: anytype, handle: DocumentStore.Ha
|
||||
scopes: for (handle.document_scope.scopes) |scope| {
|
||||
const scope_data = switch (scope.data) {
|
||||
.function => |f| b: {
|
||||
var buf: [1]std.zig.Ast.Node.Index = undefined;
|
||||
var proto = ast.fnProto(tree, f, &buf) orelse break :b f;
|
||||
if (proto.extern_export_inline_token) |tok| {
|
||||
if (std.mem.eql(u8, tree.tokenSlice(tok), "extern")) continue :scopes;
|
||||
}
|
||||
if (!ast.fnProtoHasBody(tree, f).?) continue :scopes;
|
||||
break :b f;
|
||||
},
|
||||
.block => |b| b,
|
||||
@ -2450,7 +2446,6 @@ pub fn processJsonRpc(server: *Server, writer: anytype, json: []const u8) !void
|
||||
return;
|
||||
}
|
||||
|
||||
std.debug.assert(tree.root.Object.get("method") != null);
|
||||
const method = tree.root.Object.get("method").?.String;
|
||||
|
||||
const start_time = std.time.milliTimestamp();
|
||||
@ -2490,6 +2485,7 @@ pub fn processJsonRpc(server: *Server, writer: anytype, json: []const u8) !void
|
||||
};
|
||||
|
||||
// Hack to avoid `return`ing in the inline for, which causes bugs.
|
||||
// TODO: Change once stage2 is shipped and more stable?
|
||||
var done: ?anyerror = null;
|
||||
inline for (method_map) |method_info| {
|
||||
if (done == null and std.mem.eql(u8, method, method_info[0])) {
|
||||
|
12
src/ast.zig
12
src/ast.zig
@ -1037,6 +1037,18 @@ pub fn isBlock(tree: Ast, node: Ast.Node.Index) bool {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn fnProtoHasBody(tree: Ast, node: Ast.Node.Index) ?bool {
|
||||
return switch (tree.nodes.items(.tag)[node]) {
|
||||
.fn_proto,
|
||||
.fn_proto_multi,
|
||||
.fn_proto_one,
|
||||
.fn_proto_simple,
|
||||
=> false,
|
||||
.fn_decl => true,
|
||||
else => null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn fnProto(tree: Ast, node: Ast.Node.Index, buf: *[1]Ast.Node.Index) ?Ast.full.FnProto {
|
||||
return switch (tree.nodes.items(.tag)[node]) {
|
||||
.fn_proto => tree.fnProto(node),
|
||||
|
@ -32,8 +32,7 @@ fn loop(server: *Server) !void {
|
||||
|
||||
try reader.readNoEof(buffer);
|
||||
|
||||
var writer = std.io.getStdOut().writer();
|
||||
|
||||
const writer = std.io.getStdOut().writer();
|
||||
try server.processJsonRpc(writer, buffer);
|
||||
}
|
||||
}
|
||||
@ -212,7 +211,7 @@ const stack_frames = switch (zig_builtin.mode) {
|
||||
else => 0,
|
||||
};
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
pub fn main() !void {
|
||||
var gpa_state = std.heap.GeneralPurposeAllocator(.{ .stack_trace_frames = stack_frames }){};
|
||||
defer _ = gpa_state.deinit();
|
||||
var tracy_state = if (tracy.enable_allocation) tracy.tracyAllocator(gpa_state.allocator()) else void{};
|
||||
|
Loading…
Reference in New Issue
Block a user