use super::*;
pub struct UndefinedIdentifierRule;
impl Rule for UndefinedIdentifierRule {
fn display_name(&self) -> &'static str {
"Undefined Identifiers"
}
fn id(&self) -> &'static str {
"undefined-identifiers"
}
fn run(&self, context: &RuleContext<'_>) -> Vec<lsp::Diagnostic> {
let mut diagnostics = Vec::new();
for unresolved in context.unresolved_identifiers() {
diagnostics.push(self.diagnostic(lsp::Diagnostic {
range: unresolved.range,
severity: Some(lsp::DiagnosticSeverity::ERROR),
message: format!("Variable `{}` not found", unresolved.name),
..Default::default()
}));
}
diagnostics
}
}