Browse Source

Add is_triple_string utility function

fe/perf
Fredrik Ekre 1 year ago
parent
commit
d82a8795d9
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 8
      src/chisels.jl
  2. 5
      src/runestone.jl

8
src/chisels.jl

@ -81,9 +81,6 @@ const TAG_LINE_CONT = UInt32(1) << 31 @@ -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) @@ -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 #
##########################

5
src/runestone.jl

@ -2074,6 +2074,9 @@ function indent_call(ctx::Context, node::Node) @@ -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) @@ -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"```"

Loading…
Cancel
Save