fix: when formatting and add some methods to Project::Error

This commit is contained in:
rvcas
2022-11-05 16:23:46 -04:00
parent 14724f924c
commit 9d14acbe0a
7 changed files with 40 additions and 17 deletions

View File

@@ -165,9 +165,9 @@ impl<'comments> Formatter<'comments> {
}
fn module<'a>(&mut self, module: &'a UntypedModule) -> Document<'a> {
let groups = self.definitions(&module.definitions);
let defs = self.definitions(&module.definitions);
// Now that `groups` has been collected, only freestanding comments (//)
// Now that `defs` has been collected, only freestanding comments (//)
// and doc comments (///) remain. Freestanding comments aren't associated
// with any statement, and are moved to the bottom of the module.
let doc_comments = join(
@@ -196,7 +196,7 @@ impl<'comments> Formatter<'comments> {
nil()
};
let non_empty = vec![module_comments, groups, doc_comments, comments]
let non_empty = vec![module_comments, defs, doc_comments, comments]
.into_iter()
.filter(|doc| !doc.is_empty());
@@ -753,10 +753,9 @@ impl<'comments> Formatter<'comments> {
subjects.iter().map(|s| self.wrap_expr(s)),
break_(",", ", "),
))
.append(break_(" is", " is "))
.nest(INDENT)
.append(break_("", " "))
.append("{")
.append("is {")
.group();
let clauses_doc = concat(

View File

@@ -226,6 +226,7 @@ pub fn fn_parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseEr
.then(
fn_param_parser()
.separated_by(just(Token::Comma))
.allow_trailing()
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
.map_with_span(|arguments, span| (arguments, span)),
)