Skip to content

Commit 444d109

Browse files
authored
Merge pull request #374 from julia-vscode/sp/macro-definition-sites
fix: correctly follow find definitions for macros
2 parents 6abd4bd + d747087 commit 444d109

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/linting/checks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ function sig_match_any(func::EXPR, x, call_counts, tls::Scope, env::ExternalEnv)
337337
end
338338

339339
function get_method(name::EXPR)
340-
f = maybe_get_parent_fexpr(name, x -> CSTParser.defines_function(x) || CSTParser.defines_struct(x))
340+
f = maybe_get_parent_fexpr(name, x -> CSTParser.defines_function(x) || CSTParser.defines_struct(x) || CSTParser.defines_macro(x))
341341
if f !== nothing && CSTParser.get_name(f) == name
342342
return f
343343
end

test/runtests.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,3 +2005,26 @@ end
20052005
""")
20062006
@test isempty(StaticLint.collect_hints(cst, server))
20072007
end
2008+
2009+
@testset "macro definition" begin
2010+
cst = parse_and_pass("""
2011+
module JumpToMacroDoesNotWork
2012+
export @mymacro
2013+
2014+
macro mymacro()
2015+
end
2016+
end
2017+
2018+
JumpToMacroDoesNotWork.@mymacro(1+1)
2019+
""")
2020+
m = cst.args[end].args[1].args[2].args[1]
2021+
methods = Set()
2022+
for r in m.meta.ref.refs
2023+
m = StaticLint.get_method(r)
2024+
if m !== nothing
2025+
push!(methods, m)
2026+
end
2027+
end
2028+
2029+
@test !isempty(methods)
2030+
end

0 commit comments

Comments
 (0)