Skip to content

Commit baf47c2

Browse files
authored
Merge pull request #196 from JunoLab/avi/quote
prevent items inside quotes from leaking into outline
2 parents b49fd0b + ce4c13f commit baf47c2

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/outline.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,16 @@ function scopeof(expr::CSTParser.EXPR)
332332
return :call
333333
end
334334

335+
if expr.typ == CSTParser.TupleH && expr.parent nothing && scopeof(expr.parent) == nothing
336+
return :tupleh
337+
end
338+
335339
if expr.typ == CSTParser.MacroCall
336340
return :macro
337341
end
338342

339-
if expr.typ == CSTParser.TupleH && expr.parent nothing && scopeof(expr.parent) == nothing
340-
return :tupleh
343+
if expr.typ == CSTParser.Quote
344+
return :quote
341345
end
342346
end
343347
return nothing

test/outline.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,20 @@ end
286286
end
287287
end
288288

289+
# items inside quote blocks don't leak
290+
let str = """
291+
ex = :(func() = nothing)
292+
q = quote
293+
@macrocall something
294+
val = nothing
295+
end
296+
"""
297+
let names = Set(map(d -> d[:name], outline(str)))
298+
@test length(names) === 2
299+
@test names == Set(("ex", "q"))
300+
end
301+
end
302+
289303
# should stringify method signatures correctly
290304
let str = """
291305
withstrings(single = \"1\", triple = \"\"\"3\"\"\") = single * triple

0 commit comments

Comments
 (0)