fix compile errors when targeting wasm (#886)
* fix compile errors when targeting wasm * update known-folders
This commit is contained in:
parent
20ba87c173
commit
54e7d1da8b
@ -224,7 +224,7 @@ pub fn applySave(self: *DocumentStore, handle: *const Handle) !void {
|
|||||||
const tracy_zone = tracy.trace(@src());
|
const tracy_zone = tracy.trace(@src());
|
||||||
defer tracy_zone.end();
|
defer tracy_zone.end();
|
||||||
|
|
||||||
if (isBuildFile(handle.uri)) {
|
if (std.process.can_spawn and isBuildFile(handle.uri)) {
|
||||||
const build_file = self.build_files.getPtr(handle.uri).?;
|
const build_file = self.build_files.getPtr(handle.uri).?;
|
||||||
|
|
||||||
const build_config = loadBuildConfiguration(self.allocator, build_file.*, self.config.*) catch |err| {
|
const build_config = loadBuildConfiguration(self.allocator, build_file.*, self.config.*) catch |err| {
|
||||||
@ -647,7 +647,9 @@ fn createDocument(self: *DocumentStore, uri: Uri, text: [:0]u8, open: bool) erro
|
|||||||
handle.import_uris = try self.collectImportUris(handle);
|
handle.import_uris = try self.collectImportUris(handle);
|
||||||
handle.cimports = try self.collectCIncludes(handle);
|
handle.cimports = try self.collectCIncludes(handle);
|
||||||
|
|
||||||
if (self.config.zig_exe_path != null and isBuildFile(handle.uri) and !isInStd(handle.uri)) {
|
if (!std.process.can_spawn or self.config.zig_exe_path == null) return handle;
|
||||||
|
|
||||||
|
if (isBuildFile(handle.uri) and !isInStd(handle.uri)) {
|
||||||
const gop = try self.build_files.getOrPut(self.allocator, uri);
|
const gop = try self.build_files.getOrPut(self.allocator, uri);
|
||||||
errdefer |err| {
|
errdefer |err| {
|
||||||
self.build_files.swapRemoveAt(gop.index);
|
self.build_files.swapRemoveAt(gop.index);
|
||||||
@ -658,7 +660,7 @@ fn createDocument(self: *DocumentStore, uri: Uri, text: [:0]u8, open: bool) erro
|
|||||||
gop.value_ptr.* = try self.createBuildFile(duped_uri);
|
gop.value_ptr.* = try self.createBuildFile(duped_uri);
|
||||||
gop.key_ptr.* = gop.value_ptr.uri;
|
gop.key_ptr.* = gop.value_ptr.uri;
|
||||||
}
|
}
|
||||||
} else if (self.config.zig_exe_path != null and !isBuiltinFile(handle.uri) and !isInStd(handle.uri)) blk: {
|
} else if (!isBuiltinFile(handle.uri) and !isInStd(handle.uri)) blk: {
|
||||||
// log.debug("Going to walk down the tree towards: {s}", .{uri});
|
// log.debug("Going to walk down the tree towards: {s}", .{uri});
|
||||||
|
|
||||||
// walk down the tree towards the uri. When we hit build.zig files
|
// walk down the tree towards the uri. When we hit build.zig files
|
||||||
@ -831,6 +833,8 @@ pub fn resolveCImport(self: *DocumentStore, handle: Handle, node: Ast.Node.Index
|
|||||||
const tracy_zone = tracy.trace(@src());
|
const tracy_zone = tracy.trace(@src());
|
||||||
defer tracy_zone.end();
|
defer tracy_zone.end();
|
||||||
|
|
||||||
|
if (!std.process.can_spawn) return null;
|
||||||
|
|
||||||
const index = std.mem.indexOfScalar(Ast.Node.Index, handle.cimports.items(.node), node).?;
|
const index = std.mem.indexOfScalar(Ast.Node.Index, handle.cimports.items(.node), node).?;
|
||||||
|
|
||||||
const hash: Hash = handle.cimports.items(.hash)[index];
|
const hash: Hash = handle.cimports.items(.hash)[index];
|
||||||
|
@ -1712,6 +1712,7 @@ fn initializeHandler(server: *Server, request: types.InitializeParams) Error!typ
|
|||||||
server.status = .initializing;
|
server.status = .initializing;
|
||||||
|
|
||||||
if (server.config.zig_exe_path) |exe_path| blk: {
|
if (server.config.zig_exe_path) |exe_path| blk: {
|
||||||
|
if (!std.process.can_spawn) break :blk;
|
||||||
// TODO avoid having to call getZigEnv twice
|
// TODO avoid having to call getZigEnv twice
|
||||||
// once in init and here
|
// once in init and here
|
||||||
const env = configuration.getZigEnv(server.allocator, exe_path) orelse break :blk;
|
const env = configuration.getZigEnv(server.allocator, exe_path) orelse break :blk;
|
||||||
@ -1962,7 +1963,8 @@ fn openDocumentHandler(server: *Server, notification: types.DidOpenTextDocumentP
|
|||||||
|
|
||||||
const handle = try server.document_store.openDocument(notification.textDocument.uri, notification.textDocument.text);
|
const handle = try server.document_store.openDocument(notification.textDocument.uri, notification.textDocument.text);
|
||||||
|
|
||||||
if (server.client_capabilities.supports_publish_diagnostics) {
|
if (server.client_capabilities.supports_publish_diagnostics) blk: {
|
||||||
|
if (!std.process.can_spawn) break :blk;
|
||||||
const diagnostics = try server.generateDiagnostics(handle);
|
const diagnostics = try server.generateDiagnostics(handle);
|
||||||
server.sendNotification("textDocument/publishDiagnostics", diagnostics);
|
server.sendNotification("textDocument/publishDiagnostics", diagnostics);
|
||||||
}
|
}
|
||||||
@ -1978,7 +1980,8 @@ fn changeDocumentHandler(server: *Server, notification: types.DidChangeTextDocum
|
|||||||
|
|
||||||
try server.document_store.refreshDocument(handle.uri, new_text);
|
try server.document_store.refreshDocument(handle.uri, new_text);
|
||||||
|
|
||||||
if (server.client_capabilities.supports_publish_diagnostics) {
|
if (server.client_capabilities.supports_publish_diagnostics) blk: {
|
||||||
|
if (!std.process.can_spawn) break :blk;
|
||||||
const diagnostics = try server.generateDiagnostics(handle.*);
|
const diagnostics = try server.generateDiagnostics(handle.*);
|
||||||
server.sendNotification("textDocument/publishDiagnostics", diagnostics);
|
server.sendNotification("textDocument/publishDiagnostics", diagnostics);
|
||||||
}
|
}
|
||||||
@ -1994,7 +1997,7 @@ fn saveDocumentHandler(server: *Server, notification: types.DidSaveTextDocumentP
|
|||||||
const handle = server.document_store.getHandle(uri) orelse return;
|
const handle = server.document_store.getHandle(uri) orelse return;
|
||||||
try server.document_store.applySave(handle);
|
try server.document_store.applySave(handle);
|
||||||
|
|
||||||
if (server.getAutofixMode() == .on_save) {
|
if (std.process.can_spawn and server.getAutofixMode() == .on_save) {
|
||||||
var text_edits = try server.autofix(allocator, handle);
|
var text_edits = try server.autofix(allocator, handle);
|
||||||
|
|
||||||
var workspace_edit = types.WorkspaceEdit{ .changes = .{} };
|
var workspace_edit = types.WorkspaceEdit{ .changes = .{} };
|
||||||
@ -2028,6 +2031,7 @@ fn willSaveWaitUntilHandler(server: *Server, request: types.WillSaveTextDocument
|
|||||||
|
|
||||||
const handle = server.document_store.getHandle(request.textDocument.uri) orelse return null;
|
const handle = server.document_store.getHandle(request.textDocument.uri) orelse return null;
|
||||||
|
|
||||||
|
if (!std.process.can_spawn) return null;
|
||||||
var text_edits = try server.autofix(allocator, handle);
|
var text_edits = try server.autofix(allocator, handle);
|
||||||
|
|
||||||
return try text_edits.toOwnedSlice(allocator);
|
return try text_edits.toOwnedSlice(allocator);
|
||||||
@ -2192,7 +2196,8 @@ fn hoverHandler(server: *Server, request: types.HoverParams) Error!?types.Hover
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Figure out a better solution for comptime interpreter diags
|
// TODO: Figure out a better solution for comptime interpreter diags
|
||||||
if (server.client_capabilities.supports_publish_diagnostics) {
|
if (server.client_capabilities.supports_publish_diagnostics) blk: {
|
||||||
|
if (!std.process.can_spawn) break :blk;
|
||||||
const diagnostics = try server.generateDiagnostics(handle.*);
|
const diagnostics = try server.generateDiagnostics(handle.*);
|
||||||
server.sendNotification("textDocument/publishDiagnostics", diagnostics);
|
server.sendNotification("textDocument/publishDiagnostics", diagnostics);
|
||||||
}
|
}
|
||||||
@ -2464,7 +2469,8 @@ fn codeActionHandler(server: *Server, request: types.CodeActionParams) Error!?[]
|
|||||||
|
|
||||||
// as of right now, only ast-check errors may get a code action
|
// as of right now, only ast-check errors may get a code action
|
||||||
var diagnostics = std.ArrayListUnmanaged(types.Diagnostic){};
|
var diagnostics = std.ArrayListUnmanaged(types.Diagnostic){};
|
||||||
if (server.config.enable_ast_check_diagnostics and handle.tree.errors.len == 0) {
|
if (server.config.enable_ast_check_diagnostics and handle.tree.errors.len == 0) blk: {
|
||||||
|
if (!std.process.can_spawn) break :blk;
|
||||||
getAstCheckDiagnostics(server, handle.*, &diagnostics) catch |err| {
|
getAstCheckDiagnostics(server, handle.*, &diagnostics) catch |err| {
|
||||||
log.err("failed to run ast-check: {}", .{err});
|
log.err("failed to run ast-check: {}", .{err});
|
||||||
return error.InternalError;
|
return error.InternalError;
|
||||||
|
@ -55,6 +55,7 @@ pub fn loadFromFolder(allocator: std.mem.Allocator, folder_path: []const u8) ?Co
|
|||||||
|
|
||||||
/// Invoke this once all config values have been changed.
|
/// Invoke this once all config values have been changed.
|
||||||
pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_creation_dir: ?[]const u8) !void {
|
pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_creation_dir: ?[]const u8) !void {
|
||||||
|
if (!std.process.can_spawn) return;
|
||||||
// Find the zig executable in PATH
|
// Find the zig executable in PATH
|
||||||
find_zig: {
|
find_zig: {
|
||||||
if (config.zig_exe_path) |exe_path| {
|
if (config.zig_exe_path) |exe_path| {
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 24845b0103e611c108d6bc334231c464e699742c
|
Subproject commit 6b37490ac7285133bf09441850b8102c9728a776
|
Loading…
Reference in New Issue
Block a user