You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Posting this just to keep track on that annoying issue
The problem
Currently, using the "sass-in-rust" styling, like the following:
styly!(scope {
.sel1.sel2 {}});
One can't get proper scope:: autocompletion from rust-analyzer.
It seems to work with styly!(scope "path/to/file.scss") though.
The root of evil
While I was writing the parsing part of procmacro, I've noticed then styly! seems to receive nothing where brackets with the code should be, just like if I wrote bare styly!(scope );
Initially, the code which parses arbitrary style in brackets was:
// sabry_procmacro_impl/src/impls/mod.rs// impl Parse for ArbitraryStyleBlock// fn parselet _s;braced!(_s in input);let stream = _s.parse::<TokenStream>()?;let c = match stream.span().source_text(){Some(stx) => stx,// TODO: rust-analyzer does fall into this even if all is fineNone => returnErr(syn::Error::new(stream.span(),"Source code expected")),};
And that was the cause of editor false-positive error "Source code expected".
Now it looks like this:
let _s;braced!(_s in input);let stream = _s.parse::<TokenStream>()?;let c = match stream.span().source_text(){Some(stx) => stx,// TODO: rust-analyzer does fall into this even if all is fineNone => "".to_string(),//return Err(syn::Error::new(stream.span(), "Source code expected")),};
So i've just decided to treat None-ish tokenstream's source_text as empty sourcecode.
I'm completely unsure if that's the proper way to extract source code from the ParseBuffer.
I'm aware of the fact that we could just do the input.to_string() within the proc-macro itself, however that's not the case for sabry, as we do the scoping before CSS compilation and parsing the string again and again is a bad idea.
What to do next
It's very annoying not to have autocompletion for selectors, because the selector identifier in rusty scope doesn't always match the selector identifier in style code.
So I need to investigate -- why does it even happen with rust-analyzer, and why does it work as expected with rustc.
The text was updated successfully, but these errors were encountered:
Posting this just to keep track on that annoying issue
The problem
Currently, using the "sass-in-rust" styling, like the following:
One can't get proper
scope::autocompletion from rust-analyzer.It seems to work with
styly!(scope "path/to/file.scss")though.The root of evil
While I was writing the parsing part of procmacro, I've noticed then
styly!seems to receive nothing where brackets with the code should be, just like if I wrote barestyly!(scope );Initially, the code which parses arbitrary style in brackets was:
And that was the cause of editor false-positive error "Source code expected".
Now it looks like this:
So i've just decided to treat None-ish tokenstream's source_text as empty sourcecode.
I'm completely unsure if that's the proper way to extract source code from the ParseBuffer.
I'm aware of the fact that we could just do the
input.to_string()within the proc-macro itself, however that's not the case for sabry, as we do the scoping before CSS compilation and parsing the string again and again is a bad idea.What to do next
It's very annoying not to have autocompletion for selectors, because the selector identifier in rusty scope doesn't always match the selector identifier in style code.
So I need to investigate -- why does it even happen with rust-analyzer, and why does it work as expected with rustc.
The text was updated successfully, but these errors were encountered: