refactor(sema): seal sema.zig as editor indexing only (A8.1)
Remove the last compiler dependency on sema as semantic truth and stop publishing as-you-type sema diagnostics from the LSP. - core.zig: drop dead `Compilation.analyze()`, the `sema_result` field, and the sema->diagnostics merge; drop the now-orphaned sema import. The CLI pipeline (parse -> resolveImports -> generateCode) never called analyze(), so this removes only dead code. - lsp/server.zig: rename `analyzeAndPublish` -> `refreshEditorIndex` and delete its sema-diagnostic publish (and the now-unused `semaToLspDiags`). The editor index (doc.sema) is still refreshed for nav/refs/completion/ tokens. On-save/on-open diagnostics still come solely from the canonical compiler pipeline in `runProjectCheck` (unchanged). - Document sema as an editor-indexing API (doc.sema field comment). Intended behavior change: as-you-type sema diagnostics no longer publish; on-save canonical diagnostics are the sole source. CLI compile output and the 361-example suite are unchanged (361/0, zero snapshot churn).
This commit is contained in:
14
src/core.zig
14
src/core.zig
@@ -2,7 +2,6 @@ const std = @import("std");
|
||||
const ast = @import("ast.zig");
|
||||
const parser = @import("parser.zig");
|
||||
const imports = @import("imports.zig");
|
||||
const sema = @import("sema.zig");
|
||||
const errors = @import("errors.zig");
|
||||
const c_import = @import("c_import.zig");
|
||||
const ir = @import("ir/ir.zig");
|
||||
@@ -27,7 +26,6 @@ pub const Compilation = struct {
|
||||
import_sources: std.StringHashMap([:0]const u8),
|
||||
module_scopes: std.StringHashMap(std.StringHashMap(void)),
|
||||
import_graph: std.StringHashMap(std.StringHashMap(void)),
|
||||
sema_result: ?sema.SemaResult = null,
|
||||
ir_emitter: ?ir.LLVMEmitter = null,
|
||||
/// Lowered IR module, kept alive past `generateCode` so post-link
|
||||
/// callbacks can re-enter the interpreter to invoke sx functions
|
||||
@@ -128,18 +126,6 @@ pub const Compilation = struct {
|
||||
self.resolved_root = new_root;
|
||||
}
|
||||
|
||||
pub fn analyze(self: *Compilation) !void {
|
||||
const root = self.resolved_root orelse self.root orelse return error.CompileError;
|
||||
var analyzer = sema.Analyzer.init(self.allocator);
|
||||
self.sema_result = analyzer.analyze(root) catch return error.CompileError;
|
||||
// Merge sema diagnostics into our list
|
||||
if (self.sema_result) |sr| {
|
||||
for (sr.diagnostics) |d| {
|
||||
self.diagnostics.add(d.level, d.message, d.span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate code via the IR pipeline: lower AST → IR → LLVM.
|
||||
pub fn generateCode(self: *Compilation) !void {
|
||||
// Heap-allocate the IR module so its address is stable during emit
|
||||
|
||||
Reference in New Issue
Block a user