mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Introduce Collection as a general abstraction in the ast
This commit is contained in:
parent
ac733b1805
commit
04d4a8ca79
10 changed files with 49 additions and 37 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::spaces::{fmt_comments_only, fmt_spaces, newline, NewlineAt, INDENT};
|
||||
use bumpalo::collections::String;
|
||||
use roc_parse::ast::{AssignedField, Expr, Tag, TypeAnnotation};
|
||||
use roc_parse::ast::{AssignedField, Expr, Tag, TypeAnnotation, Collection};
|
||||
use roc_region::all::Located;
|
||||
|
||||
/// Does an AST node need parens around it?
|
||||
|
@ -186,14 +186,13 @@ impl<'a> Formattable<'a> for TypeAnnotation<'a> {
|
|||
Record {
|
||||
fields,
|
||||
ext,
|
||||
final_comments: _,
|
||||
} => {
|
||||
match ext {
|
||||
Some(ann) if ann.value.is_multiline() => return true,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
fields.iter().any(|field| field.value.is_multiline())
|
||||
fields.items.iter().any(|field| field.value.is_multiline())
|
||||
}
|
||||
|
||||
TagUnion {
|
||||
|
@ -296,16 +295,15 @@ impl<'a> Formattable<'a> for TypeAnnotation<'a> {
|
|||
}
|
||||
|
||||
Record {
|
||||
fields,
|
||||
fields: Collection { items, final_comments },
|
||||
ext,
|
||||
final_comments,
|
||||
} => {
|
||||
format_sequence!(
|
||||
buf,
|
||||
indent,
|
||||
'{',
|
||||
'}',
|
||||
fields,
|
||||
items,
|
||||
final_comments,
|
||||
newlines,
|
||||
AssignedField
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue