ExplicitImports.jl icon indicating copy to clipboard operation
ExplicitImports.jl copied to clipboard

`@enumx` unsupported

Open ericphanson opened this issue 1 year ago • 2 comments

https://github.com/Ferrite-FEM/Ferrite.jl/pull/1013#discussion_r1664549346

ericphanson avatar Jul 03 '24 21:07 ericphanson

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

ericphanson avatar Jul 04 '24 11:07 ericphanson

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.

ericphanson avatar Oct 12 '24 14:10 ericphanson