fix: more-or-less readable errors + syntax check on sassy macro

This commit is contained in:
Yiffy Dev 2024-11-02 00:20:10 +05:00 • committed by spushk
commit 6eb9725583
Signed by: spushk
GPG key ID: 7797B761E105E8AA

View file

@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::quote;
use regex::Regex;
use sabry_intrnl::scoper::ArbitraryScope;
use syn::{parse::Parse, Ident};
use super::{ArbitraryStyleBlock, ArbitraryStyleSyntax};
@ -21,6 +21,14 @@ pub fn sassy_macro_impl(input: TokenStream) -> TokenStream {
Err(e) => return e.to_compile_error(),
};
// quick raffia syntax check
match ArbitraryScope::from_source(mode.into(), ident.clone(), &code.code) {
Ok(_) => {},
Err(e) => {
return syn::Error::new(code.span, format!("{e:?}")).into_compile_error()
}
}
let sourcesass = code.to_string();
let identname = ident.to_string();
let macro_doc = format!("Arbitrary {:?} code declared with `sassy!`. Pretty usable in tandem with `usey!` and `magic()` at build time", mode);