Skip to content

Commit 5c7d4f6

Browse files
authored
Rename CommentDirectives to CommentsExt (#426)
1 parent 9a67317 commit 5c7d4f6

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

crates/air_r_formatter/src/directives.rs renamed to crates/air_r_formatter/src/comments_ext.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@ use settings::Table;
1212
use crate::RFormatter;
1313
use crate::comments::RComments;
1414

15-
/// Extension trait for comment [comments::Directive]s
16-
pub trait CommentDirectives {
15+
/// Extension trait for [biome_formatter::Comments]
16+
///
17+
/// Currently this is for extending [biome_formatter::Comments] with knowledge about our
18+
/// comment directives
19+
pub trait CommentsExt {
1720
type Language: Language;
1821

22+
/// Does this node contain a `# fmt: skip` directive?
1923
fn has_skip_directive(&self, node: &SyntaxNode<Self::Language>) -> bool;
2024

25+
/// Does this node contain a `# fmt: table` directive?
2126
fn has_table_directive(&self, node: &SyntaxNode<Self::Language>) -> bool;
2227
}
2328

24-
impl CommentDirectives for RComments {
29+
impl CommentsExt for RComments {
2530
type Language = RLanguage;
2631

2732
fn has_skip_directive(&self, node: &SyntaxNode<Self::Language>) -> bool {
@@ -67,6 +72,7 @@ fn can_have_directive(node: &RSyntaxNode) -> bool {
6772
)
6873
}
6974

75+
/// Is the name of this function call contained within the `skip` `air.toml` setting?
7076
pub(crate) fn in_skip_setting(node: &RCall, f: &RFormatter) -> SyntaxResult<bool> {
7177
fn pred(node: RIdentifier, skip: &Skip) -> SyntaxResult<bool> {
7278
let node = node.name_token()?;
@@ -76,6 +82,7 @@ pub(crate) fn in_skip_setting(node: &RCall, f: &RFormatter) -> SyntaxResult<bool
7682
in_setting(node, f.options().skip(), pred)
7783
}
7884

85+
/// Is the name of this function call contained within the `table` `air.toml` setting?
7986
pub(crate) fn in_table_setting(node: &RCall, f: &RFormatter) -> SyntaxResult<bool> {
8087
fn pred(node: RIdentifier, table: &Table) -> SyntaxResult<bool> {
8188
let node = node.name_token()?;

crates/air_r_formatter/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ use biome_formatter::write;
1313
use biome_rowan::AstNode;
1414

1515
use crate::comments::RCommentStyle;
16+
use crate::comments_ext::CommentsExt;
1617
use crate::context::RFormatContext;
1718
use crate::context::RFormatOptions;
1819
use crate::cst::FormatRSyntaxNode;
19-
use crate::directives::CommentDirectives;
2020

2121
pub mod comments;
22+
pub mod comments_ext;
2223
pub mod context;
2324
mod cst;
24-
pub mod directives;
2525
pub mod either;
2626
pub mod formatter_ext;
2727
pub mod joiner_ext;

crates/air_r_formatter/src/r/auxiliary/binary_expression.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::comments_ext::CommentsExt;
12
use crate::context::RFormatOptions;
2-
use crate::directives::CommentDirectives;
33
use crate::either::Either;
44
use crate::prelude::*;
55
use crate::r::auxiliary::call_arguments::FormatRCallArgumentsOptions;
@@ -85,7 +85,9 @@ impl FormatNodeRule<RBinaryExpression> for FormatRBinaryExpression {
8585
| RSyntaxKind::ASSIGN
8686
| RSyntaxKind::ASSIGN_RIGHT
8787
| RSyntaxKind::SUPER_ASSIGN
88-
| RSyntaxKind::SUPER_ASSIGN_RIGHT => fmt_binary_assignment(node, left, operator, right, f),
88+
| RSyntaxKind::SUPER_ASSIGN_RIGHT => {
89+
fmt_binary_assignment(node, left, operator, right, f)
90+
}
8991

9092
// Chainable (pipes, logical, arithmetic)
9193
kind if is_chainable_binary_operator(kind) => {

crates/air_r_formatter/src/r/auxiliary/call.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::directives::CommentDirectives;
2-
use crate::directives::in_skip_setting;
3-
use crate::directives::in_table_setting;
1+
use crate::comments_ext::CommentsExt;
2+
use crate::comments_ext::in_skip_setting;
3+
use crate::comments_ext::in_table_setting;
44
use crate::prelude::*;
55
use crate::r::auxiliary::call_arguments::FormatRCallArgumentsOptions;
66

crates/air_r_formatter/src/r/auxiliary/unary_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::directives::CommentDirectives;
1+
use crate::comments_ext::CommentsExt;
22
use crate::prelude::*;
33
use air_r_syntax::AnyRExpression;
44
use air_r_syntax::RSyntaxKind;

0 commit comments

Comments
 (0)