support new module cli arguments (#1019)

* support new module cli arguments

* capture the runtime zig version and store it on `Server`

* update build_runner action

* Use correct version for selecting arguments
This commit is contained in:
Lee Cannon
2023-02-23 12:18:52 -08:00
committed by GitHub
parent f1a8efbe5c
commit 5ede46f003
9 changed files with 133 additions and 51 deletions

View File

@@ -29,7 +29,7 @@ const default_config: Config = .{
const allocator = std.testing.allocator;
pub const Context = struct {
server: Server,
server: *Server,
arena: std.heap.ArenaAllocator,
config: *Config,
request_id: u32 = 1,
@@ -40,8 +40,8 @@ pub const Context = struct {
config.* = default_config;
var server = try Server.init(allocator, config, null, false, false);
errdefer server.deinit();
const server = try Server.create(allocator, config, null, false, false);
errdefer server.destroy();
var context: Context = .{
.server = server,
@@ -63,7 +63,7 @@ pub const Context = struct {
allocator.destroy(self.config);
self.request("shutdown", "{}", null) catch {};
self.server.deinit();
self.server.destroy();
self.arena.deinit();
}

View File

@@ -3,7 +3,7 @@ const zls = @import("zls");
const builtin = @import("builtin");
const Ast = std.zig.Ast;
const ZigVersionWrapper = zls.ZigVersionWrapper;
const ComptimeInterpreter = zls.ComptimeInterpreter;
const InternPool = zls.analyser.InternPool;
const Index = InternPool.Index;
@@ -286,7 +286,14 @@ const Context = struct {
document_store: *zls.DocumentStore,
interpreter: *ComptimeInterpreter,
// this is very annoying and ugly
boxed_null: *const ?ZigVersionWrapper,
pub fn init(source: []const u8) !Context {
var boxed_null = try allocator.create(?ZigVersionWrapper);
errdefer allocator.destroy(boxed_null);
boxed_null.* = null;
var config = try allocator.create(zls.Config);
errdefer allocator.destroy(config);
@@ -300,6 +307,7 @@ const Context = struct {
document_store.* = .{
.allocator = allocator,
.config = config,
.runtime_zig_version = boxed_null,
};
errdefer document_store.deinit();
@@ -326,6 +334,8 @@ const Context = struct {
.config = config,
.document_store = document_store,
.interpreter = interpreter,
.boxed_null = boxed_null,
};
}
@@ -336,6 +346,7 @@ const Context = struct {
allocator.destroy(self.config);
allocator.destroy(self.document_store);
allocator.destroy(self.interpreter);
allocator.destroy(self.boxed_null);
}
pub fn call(self: *Context, func_node: Ast.Node.Index, arguments: []const KV) !KV {