Fix format for the 'as' keyword

This commit is contained in:
JRI98 2023-12-07 10:40:40 +00:00
parent 5652d4ec18
commit 0599066865
No known key found for this signature in database
GPG key ID: F83B29916FF13F24
2 changed files with 46 additions and 6 deletions

View file

@ -5,8 +5,8 @@ use roc_parse::{
ast::{
AbilityImpls, AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr,
Header, Implements, ImplementsAbilities, ImplementsAbility, ImplementsClause, Module,
Pattern, RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation,
TypeDef, TypeHeader, ValueDef, WhenBranch,
Pattern, PatternAs, RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag,
TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch,
},
header::{
AppHeader, ExposedName, HostedHeader, ImportsEntry, InterfaceHeader, KeywordItem,
@ -800,9 +800,10 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
Pattern::OptionalField(a, b) => {
Pattern::OptionalField(a, arena.alloc(b.remove_spaces(arena)))
}
Pattern::As(pattern, pattern_as) => {
Pattern::As(arena.alloc(pattern.remove_spaces(arena)), pattern_as)
}
Pattern::As(pattern, pattern_as) => Pattern::As(
arena.alloc(pattern.remove_spaces(arena)),
pattern_as.remove_spaces(arena),
),
Pattern::NumLiteral(a) => Pattern::NumLiteral(a),
Pattern::NonBase10Literal {
string,
@ -826,7 +827,10 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
Pattern::SingleQuote(a) => Pattern::SingleQuote(a),
Pattern::List(pats) => Pattern::List(pats.remove_spaces(arena)),
Pattern::Tuple(pats) => Pattern::Tuple(pats.remove_spaces(arena)),
Pattern::ListRest(opt_pattern_as) => Pattern::ListRest(opt_pattern_as),
Pattern::ListRest(opt_pattern_as) => Pattern::ListRest(
opt_pattern_as
.map(|(_, pattern_as)| ([].as_ref(), pattern_as.remove_spaces(arena))),
),
}
}
}
@ -936,3 +940,12 @@ impl<'a> RemoveSpaces<'a> for ImplementsAbilities<'a> {
}
}
}
impl<'a> RemoveSpaces<'a> for PatternAs<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self {
PatternAs {
spaces_before: &[],
identifier: self.identifier.remove_spaces(arena),
}
}
}