From b2e456404cce28c7c8532e5d6c4d017a6b6402ac Mon Sep 17 00:00:00 2001 From: Vesim Date: Sun, 10 Jan 2021 08:12:11 +0100 Subject: [PATCH] fix inStream/outStream removal --- build.zig | 2 +- src/analysis.zig | 10 +++++----- src/main.zig | 8 ++++---- src/uri.zig | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.zig b/build.zig index 15a7a47..c9be825 100644 --- a/build.zig +++ b/build.zig @@ -64,7 +64,7 @@ pub fn config(step: *std.build.Step) anyerror!void { var file = try dir.createFile("zls.json", .{}); defer file.close(); - const out = file.outStream(); + const out = file.writer(); std.debug.warn("Writing to config...\n", .{}); diff --git a/src/analysis.zig b/src/analysis.zig index 8e98c37..6370553 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -64,9 +64,9 @@ pub fn collectDocComments( pub fn getFunctionSignature(tree: *ast.Tree, func: *ast.Node.FnProto) []const u8 { const start = tree.token_locs[func.firstToken()].start; const end = tree.token_locs[switch (func.return_type) { - .Explicit, .InferErrorSet => |node| node.lastToken(), - .Invalid => |r_paren| r_paren, - }].end; + .Explicit, .InferErrorSet => |node| node.lastToken(), + .Invalid => |r_paren| r_paren, + }].end; return tree.source[start..end]; } @@ -80,7 +80,7 @@ pub fn getFunctionSnippet(allocator: *std.mem.Allocator, tree: *ast.Tree, func: try buffer.appendSlice(tree.tokenSlice(name_tok)); try buffer.append('('); - var buf_stream = buffer.outStream(); + var buf_stream = buffer.writer(); for (func.paramsConst()) |param, param_num| { if (skip_self_param and param_num == 0) continue; @@ -2006,7 +2006,7 @@ pub const DocumentScope = struct { while (decl_it.next()) |name_decl| : (idx += 1) { if (idx != 0) log.debug(", ", .{}); } - log.debug("{s}", .{name_decl.key}); + log.debug("{s}", .{name_decl.key}); log.debug("\n--------------------------\n", .{}); } } diff --git a/src/main.zig b/src/main.zig index 85e1b47..83dcd0c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -88,7 +88,7 @@ pub fn log( } // Code is largely based off of https://github.com/andersfr/zig-lsp/blob/master/server.zig -var stdout: std.io.BufferedOutStream(4096, std.fs.File.OutStream) = undefined; +var stdout: std.io.BufferedWriter(4096, std.fs.File.Writer) = undefined; var allocator: *std.mem.Allocator = undefined; var document_store: DocumentStore = undefined; @@ -155,7 +155,7 @@ fn respondGeneric(id: types.RequestId, response: []const u8) !void { // Numbers of character that will be printed from this string: len - 1 brackets const json_fmt = "{{\"jsonrpc\":\"2.0\",\"id\":"; - const stdout_stream = stdout.outStream(); + const stdout_stream = stdout.writer(); try stdout_stream.print("Content-Length: {}\r\n\r\n" ++ json_fmt, .{response.len + id_len + json_fmt.len - 1}); switch (id) { .Integer => |int| try stdout_stream.print("{}", .{int}), @@ -203,7 +203,7 @@ fn publishDiagnostics(arena: *std.heap.ArenaAllocator, handle: DocumentStore.Han var mem_buffer: [256]u8 = undefined; var fbs = std.io.fixedBufferStream(&mem_buffer); - try tree.renderError(err, fbs.outStream()); + try tree.renderError(err, fbs.writer()); try diagnostics.append(.{ .range = astLocationToRange(loc), @@ -1536,7 +1536,7 @@ pub fn main() anyerror!void { // Init global vars const reader = std.io.getStdIn().reader(); - stdout = std.io.bufferedOutStream(std.io.getStdOut().outStream()); + stdout = std.io.bufferedWriter(std.io.getStdOut().writer()); // Read the configuration, if any. const config_parse_options = std.json.ParseOptions{ .allocator = allocator }; diff --git a/src/uri.zig b/src/uri.zig index 59ea9d6..1e7c89a 100644 --- a/src/uri.zig +++ b/src/uri.zig @@ -14,7 +14,7 @@ pub fn fromPath(allocator: *std.mem.Allocator, path: []const u8) ![]const u8 { var buf = std.ArrayList(u8).init(allocator); try buf.appendSlice(prefix); - const out_stream = buf.outStream(); + const out_stream = buf.writer(); for (path) |char| { if (char == std.fs.path.sep) { @@ -41,7 +41,7 @@ pub fn fromPath(allocator: *std.mem.Allocator, path: []const u8) ![]const u8 { return buf.toOwnedSlice(); } -pub const UriParseError = error { +pub const UriParseError = error{ UriBadScheme, UriBadHexChar, UriBadEscape,