Fixes to autofmt, make it more aggressive (#2230)
* fix: fmt unterminated if, be more aggressive with line splits * Fix: Handle long exprs in for/if statements
This commit is contained in:
1 parent
46b0eeb12c
commit
be99e29e5f
31 files changed
+464
-117
No files matched your search
@@ -208,6 +208,26 @@ pub struct ElementAttr {
|
||||
pub value: ElementAttrValue,
|
||||
}
|
||||
|
||||
impl ElementAttr {
|
||||
pub fn can_be_shorthand(&self) -> bool {
|
||||
// If it's a shorthand...
|
||||
if matches!(self.value, ElementAttrValue::Shorthand(_)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If it's in the form of attr: attr, return true
|
||||
if let ElementAttrValue::AttrExpr(Expr::Path(path)) = &self.value {
|
||||
if let ElementAttrName::BuiltIn(name) = &self.name {
|
||||
if path.path.segments.len() == 1 && &path.path.segments[0].ident == name {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
||||
pub enum ElementAttrValue {
|
||||
/// attribute,
|
||||
@@ -269,6 +289,10 @@ impl ToTokens for ElementAttrValue {
|
||||
}
|
||||
|
||||
impl ElementAttrValue {
|
||||
pub fn is_shorthand(&self) -> bool {
|
||||
matches!(self, ElementAttrValue::Shorthand(_))
|
||||
}
|
||||
|
||||
fn to_str_expr(&self) -> Option<TokenStream2> {
|
||||
match self {
|
||||
ElementAttrValue::AttrLiteral(lit) => Some(quote!(#lit.to_string())),
|
||||
|
||||
Reference in new issue
Block a user