From 2bc83741fbb9534044b602997351fd78fc955c5e Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Mon, 10 Oct 2022 19:16:23 +0200 Subject: [PATCH] update cimport diagnostic collection --- src/Server.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Server.zig b/src/Server.zig index 1200a62..5793eb2 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -175,17 +175,19 @@ fn publishDiagnostics(server: *Server, writer: anytype, handle: DocumentStore.Ha }); } - for (handle.cimports) |cimport| { - if (cimport.result != .failure) continue; - const stderr = std.mem.trim(u8, cimport.result.failure, " "); + for (handle.cimports.items(.hash)) |hash, i| { + const result = server.document_store.cimports.get(hash) orelse continue; + if (result != .failure) continue; + const stderr = std.mem.trim(u8, result.failure, " "); var pos_and_diag_iterator = std.mem.split(u8, stderr, ":"); _ = pos_and_diag_iterator.next(); // skip file path _ = pos_and_diag_iterator.next(); // skip line _ = pos_and_diag_iterator.next(); // skip character + const node = handle.cimports.items(.node)[i]; try diagnostics.append(allocator, .{ - .range = offsets.nodeToRange(handle.tree, cimport.node, server.offset_encoding), + .range = offsets.nodeToRange(handle.tree, node, server.offset_encoding), .severity = .Error, .code = "cImport", .source = "zls", @@ -288,7 +290,8 @@ fn publishDiagnostics(server: *Server, writer: anytype, handle: DocumentStore.Ha .source = "zls", .message = try allocator.dupe(u8, pos_and_diag_iterator.rest()), }); - + } + if (server.config.highlight_global_var_declarations) { const main_tokens = tree.nodes.items(.main_token); const tags = tree.tokens.items(.tag);