use lsp_types::{Diagnostic, DiagnosticSeverity};
use crate::ir::analysis::type_checker::{TypeCheckResult, TypeErrorSeverity};
use super::helpers::create_diagnostic;
pub fn type_errors_to_diagnostics(type_result: &TypeCheckResult) -> Vec<Diagnostic> {
type_result
.errors
.iter()
.map(|err| {
let severity = match err.severity {
TypeErrorSeverity::Warning => DiagnosticSeverity::WARNING,
TypeErrorSeverity::Error => DiagnosticSeverity::ERROR,
};
create_diagnostic(
err.location.start_line,
err.location.start_column,
err.message.clone(),
severity,
)
})
.collect()
}