Use error iterator instead of manual looping in diagnostic generation
This commit is contained in:
parent
01b2c2e328
commit
922559c83a
@ -143,10 +143,8 @@ fn publishDiagnostics(document: *types.TextDocument) !void {
|
|||||||
|
|
||||||
var diagnostics = std.ArrayList(types.Diagnostic).init(&arena.allocator);
|
var diagnostics = std.ArrayList(types.Diagnostic).init(&arena.allocator);
|
||||||
|
|
||||||
if (tree.errors.len > 0) {
|
var error_it = tree.errors.iterator(0);
|
||||||
var index: usize = 0;
|
while (error_it.next()) |err| {
|
||||||
while (index < tree.errors.len) : (index += 1) {
|
|
||||||
const err = tree.errors.at(index);
|
|
||||||
const loc = tree.tokenLocation(0, err.loc());
|
const loc = tree.tokenLocation(0, err.loc());
|
||||||
|
|
||||||
var mem_buffer: [256]u8 = undefined;
|
var mem_buffer: [256]u8 = undefined;
|
||||||
@ -162,7 +160,8 @@ fn publishDiagnostics(document: *types.TextDocument) !void {
|
|||||||
// .relatedInformation = undefined
|
// .relatedInformation = undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
if (tree.errors.len == 0) {
|
||||||
try cacheSane(document);
|
try cacheSane(document);
|
||||||
var decls = tree.root_node.decls.iterator(0);
|
var decls = tree.root_node.decls.iterator(0);
|
||||||
while (decls.next()) |decl_ptr| {
|
while (decls.next()) |decl_ptr| {
|
||||||
|
Loading…
Reference in New Issue
Block a user