Hotreloading of for/if/body, formatted strings, literals, component props, nested rsx, light CLI rewrite, cli TUI (#2258)
Hotreload the contents of for loops, if chains, component bodies, props, attributes, and any literals discovered in rsx! Add a TUI renderer to the CLI. Improve the CLI build system to be async and parallel. Refactor RSX to allow partial expansion of expressions. Merge autofmt implementations for consistency. Merge the representation of elements and components under the hood. Add a diagnostics system for rsx for improved error messages. Drop interprocess and move to websockets for communication between the CLI and the server. Assign IDs to nodes and attributes in a stable way to be used in non compiler contexts. Add hotreloading to any body of component/for loop/if chain/etc. --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com> Co-authored-by: Liam Mitchell <liamkarlmitchell@gmail.com>
This commit is contained in:
181 files changed
+12755
-10806
No files matched your search
@@ -0,0 +1,46 @@
|
||||
use crate::{DynIdx, PartialExpr};
|
||||
use quote::{quote, ToTokens, TokenStreamExt};
|
||||
use syn::parse::Parse;
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
pub struct ExprNode {
|
||||
pub expr: PartialExpr,
|
||||
pub dyn_idx: DynIdx,
|
||||
}
|
||||
|
||||
impl ExprNode {
|
||||
pub fn span(&self) -> proc_macro2::Span {
|
||||
self.expr.span()
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for ExprNode {
|
||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
||||
Ok(Self {
|
||||
expr: input.parse()?,
|
||||
dyn_idx: DynIdx::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for ExprNode {
|
||||
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
|
||||
let expr = &self.expr;
|
||||
tokens.append_all(quote! {
|
||||
{ let ___nodes = (#expr).into_dyn_node(); ___nodes }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_commas() {
|
||||
use crate::PrettyUnparse;
|
||||
let input = quote! {
|
||||
div {
|
||||
{label("Hello, world!")},
|
||||
}
|
||||
};
|
||||
|
||||
let _expr: crate::BodyNode = syn::parse2(input).unwrap();
|
||||
println!("{}", _expr.to_token_stream().pretty_unparse());
|
||||
}
|
||||
Reference in new issue
Block a user