Merge branch 'main' into typecheck-module-params

This commit is contained in:
Agus Zubiaga 2024-08-12 22:27:16 -03:00
commit b451e69b20
No known key found for this signature in database
53 changed files with 1814 additions and 1790 deletions

View file

@ -5,7 +5,7 @@ use crate::collection::{fmt_collection, Braces};
use crate::expr::fmt_str_literal;
use crate::spaces::{fmt_comments_only, fmt_default_spaces, fmt_spaces, NewlineAt, INDENT};
use crate::Buf;
use roc_parse::ast::{Collection, CommentOrNewline, Header, Module, Spaced, Spaces};
use roc_parse::ast::{Collection, CommentOrNewline, Header, Spaced, Spaces, SpacesBefore};
use roc_parse::header::{
AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword, HostedHeader, ImportsEntry,
ImportsKeyword, Keyword, KeywordItem, ModuleHeader, ModuleName, PackageEntry, PackageHeader,
@ -16,9 +16,9 @@ use roc_parse::header::{
use roc_parse::ident::UppercaseIdent;
use roc_region::all::Loc;
pub fn fmt_module<'a>(buf: &mut Buf<'_>, module: &'a Module<'a>) {
fmt_comments_only(buf, module.comments.iter(), NewlineAt::Bottom, 0);
match &module.header {
pub fn fmt_header<'a>(buf: &mut Buf<'_>, header: &'a SpacesBefore<'a, Header<'a>>) {
fmt_comments_only(buf, header.before.iter(), NewlineAt::Bottom, 0);
match &header.item {
Header::Module(header) => {
fmt_module_header(buf, header);
}

View file

@ -6,18 +6,11 @@ pub mod annotation;
pub mod collection;
pub mod def;
pub mod expr;
pub mod module;
pub mod header;
pub mod pattern;
pub mod spaces;
use bumpalo::{collections::String, Bump};
use roc_parse::ast::Module;
#[derive(Debug)]
pub struct Ast<'a> {
pub module: Module<'a>,
pub defs: roc_parse::ast::Defs<'a>,
}
#[derive(Debug)]
pub struct Buf<'a> {

View file

@ -1,7 +1,6 @@
use bumpalo::Bump;
use roc_parse::{ast::CommentOrNewline, remove_spaces::RemoveSpaces};
use roc_parse::ast::CommentOrNewline;
use crate::{Ast, Buf};
use crate::Buf;
/// The number of spaces to indent.
pub const INDENT: u16 = 4;
@ -192,12 +191,3 @@ fn fmt_docs(buf: &mut Buf, docs: &str) {
}
buf.push_str(docs.trim_end());
}
impl<'a> RemoveSpaces<'a> for Ast<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self {
Ast {
module: self.module.remove_spaces(arena),
defs: self.defs.remove_spaces(arena),
}
}
}