From d82a8795d9acf512fee2d9964a2e9c536bbf0d7f Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Thu, 1 Aug 2024 13:47:15 +0200 Subject: [PATCH] Add is_triple_string utility function --- src/chisels.jl | 8 +++++--- src/runestone.jl | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/chisels.jl b/src/chisels.jl index ca36a48..1b9bae4 100644 --- a/src/chisels.jl +++ b/src/chisels.jl @@ -81,9 +81,6 @@ const TAG_LINE_CONT = UInt32(1) << 31 const TAG_TRAILING_COMMA = TagType(1) << 4 function add_tag(node::Node, tag::TagType) - if kind(node) !== K"parameters" - @assert is_leaf(node) - end return Node(head(node), span(node), node.kids, node.tags | tag) end @@ -540,6 +537,11 @@ function contains_multiline_triple_string(ctx, node::Node) return false end +function is_triple_string(node) + return kind(node) in KSet"string cmdstring" && + JuliaSyntax.has_flags(node, JuliaSyntax.TRIPLE_STRING_FLAG) +end + ########################## # Utilities for IOBuffer # ########################## diff --git a/src/runestone.jl b/src/runestone.jl index 23b544e..d3dbb52 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -2074,6 +2074,9 @@ function indent_call(ctx::Context, node::Node) end +# TODO: I feel like this function can be removed. The use in `indent_assignment` can be +# replaced with `continue_all_newlines` but the use in `indent_op_call` might have to be +# tweaked slightly. function indent_newlines_between_indices( ctx::Context, node::Node, open_idx::Int, close_idx::Int; indent_closing_token::Bool = false, @@ -2759,7 +2762,7 @@ function insert_delete_mark_newlines(ctx::Context, node::Node) end function indent_multiline_strings(ctx::Context, node::Node) - if !(kind(node) in KSet"string cmdstring" && JuliaSyntax.has_flags(node, JuliaSyntax.TRIPLE_STRING_FLAG)) + if !is_triple_string(node) return nothing end triplekind = kind(node) === K"string" ? K"\"\"\"" : K"```"