Skip to content

Commit 25a492c

Browse files
authored
Clean up misleading is_comment method (#782)
1 parent 21c255f commit 25a492c

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

librubyfmt/src/line_tokens.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ impl<'src> ConcreteLineToken<'src> {
213213
matches!(self, ConcreteLineToken::Indent { .. })
214214
}
215215

216-
pub fn is_comment(&self) -> bool {
217-
matches!(self, Self::Indent { .. })
218-
}
219-
220216
pub fn is_in_need_of_a_trailing_blankline(&self) -> bool {
221217
self.is_conditional_spaced_token() && !self.is_block_closing_token()
222218
}
@@ -259,9 +255,9 @@ impl<'src> ConcreteLineTokenAndTargets<'src> {
259255
}
260256
}
261257

262-
pub fn is_comment(&self) -> bool {
258+
pub fn is_indent(&self) -> bool {
263259
match self {
264-
Self::ConcreteLineToken(clt) => clt.is_comment(),
260+
Self::ConcreteLineToken(clt) => clt.is_indent(),
265261
_ => false,
266262
}
267263
}
@@ -359,9 +355,9 @@ impl<'src> AbstractLineToken<'src> {
359355
}
360356
}
361357

362-
pub fn is_comment(&self) -> bool {
358+
pub fn is_indent(&self) -> bool {
363359
match self {
364-
Self::ConcreteLineToken(clt) => clt.is_comment(),
360+
Self::ConcreteLineToken(clt) => clt.is_indent(),
365361
_ => false,
366362
}
367363
}

librubyfmt/src/render_targets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'src> BaseQueue<'src> {
4343
pub fn index_of_prev_newline(&self) -> Option<usize> {
4444
self.tokens
4545
.iter()
46-
.rposition(|v| v.is_newline() || v.is_comment())
46+
.rposition(|v| v.is_newline() || v.is_indent())
4747
}
4848
}
4949

@@ -62,7 +62,7 @@ pub trait AbstractTokenTarget<'src>: std::fmt::Debug {
6262
fn index_of_prev_newline(&self) -> Option<usize> {
6363
self.tokens()
6464
.iter()
65-
.rposition(|v| v.is_newline() || v.is_comment())
65+
.rposition(|v| v.is_newline() || v.is_indent())
6666
.map(|x| {
6767
let token = &self.tokens()[x];
6868
if matches!(token, AbstractLineToken::CollapsingNewLine(_))

0 commit comments

Comments
 (0)