Skip to content

Commit

Permalink
fmt: rust code
Browse files Browse the repository at this point in the history
  • Loading branch information
LastLeaf committed Jun 20, 2024
1 parent 07110ad commit 917fbed
Showing 1 changed file with 77 additions and 23 deletions.
100 changes: 77 additions & 23 deletions glass-easel-template-compiler/src/parse/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ impl Element {
) {
match element {
ElementKind::Normal { common, .. } | ElementKind::Slot { common, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
common.event_bindings.push(EventBinding {
name: attr_name,
value,
Expand All @@ -846,7 +848,9 @@ impl Element {
| ElementKind::Slot {
values: attributes, ..
} => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if attributes
.iter()
.find(|x| x.name.name_eq(&attr_name))
Expand Down Expand Up @@ -878,15 +882,20 @@ impl Element {
},
AttrPrefixKind::Id => match &mut element {
ElementKind::Normal { common, .. } | ElementKind::Slot { common, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if common.id.is_some() {
ps.add_warning(
ParseErrorKind::DuplicatedAttribute,
attr_name.location,
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
common.id = Some((attr_name.location(), value));
}
Expand Down Expand Up @@ -930,7 +939,9 @@ impl Element {
},
AttrPrefixKind::ClassString => match &mut element {
ElementKind::Normal { class, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if let ClassAttribute::Multiple(..) | ClassAttribute::String(..) =
class
{
Expand All @@ -940,7 +951,10 @@ impl Element {
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
*class = ClassAttribute::String(attr_name.location(), value);
}
Expand All @@ -957,7 +971,9 @@ impl Element {
},
AttrPrefixKind::StyleString => match &mut element {
ElementKind::Normal { style, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if let StyleAttribute::Multiple(..) | StyleAttribute::String(..) =
style
{
Expand All @@ -967,7 +983,10 @@ impl Element {
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
*style = StyleAttribute::String(attr_name.location(), value);
}
Expand All @@ -983,30 +1002,40 @@ impl Element {
}
},
AttrPrefixKind::WxIf => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if wx_if.is_some() {
ps.add_warning(
ParseErrorKind::DuplicatedAttribute,
attr_name.location,
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
wx_if = Some((attr_name.location(), value));
}
}
}
AttrPrefixKind::WxElif => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if wx_elif.is_some() {
ps.add_warning(
ParseErrorKind::DuplicatedAttribute,
attr_name.location,
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
wx_elif = Some((attr_name.location(), value));
}
Expand All @@ -1031,15 +1060,20 @@ impl Element {
}
}
AttrPrefixKind::WxFor => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if wx_for.is_some() {
ps.add_warning(
ParseErrorKind::DuplicatedAttribute,
attr_name.location,
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
wx_for = Some((attr_name.location(), value));
}
Expand Down Expand Up @@ -1101,15 +1135,20 @@ impl Element {
}
AttrPrefixKind::TemplateIs => match &mut element {
ElementKind::TemplateRef { target, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if target.1.location().end != default_attr_position {
ps.add_warning(
ParseErrorKind::DuplicatedAttribute,
attr_name.location,
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
*target = (attr_name.location(), value);
}
Expand All @@ -1119,15 +1158,20 @@ impl Element {
},
AttrPrefixKind::TemplateData => match &mut element {
ElementKind::TemplateRef { data, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if data.1.location().end != default_attr_position {
ps.add_warning(
ParseErrorKind::DuplicatedAttribute,
attr_name.location,
);
} else {
if is_value_unspecified {
ps.add_warning(ParseErrorKind::MissingAttributeValue, attr_name.location.clone());
ps.add_warning(
ParseErrorKind::MissingAttributeValue,
attr_name.location.clone(),
);
}
*data = (attr_name.location(), value);
}
Expand Down Expand Up @@ -1191,7 +1235,9 @@ impl Element {
},
AttrPrefixKind::Model(prefix_location) => match &mut element {
ElementKind::Normal { attributes, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if attributes
.iter()
.find(|x| x.name.name_eq(&attr_name))
Expand Down Expand Up @@ -1226,7 +1272,9 @@ impl Element {
ElementKind::Normal {
change_attributes, ..
} => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if change_attributes
.iter()
.find(|x| x.name.name_eq(&attr_name))
Expand Down Expand Up @@ -1290,7 +1338,9 @@ impl Element {
},
AttrPrefixKind::Data(prefix_location) => match &mut element {
ElementKind::Normal { data, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if data
.iter()
.find(|attr| attr.name.name_eq(&attr_name))
Expand Down Expand Up @@ -1322,7 +1372,9 @@ impl Element {
},
AttrPrefixKind::DataHyphen => match &mut element {
ElementKind::Normal { data, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if data
.iter()
.find(|attr| attr.name.name_eq(&attr_name))
Expand Down Expand Up @@ -1480,7 +1532,9 @@ impl Element {
}
AttrPrefixKind::Mark(prefix_location) => match &mut element {
ElementKind::Normal { common, .. } | ElementKind::Slot { common, .. } => {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) = attr_value {
if let AttrPrefixParseResult::Value(value, is_value_unspecified) =
attr_value
{
if common
.marks
.iter()
Expand Down

0 comments on commit 917fbed

Please sign in to comment.