Archived
feat: el-ide — native IDE for engram-lang, LSP, type graph, plugin ecosystem
Axum HTTP server (port 7771) serving a single-page IDE with CodeMirror 6 syntax highlighting for engram-lang, a force-directed type graph visualizer, LSP (completions, hover, diagnostics), SSE-streamed build/run output, a plugin host with five first-party plugins, and a reasoning panel that proxies to engram-server. 28 tests across three crates, zero warnings.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
//! Diagnostic computation — wraps el-types TypeChecker output.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct Diagnostic {
|
||||
/// Human-readable message.
|
||||
pub message: String,
|
||||
/// "error" | "warning" | "info"
|
||||
pub severity: String,
|
||||
/// 1-based line number (if known).
|
||||
pub line: Option<u32>,
|
||||
/// 1-based column (if known).
|
||||
pub col: Option<u32>,
|
||||
}
|
||||
|
||||
impl Diagnostic {
|
||||
pub fn error(message: impl Into<String>) -> Self {
|
||||
Self { message: message.into(), severity: "error".into(), line: None, col: None }
|
||||
}
|
||||
|
||||
pub fn warning(message: impl Into<String>) -> Self {
|
||||
Self { message: message.into(), severity: "warning".into(), line: None, col: None }
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse and type-check `source`, returning all diagnostics.
|
||||
pub fn check(source: &str) -> Vec<Diagnostic> {
|
||||
let mut out = Vec::new();
|
||||
|
||||
let tokens = match el_lexer::tokenize(source) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
out.push(Diagnostic::error(format!("Lex error: {e}")));
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
let program = match el_parser::parse(tokens, source.to_string()) {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
out.push(Diagnostic::error(format!("Parse error: {e}")));
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
let mut checker = el_types::TypeChecker::with_builtins();
|
||||
checker.check(&program);
|
||||
|
||||
for d in &checker.diagnostics {
|
||||
if d.is_error {
|
||||
out.push(Diagnostic::error(&d.message));
|
||||
} else {
|
||||
out.push(Diagnostic::warning(&d.message));
|
||||
}
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
Reference in New Issue
Block a user