Fix: #2604, Fix: #2240, Fix: #2341, Fix #1355 - Better error handling and and spaces handling in autofmt (#2736)

* add new autofmt sample
* Feat: implement rustfmt::skip support for rsx
* generally improve error handling with better expect messages
* wip: nested rsx formatting and expression formatting
* nested rsx formatting works
* collapse autofmt crate
* cast indent through macros
* use proper whitespace
* no more eating comments!
* Use proper error handling
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-07-30 18:36:13 -07:00
1 parent ef0202f999
commit 828cc502f1
47 files changed
+1621 -1055

No files matched your search

+9 -1
View File
@@ -1,3 +1,5 @@
#![allow(deprecated)]
use dioxus_autofmt::{IndentOptions, IndentType};
macro_rules! twoway {
@@ -6,7 +8,12 @@ macro_rules! twoway {
fn $name() {
let src_right = include_str!(concat!("./wrong/", $val, ".rsx"));
let src_wrong = include_str!(concat!("./wrong/", $val, ".wrong.rsx"));
let formatted = dioxus_autofmt::fmt_file(src_wrong, $indent);
let parsed = syn::parse_file(src_wrong)
.expect("fmt_file should only be called on valid syn::File files");
let formatted =
dioxus_autofmt::try_fmt_file(src_wrong, &parsed, $indent).unwrap_or_default();
let out = dioxus_autofmt::apply_formats(src_wrong, formatted);
// normalize line endings
@@ -31,3 +38,4 @@ twoway!("simple-combo-expr" => simple_combo_expr (IndentOptions::new(IndentType:
twoway!("oneline-expand" => online_expand (IndentOptions::new(IndentType::Spaces, 4, false)));
twoway!("shortened" => shortened (IndentOptions::new(IndentType::Spaces, 4, false)));
twoway!("syntax_error" => syntax_error (IndentOptions::new(IndentType::Spaces, 4, false)));
twoway!("skipfail" => skipfail (IndentOptions::new(IndentType::Spaces, 4, false)));