mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Parse and format inline ingested file imports
This commit is contained in:
parent
42e755677c
commit
4d6e641864
10 changed files with 165 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
use crate::annotation::{is_collection_multiline, Formattable, Newlines, Parens};
|
||||
use crate::collection::{fmt_collection, Braces};
|
||||
use crate::expr::fmt_str_literal;
|
||||
use crate::pattern::fmt_pattern;
|
||||
use crate::spaces::{fmt_default_newline, fmt_default_spaces, fmt_spaces, INDENT};
|
||||
use crate::Buf;
|
||||
|
@ -287,6 +288,11 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
a.keyword.is_multiline() || is_collection_multiline(&a.item)
|
||||
})
|
||||
}
|
||||
IngestedFileImport {
|
||||
before_path,
|
||||
path: _,
|
||||
name,
|
||||
} => !before_path.is_empty() || name.is_multiline(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,6 +371,20 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
fmt_collection(buf, list_indent, Braces::Square, exposed.item, Newlines::No);
|
||||
}
|
||||
}
|
||||
IngestedFileImport {
|
||||
before_path,
|
||||
path,
|
||||
name,
|
||||
} => {
|
||||
buf.indent(indent);
|
||||
buf.push_str("import");
|
||||
|
||||
let indent = indent + INDENT;
|
||||
|
||||
fmt_default_spaces(buf, before_path, indent);
|
||||
fmt_str_literal(buf, path.value, indent);
|
||||
name.format(buf, indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue