Browse Source

Fix import/using lists with operators and macros

pull/30/head
Fredrik Ekre 1 year ago
parent
commit
c19f5b578e
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 3
      src/runestone.jl
  2. 12
      test/runtests.jl

3
src/runestone.jl

@ -1031,7 +1031,8 @@ function format_importpath(ctx::Context, node::Node)
node′ = replace_first_leaf(node, spacebar) node′ = replace_first_leaf(node, spacebar)
else else
# No whitespace, insert # No whitespace, insert
@assert kind(first_leaf(node)) === K"Identifier" @assert kind(first_leaf(node)) in KSet"Identifier @" ||
JuliaSyntax.is_operator(first_leaf(node))
kids′ = copy(verified_kids(node)) kids′ = copy(verified_kids(node))
pushfirst!(kids′, spacebar) pushfirst!(kids′, spacebar)
replace_bytes!(ctx, " ", 0) replace_bytes!(ctx, " ", 0)

12
test/runtests.jl

@ -804,9 +804,15 @@ end
@test format_string("$(verb) A$(sp),\nB") == "$(verb) A,\n B" @test format_string("$(verb) A$(sp),\nB") == "$(verb) A,\n B"
@test format_string("$(verb) \nA$(sp),\nB") == "$(verb)\n A,\n B" @test format_string("$(verb) \nA$(sp),\nB") == "$(verb)\n A,\n B"
# Colon lists # Colon lists
@test format_string("$(verb) $(sp)A: $(sp)a") == "$(verb) A: a" for a in ("a", "@a", "*")
@test format_string("$(verb) $(sp)A: $(sp)a$(sp),$(sp)b") == "$(verb) A: a, b" @test format_string("$(verb) $(sp)A: $(sp)$(a)") == "$(verb) A: $(a)"
@test format_string("$(verb) $(sp)A: $(sp)a$(sp),\nb") == "$(verb) A: a,\n b" for b in ("b", "@b", "*")
@test format_string("$(verb) $(sp)A: $(sp)$(a)$(sp),$(sp)$(b)") ==
"$(verb) A: $(a), $(b)"
@test format_string("$(verb) $(sp)A: $(sp)$(a)$(sp),\n$(b)") ==
"$(verb) A: $(a),\n $(b)"
end
end
end end
for sp in ("", " ", " ", "\t") for sp in ("", " ", " ", "\t")
# `import A as a, ...` # `import A as a, ...`

Loading…
Cancel
Save