Skip to main content

omena_parser/
language.rs

1//! Source language classification for style-bearing modules.
2//!
3//! This small boundary maps paths to CSS-family languages before dialect and
4//! source-projection layers perform deeper parsing.
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum StyleLanguage {
8    Css,
9    Scss,
10    Less,
11}
12
13impl StyleLanguage {
14    pub fn from_module_path(path: &str) -> Option<Self> {
15        if path.ends_with(".module.css") || path.ends_with(".css") {
16            Some(Self::Css)
17        } else if path.ends_with(".module.scss") || path.ends_with(".scss") {
18            Some(Self::Scss)
19        } else if path.ends_with(".module.less") || path.ends_with(".less") {
20            Some(Self::Less)
21        } else {
22            None
23        }
24    }
25}