From c0e446d73b445a615c1dd55f095d0b879a13f289 Mon Sep 17 00:00:00 2001 From: Andrew Frantz Date: Wed, 15 Jan 2025 12:39:38 -0500 Subject: [PATCH] revise: more specific name for line spacing policy --- wdl-format/src/token/post.rs | 10 +++++----- wdl-format/src/token/pre.rs | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/wdl-format/src/token/post.rs b/wdl-format/src/token/post.rs index 185cef44..9747782c 100644 --- a/wdl-format/src/token/post.rs +++ b/wdl-format/src/token/post.rs @@ -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]; @@ -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, @@ -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); } diff --git a/wdl-format/src/token/pre.rs b/wdl-format/src/token/pre.rs index 7996d4c7..a09c3214 100644 --- a/wdl-format/src/token/pre.rs +++ b/wdl-format/src/token/pre.rs @@ -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. /// @@ -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, SyntaxKind), @@ -133,14 +133,15 @@ impl TokenStream { /// 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, )); }