-
-
Notifications
You must be signed in to change notification settings - Fork 432
hls-rename-plugin can’t rename import aliases #4873
Description
Is your enhancement request related to a problem? Please describe.
Sometimes I find it difficult to organize my imports, because hls-rename-plugin doesn’t support renaming import aliases.
For example, consider the following code:
import qualified Data.List as L
betterTail = L.drop 1Now, suppose I want to rename L because I want to import Control.Lens as L and refer to Data.List as List instead.
hls-rename-plugin can’t do this yet. Specifically:
- If I place my cursor on
Linas L, the plugin says “No symbol to rename at given location.” - If I place my cursor on
LinL.dropand attempt to renameLtoList, I get “Renaming of an imported name is unsupported.”
Describe the solution you'd like
I want to be able to place my cursor on an import alias (whether in an import statement or in a qualified name), and rename the alias.
For example, I should be able go to either L below, rename it to List, and have all occurrences of L changed correctly:
-- Before: ----------------------------
import qualified Data.List as L
betterTail = L.drop 1
-- After: -----------------------------
import qualified Data.List as List
betterTail = List.drop 1Bonus
I also want to be able to rename the following aliases separately:
-- Before: ----------------------------
import Control.Monad as M
import Data.Maybe as M
isSomething = M.isJust -- from Maybe
discard = M.void -- from Monad
-- After: -----------------------------
import Control.Monad as Monad
import Data.Maybe as Maybe
isSomething = Maybe.isJust -- from Maybe
discard = Monad.void -- from MonadDescribe alternatives you've considered
I tried search-and-replace, but it always felt less convenient and more error prone.
For example, if I have two aliases named L and URL, doing search-and-replace to rename L to List might also turn URL to URList.
Additional context
I think there’s none.