mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Merge branch 'main' into store-all-space-between-annotation-body
This commit is contained in:
commit
125990855f
306 changed files with 12149 additions and 8820 deletions
|
@ -21,6 +21,12 @@ pub struct Spaces<'a, T> {
|
|||
pub after: &'a [CommentOrNewline<'a>],
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct SpacesBefore<'a, T> {
|
||||
pub before: &'a [CommentOrNewline<'a>],
|
||||
pub item: T,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum Spaced<'a, T> {
|
||||
Item(T),
|
||||
|
@ -1204,6 +1210,21 @@ impl<'a> Defs<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn loc_defs<'b>(
|
||||
&'b self,
|
||||
) -> impl Iterator<Item = Result<Loc<TypeDef<'a>>, Loc<ValueDef<'a>>>> + 'b {
|
||||
self.tags
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, tag)| match tag.split() {
|
||||
Ok(type_index) => Ok(Loc::at(self.regions[i], self.type_defs[type_index.index()])),
|
||||
Err(value_index) => Err(Loc::at(
|
||||
self.regions[i],
|
||||
self.value_defs[value_index.index()],
|
||||
)),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn list_value_defs(&self) -> impl Iterator<Item = (usize, &ValueDef<'a>)> {
|
||||
self.tags
|
||||
.iter()
|
||||
|
@ -2072,6 +2093,28 @@ pub trait Spaceable<'a> {
|
|||
fn before(&'a self, _: &'a [CommentOrNewline<'a>]) -> Self;
|
||||
fn after(&'a self, _: &'a [CommentOrNewline<'a>]) -> Self;
|
||||
|
||||
fn maybe_before(self, arena: &'a Bump, spaces: &'a [CommentOrNewline<'a>]) -> Self
|
||||
where
|
||||
Self: Sized + 'a,
|
||||
{
|
||||
if spaces.is_empty() {
|
||||
self
|
||||
} else {
|
||||
arena.alloc(self).before(spaces)
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe_after(self, arena: &'a Bump, spaces: &'a [CommentOrNewline<'a>]) -> Self
|
||||
where
|
||||
Self: Sized + 'a,
|
||||
{
|
||||
if spaces.is_empty() {
|
||||
self
|
||||
} else {
|
||||
arena.alloc(self).after(spaces)
|
||||
}
|
||||
}
|
||||
|
||||
fn with_spaces_before(&'a self, spaces: &'a [CommentOrNewline<'a>], region: Region) -> Loc<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue