Skip to content

Commit

Permalink
revise: more specific name for line spacing policy
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frantz committed Jan 15, 2025
1 parent 5a42020 commit c0e446d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions wdl-format/src/token/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use wdl_ast::SyntaxKind;

use crate::Comment;
use crate::Config;
use crate::LineSpacingPolicy;
use crate::NEWLINE;
use crate::PreToken;
use crate::SPACE;
use crate::Token;
use crate::TokenStream;
use crate::Trivia;
use crate::TriviaBlankLineSpacingPolicy;

/// [`PostToken`]s that precede an inline comment.
const INLINE_COMMENT_PRECEDING_TOKENS: [PostToken; 2] = [PostToken::Space, PostToken::Space];
Expand Down Expand Up @@ -200,8 +200,8 @@ pub struct Postprocessor {
/// Whether the current line has been interrupted by trivia.
interrupted: bool,

/// The line spacing policy.
line_spacing_policy: LineSpacingPolicy,
/// The current trivial blank line spacing policy.
line_spacing_policy: TriviaBlankLineSpacingPolicy,

/// Whether temporary indentation is needed.
temp_indent_needed: bool,
Expand Down Expand Up @@ -324,10 +324,10 @@ impl Postprocessor {
}
PreToken::Trivia(trivia) => match trivia {
Trivia::BlankLine => match self.line_spacing_policy {
LineSpacingPolicy::Always => {
TriviaBlankLineSpacingPolicy::Always => {
self.blank_line(stream);
}
LineSpacingPolicy::BeforeComments => {
TriviaBlankLineSpacingPolicy::BeforeComments => {
if matches!(next, Some(&PreToken::Trivia(Trivia::Comment(_)))) {
self.blank_line(stream);
}
Expand Down
13 changes: 7 additions & 6 deletions wdl-format/src/token/pre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use wdl_ast::SyntaxKind;
use wdl_ast::SyntaxTokenExt;

use crate::Comment;
use crate::LineSpacingPolicy;
use crate::Token;
use crate::TokenStream;
use crate::Trivia;
use crate::TriviaBlankLineSpacingPolicy;

/// A token that can be written by elements.
///
Expand All @@ -36,8 +36,8 @@ pub enum PreToken {
/// The end of an indented block.
IndentEnd,

/// How to handle blank lines from this point onwards.
LineSpacingPolicy(LineSpacingPolicy),
/// How to handle trivial blank lines from this point onwards.
LineSpacingPolicy(TriviaBlankLineSpacingPolicy),

/// Literal text.
Literal(Rc<String>, SyntaxKind),
Expand Down Expand Up @@ -133,14 +133,15 @@ impl TokenStream<PreToken> {

/// Inserts a blank lines allowed context change.
pub fn blank_lines_allowed(&mut self) {
self.0
.push(PreToken::LineSpacingPolicy(LineSpacingPolicy::Always));
self.0.push(PreToken::LineSpacingPolicy(
TriviaBlankLineSpacingPolicy::Always,
));
}

/// Inserts a blank lines allowed before comments context change.
pub fn blank_lines_allowed_between_comments(&mut self) {
self.0.push(PreToken::LineSpacingPolicy(
LineSpacingPolicy::BeforeComments,
TriviaBlankLineSpacingPolicy::BeforeComments,
));
}

Expand Down

0 comments on commit c0e446d

Please sign in to comment.