simplify analysis by introducing a Analysis Struct

This commit is contained in:
Techatrix
2023-03-12 23:48:31 +01:00
committed by Lee Cannon
parent 973d33d435
commit 0ff0a193cc
9 changed files with 375 additions and 432 deletions

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const zls = @import("zls");
const analysis = zls.analysis;
const Analyser = zls.Analyser;
const types = zls.types;
const offsets = zls.offsets;
@@ -510,12 +510,12 @@ test "position context - empty" {
);
}
fn testContext(line: []const u8, tag: std.meta.Tag(analysis.PositionContext), maybe_range: ?[]const u8) !void {
fn testContext(line: []const u8, tag: std.meta.Tag(Analyser.PositionContext), maybe_range: ?[]const u8) !void {
const cursor_idx = std.mem.indexOf(u8, line, "<cursor>").?;
const final_line = try std.mem.concat(allocator, u8, &.{ line[0..cursor_idx], line[cursor_idx + "<cursor>".len ..] });
defer allocator.free(final_line);
const ctx = try analysis.getPositionContext(allocator, final_line, cursor_idx, true);
const ctx = try Analyser.getPositionContext(allocator, final_line, cursor_idx, true);
if (std.meta.activeTag(ctx) != tag) {
std.debug.print("Expected tag `{s}`, got `{s}`\n", .{ @tagName(tag), @tagName(std.meta.activeTag(ctx)) });