@@ -38,6 +38,9 @@ import Ide.PluginUtils (getClientConfig)
3838import Ide.Types
3939import TcRnDriver (tcRnImportDecls )
4040import Control.Concurrent.Async (concurrently )
41+ import GHC.Exts (toList )
42+ import Development.IDE.GHC.Error (rangeToSrcSpan )
43+ import Development.IDE.GHC.Util (prettyPrint )
4144#if defined(GHC_LIB)
4245import Development.IDE.Import.DependencyInformation
4346#endif
@@ -159,13 +162,24 @@ extendImportCommand =
159162 PluginCommand (CommandId extendImportCommandId) " additional edits for a completion" extendImportHandler
160163
161164extendImportHandler :: CommandFunction IdeState ExtendImport
162- extendImportHandler ideState edit = do
165+ extendImportHandler ideState edit@ ExtendImport { .. } = do
163166 res <- liftIO $ runMaybeT $ extendImportHandler' ideState edit
164- whenJust res $ \ wedit ->
167+ whenJust res $ \ (nfp, wedit@ WorkspaceEdit {_changes}) -> do
168+ let (_, List (head -> TextEdit {_range})) = fromJust $ _changes >>= listToMaybe . toList
169+ srcSpan = rangeToSrcSpan nfp _range
170+ LSP. sendNotification SWindowShowMessage $
171+ ShowMessageParams MtInfo $
172+ " Import "
173+ <> maybe (" ‘" <> newThing) (\ x -> " ‘" <> x <> " (" <> newThing <> " )" ) thingParent
174+ <> " ’ from "
175+ <> importName
176+ <> " (at "
177+ <> T. pack (prettyPrint srcSpan)
178+ <> " )"
165179 void $ LSP. sendRequest SWorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing wedit) (\ _ -> pure () )
166180 return $ Right Null
167181
168- extendImportHandler' :: IdeState -> ExtendImport -> MaybeT IO WorkspaceEdit
182+ extendImportHandler' :: IdeState -> ExtendImport -> MaybeT IO ( NormalizedFilePath , WorkspaceEdit )
169183extendImportHandler' ideState ExtendImport {.. }
170184 | Just fp <- uriToFilePath doc,
171185 nfp <- toNormalizedFilePath' fp =
@@ -181,7 +195,7 @@ extendImportHandler' ideState ExtendImport {..}
181195 wantedModule = mkModuleName (T. unpack importName)
182196 wantedQual = mkModuleName . T. unpack <$> importQual
183197 imp <- liftMaybe $ find (isWantedModule wantedModule wantedQual) imps
184- liftEither $
198+ fmap (nfp,) $ liftEither $
185199 rewriteToWEdit df doc (annsA ps) $
186200 extendImport (T. unpack <$> thingParent) (T. unpack newThing) imp
187201 | otherwise =
0 commit comments