Archived
376fbb41b3
Round 1: Fix dependency paths (../el/crates → ../el/engrams), verify build Round 2: Enhanced syntax highlighting — function call detection, all El keywords (activate, sealed, parallel, deploy, etc.) Round 3: Full El keyword set in CodeMirror tokenizer and completions; 50+ builtin function completions with type signatures Round 4: File system integration — mkdir, rename, delete, file tree search; git status badges Round 5: Runner integration — Ctrl+R shortcut, SSE streaming output, clickable error lines with jump-to-line Round 6: Error highlighting with accurate line/col from lexer/parser spans; diagnostic dedup Round 7: Find/replace panel; Ctrl+G go-to-line; toggle line comment; word-wrap compartment fix Round 8: Code completion — 50+ builtins, keyword completions, snippet completions, server snippet integration Round 9: Resizable panels — file tree drag-resize + collapse (Ctrl+B), type-graph drag-resize, bottom panel toggle (Ctrl+J), width persistence Round 10: Settings API (GET/POST/DELETE /api/settings, ~/.el-ide/settings.json); frontend wired to API with debounced save; theme persistence Round 11: Minimap click-to-jump and drag-to-scroll Round 12: Command palette — added Go To Line, Toggle Word Wrap/Minimap/File Tree/Bottom Panel, font size commands, New File, Select Next Occurrence Round 13: Multi-cursor — Ctrl+D select next occurrence, EditorSelection exposed for multi-range selection
70 lines
1.9 KiB
Rust
70 lines
1.9 KiB
Rust
//! 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 {
|
|
message: format!("Lex error: {}", e.kind),
|
|
severity: "error".into(),
|
|
line: Some(e.span.line),
|
|
col: Some(e.span.col),
|
|
});
|
|
return out;
|
|
}
|
|
};
|
|
|
|
let program = match el_parser::parse(tokens, source.to_string()) {
|
|
Ok(p) => p,
|
|
Err(e) => {
|
|
out.push(Diagnostic {
|
|
message: format!("Parse error: {}", e.kind),
|
|
severity: "error".into(),
|
|
line: Some(e.span.line),
|
|
col: Some(e.span.col),
|
|
});
|
|
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
|
|
}
|