Browse Source

Fix whitespace in dotted comparison chains

pull/19/head
Fredrik Ekre 2 years ago
parent
commit
fac7aa8d64
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 10
      src/chisels.jl
  2. 3
      test/runtests.jl

10
src/chisels.jl

@ -101,8 +101,16 @@ function infix_op_call_op(node::JuliaSyntax.GreenNode) @@ -101,8 +101,16 @@ function infix_op_call_op(node::JuliaSyntax.GreenNode)
return children[op_index]
end
# Comparison leaf or a dotted comparison leaf (.<)
function is_comparison_leaf(node::JuliaSyntax.GreenNode)
return is_leaf(node) && JuliaSyntax.is_prec_comparison(node)
if is_leaf(node) && JuliaSyntax.is_prec_comparison(node)
return true
elseif !is_leaf(node) && JuliaSyntax.kind(node) === K"." &&
n_children(node) == 2 && is_comparison_leaf(verified_children(node)[2])
return true
else
return false
end
end
function is_operator_leaf(node::JuliaSyntax.GreenNode)

3
test/runtests.jl

@ -157,6 +157,9 @@ end @@ -157,6 +157,9 @@ end
@test format_string("a$(sp)<=$(sp)b$(sp)>=$(sp)c") == "a <= b >= c"
@test format_string("a$(sp)<$(sp)b$(sp)>=$(sp)c") == "a < b >= c"
@test format_string("a$(sp)<$(sp)b$(sp)<$(sp)c") == "a < b < c"
# Dotted chains
@test format_string("a$(sp).<=$(sp)b$(sp).>=$(sp)c") == "a .<= b .>= c"
@test format_string("a$(sp).<$(sp)b$(sp).<$(sp)c") == "a .< b .< c"
end
end

Loading…
Cancel
Save