Skip to content

Commit 674a1b9

Browse files
committed
Change of module decl and imports on rename
Add handling of WillRename Notification which changes the module declaration and all imports of the module to rename to the new name.
1 parent 1873226 commit 674a1b9

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

plugins/hls-rename-plugin/src/Ide/Plugin/Rename.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ import Control.Monad.Except (ExceptT, throwError)
1616
import Control.Monad.IO.Class (MonadIO, liftIO)
1717
import Control.Monad.Trans.Class (lift)
1818
import Control.Monad.Trans.Except (mapExceptT)
19-
import Control.Monad.Trans.Maybe (hoistMaybe,
20-
maybeToExceptT)
2119
import Data.Either (rights)
2220
import Data.Foldable (fold, minimumBy)
2321
import Data.Generics
2422
import Data.Hashable
2523
import Data.HashSet (HashSet)
2624
import qualified Data.HashSet as HS
27-
import Data.List (foldl')
25+
import qualified Data.List as List
2826
import Data.List.NonEmpty (NonEmpty ((:|)),
2927
groupWith)
3028
import qualified Data.List.NonEmpty as NE
@@ -122,7 +120,7 @@ prepareRenameProvider state _pluginId (PrepareRenameParams (TextDocumentIdentifi
122120
renameModuleProvider :: Recorder (WithPriority Log)-> PluginMethodHandler IdeState Method_WorkspaceWillRenameFiles
123121
renameModuleProvider recorder state _ (RenameFilesParams renames) = do
124122
renameResults <- mapM renameFile renames
125-
pure $ InL $ foldl' combineTextEdits (WorkspaceEdit mempty mempty mempty) $ catMaybes renameResults
123+
pure $ InL $ List.foldl' combineTextEdits (WorkspaceEdit mempty mempty mempty) $ catMaybes renameResults
126124
where
127125
recorder' = cmapWithPrio LogModuleRename recorder
128126

plugins/hls-rename-plugin/src/Ide/Plugin/Rename/ModuleRename.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ instance Pretty Log where
5050
pretty log =
5151
"ModuleRename." <> case log of
5252
CorrectNames log -> "CorrectNames" <> colon <+> pretty log
53-
LogRenameDependencies oldName fps -> "Rename of" <+> pretty oldName <+> "in" <+> (pretty $ map fromNormalizedFilePath fps)
53+
LogRenameDependencies oldName fps -> "Rename of" <+> pretty oldName <+> "in files:" <+> (pretty $ map fromNormalizedFilePath fps)
5454
NoModuleName nfp -> "Could not execute rename of" <+> pretty (fromNormalizedFilePath nfp) <+> "as no module path could be determined."
5555
LogRenameModuleDeclaration nfp -> "Renaming module declaration for file" <+> pretty (fromNormalizedFilePath nfp)
5656

0 commit comments

Comments
 (0)