mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
cleanup
This commit is contained in:
parent
d6bdb45c82
commit
ba38d4ec14
4 changed files with 76 additions and 244 deletions
|
@ -1,5 +1,4 @@
|
|||
use crate::annotation::{fmt_annotation, Formattable, Newlines, Parens};
|
||||
use crate::expr::fmt_expr;
|
||||
use crate::annotation::{Formattable, Newlines, Parens};
|
||||
use crate::pattern::fmt_pattern;
|
||||
use crate::spaces::{fmt_spaces, is_comment, newline, INDENT};
|
||||
use bumpalo::collections::String;
|
||||
|
@ -88,21 +87,24 @@ pub fn fmt_body<'a>(
|
|||
body: &'a Expr<'a>,
|
||||
indent: u16,
|
||||
) {
|
||||
fmt_pattern(buf, pattern, indent, Parens::InApply);
|
||||
pattern.format_with_options(buf, Parens::InApply, Newlines::No, indent);
|
||||
buf.push_str(" =");
|
||||
if body.is_multiline() {
|
||||
match body {
|
||||
Expr::SpaceBefore(_, _) => {
|
||||
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent + INDENT);
|
||||
}
|
||||
Expr::Record { .. } | Expr::List(_) => {
|
||||
newline(buf, indent + INDENT);
|
||||
fmt_expr(buf, body, indent + INDENT, false, true);
|
||||
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent + INDENT);
|
||||
}
|
||||
_ => {
|
||||
buf.push(' ');
|
||||
fmt_expr(buf, body, indent, false, true);
|
||||
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buf.push(' ');
|
||||
fmt_expr(buf, body, indent, false, true);
|
||||
body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue