Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Add code action for hiding imports #1191

Open
expipiplus1 opened this issue Apr 23, 2019 · 8 comments
Open

Add code action for hiding imports #1191

expipiplus1 opened this issue Apr 23, 2019 · 8 comments

Comments

@expipiplus1
Copy link
Contributor

It would be nice if there was a code action for hiding imports which are unused and being shadowed by local declarations.

This is complicated because it requires some detailed information on the provenance of these names in order to hide them (for example if they are record fields).

An example:

Given the following warning:

triangle/Main.hs:83:26: warning: [-Wname-shadowing]
    This binding for ‘window’ shadows the existing bindings
      imported from ‘Graphics.Vulkan’ at triangle/Main.hs:(29,1)-(45,59)
      (and originally defined in ‘Graphics.Vulkan.Extensions.VK_NN_vi_surface’)
      imported from ‘Graphics.Vulkan’ at triangle/Main.hs:(29,1)-(45,59)
      (and originally defined in ‘Graphics.Vulkan.Extensions.VK_KHR_xlib_surface’)
      imported from ‘Graphics.Vulkan’ at triangle/Main.hs:(29,1)-(45,59)
      (and originally defined in ‘Graphics.Vulkan.Extensions.VK_KHR_xcb_surface’)
      imported from ‘Graphics.Vulkan’ at triangle/Main.hs:(29,1)-(45,59)
      (and originally defined in ‘Graphics.Vulkan.Extensions.VK_KHR_android_surface’)

To the hiding list of Graphics.Vulkan add

  XlibSurfaceCreateInfoKHR(window)
, XcbSurfaceCreateInfoKHR(window)
, ViSurfaceCreateInfoNN(window)
, AndroidSurfaceCreateInfoKHR(window)

At the moment this is a pain, as one has to visit each of those modules and find out which record is exposing that name.

@lorenzo
Copy link
Collaborator

lorenzo commented Apr 23, 2019

An alternate code action could be to make the shadowed function come from a qualified module instead. I often choose to fully qualify things when getting name conflicts

@fendor
Copy link
Collaborator

fendor commented Apr 25, 2019

Is there a tool to do it already? E.g. could hsimport do that?

@fendor
Copy link
Collaborator

fendor commented May 26, 2019

Hsimport does not seem to be able to do that, maybe we can add that to hsimport? It seems at least to be a feature they might want.

@lorenzo
Copy link
Collaborator

lorenzo commented May 27, 2019

@fendor that sounds like a great idea!

@fendor fendor self-assigned this May 29, 2019
@fendor
Copy link
Collaborator

fendor commented May 29, 2019

I am implementing the feature upstream in #18

@expipiplus1
Copy link
Contributor Author

expipiplus1 commented Jul 9, 2019 via email

@fendor
Copy link
Collaborator

fendor commented Jul 9, 2019

Not yet done! For a more complete implementation, the issue #19 needs to be implemented as discussed with the author. However, I wont be able to do it before august.
Afterwards, diagnostics must be parsed to offer the right Code Action. However, the general concept is already implemented in HIE, so as soon as upstream support is implemented and published.

@fendor
Copy link
Collaborator

fendor commented Dec 30, 2019

This can be implemented now, since we have implemented the required features upstream in hsimport!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants