summaryrefslogtreecommitdiff
path: root/src/diagnostics/unclosed_start_tag.rs
blob: db7e3fb7ac7d8597e3783b695044ca43cdb61b33 (plain)
use miette::Diagnostic;
use thiserror::Error;

use crate::{diagnostics::AstDiagnostic, parse::Element, tokenize::Span};

#[derive(Error, Debug, Diagnostic)]
#[error("The start tag was not closed")]
#[diagnostic(code(UnclosedStartTag), severity(Error))]
pub struct UnclosedStartTag {
	#[label("no matching end tag found")]
	start_tag: Span,
}

impl AstDiagnostic for UnclosedStartTag {
	fn handle_element(element: &Element<'_>) -> Option<Self> {
		if element.is_self_closing() || element.end_tag.is_some() {
			return None;
		}

		Some(Self {
			start_tag: element.start_tag.span,
		})
	}
}