ExplicitImports.jl
ExplicitImports.jl copied to clipboard
`@enumx` unsupported
https://github.com/Ferrite-FEM/Ferrite.jl/pull/1013#discussion_r1664549346
The problem is we can’t see through macros to know new names are being defined. We could probably special case some macros that we know about though.
prior art: https://github.com/julia-vscode/StaticLint.jl/blob/master/src/macros.jl
Pluto does actual macro expansion: https://github.com/fonsp/Pluto.jl/pull/1032
I’d prefer to wait for JuliaLowering for that though
MWE:
module TestMacro
using EnumX: @enumx
using LinearAlgebra
@enumx ApplyStrategy Transpose Inplace
function my_method()
ApplyStrategy.Transpose
end
end #TestMacro
yields
julia> print_explicit_imports(TestMacro, "test/test_macros.jl")
Module Main.TestMacro is relying on implicit imports for 2 names. These could
be explicitly imported as follows:
using LinearAlgebra: LinearAlgebra, Transpose
Module Main.TestMacro.ApplyStrategy could not be accurately analyzed, likely
due to dynamic include statements. You can pass strict=false to attempt to get
(possibly inaccurate) results anyway.