s/demands/members

This commit is contained in:
Ayaz Hafiz 2022-04-06 11:34:14 -04:00
parent bd8333ebb1
commit eee19bba2b
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58
2 changed files with 12 additions and 12 deletions

View File

@ -10,7 +10,7 @@ use roc_fmt::module::fmt_module;
use roc_fmt::Buf;
use roc_module::called_via::{BinOp, UnaryOp};
use roc_parse::ast::{
AbilityDemand, AssignedField, Collection, Expr, Has, HasClause, Pattern, Spaced, StrLiteral,
AbilityMember, AssignedField, Collection, Expr, Has, HasClause, Pattern, Spaced, StrLiteral,
StrSegment, Tag, TypeAnnotation, TypeHeader, WhenBranch,
};
use roc_parse::header::{
@ -491,14 +491,14 @@ impl<'a> RemoveSpaces<'a> for Def<'a> {
Def::Ability {
header: TypeHeader { name, vars },
loc_has,
demands,
members,
} => Def::Ability {
header: TypeHeader {
name: name.remove_spaces(arena),
vars: vars.remove_spaces(arena),
},
loc_has: loc_has.remove_spaces(arena),
demands: demands.remove_spaces(arena),
members: members.remove_spaces(arena),
},
Def::Expect(a) => Def::Expect(arena.alloc(a.remove_spaces(arena))),
Def::NotYetImplemented(a) => Def::NotYetImplemented(a),
@ -513,9 +513,9 @@ impl<'a> RemoveSpaces<'a> for Has<'a> {
}
}
impl<'a> RemoveSpaces<'a> for AbilityDemand<'a> {
impl<'a> RemoveSpaces<'a> for AbilityMember<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self {
AbilityDemand {
AbilityMember {
name: self.name.remove_spaces(arena),
typ: self.typ.remove_spaces(arena),
}

View File

@ -2,7 +2,7 @@ use crate::annotation::{Formattable, Newlines, Parens};
use crate::pattern::fmt_pattern;
use crate::spaces::{fmt_spaces, INDENT};
use crate::Buf;
use roc_parse::ast::{AbilityDemand, Def, Expr, ExtractSpaces, Pattern, TypeHeader};
use roc_parse::ast::{AbilityMember, Def, Expr, ExtractSpaces, Pattern, TypeHeader};
use roc_region::all::Loc;
/// A Located formattable value is also formattable
@ -22,7 +22,7 @@ impl<'a> Formattable for Def<'a> {
SpaceBefore(sub_def, spaces) | SpaceAfter(sub_def, spaces) => {
spaces.iter().any(|s| s.is_comment()) || sub_def.is_multiline()
}
Ability { demands, .. } => demands.iter().any(|d| d.is_multiline()),
Ability { members, .. } => members.iter().any(|d| d.is_multiline()),
NotYetImplemented(s) => todo!("{}", s),
}
}
@ -87,7 +87,7 @@ impl<'a> Formattable for Def<'a> {
Ability {
header: TypeHeader { name, vars },
loc_has: _,
demands,
members,
} => {
buf.indent(indent);
buf.push_str(name.value);
@ -99,11 +99,11 @@ impl<'a> Formattable for Def<'a> {
buf.push_str(" has");
if !self.is_multiline() {
debug_assert_eq!(demands.len(), 1);
debug_assert_eq!(members.len(), 1);
buf.push_str(" ");
demands[0].format(buf, indent + INDENT);
members[0].format(buf, indent + INDENT);
} else {
for demand in demands.iter() {
for demand in members.iter() {
buf.newline();
buf.indent(indent + INDENT);
demand.format(buf, indent + INDENT);
@ -195,7 +195,7 @@ pub fn fmt_body<'a, 'buf>(
}
}
impl<'a> Formattable for AbilityDemand<'a> {
impl<'a> Formattable for AbilityMember<'a> {
fn is_multiline(&self) -> bool {
self.name.value.is_multiline() || self.typ.is_multiline()
}