@@ -38,6 +38,9 @@ import Ide.PluginUtils (getClientConfig)
38
38
import Ide.Types
39
39
import TcRnDriver (tcRnImportDecls )
40
40
import Control.Concurrent.Async (concurrently )
41
+ import GHC.Exts (toList )
42
+ import Development.IDE.GHC.Error (rangeToSrcSpan )
43
+ import Development.IDE.GHC.Util (prettyPrint )
41
44
#if defined(GHC_LIB)
42
45
import Development.IDE.Import.DependencyInformation
43
46
#endif
@@ -159,13 +162,24 @@ extendImportCommand =
159
162
PluginCommand (CommandId extendImportCommandId) " additional edits for a completion" extendImportHandler
160
163
161
164
extendImportHandler :: CommandFunction IdeState ExtendImport
162
- extendImportHandler ideState edit = do
165
+ extendImportHandler ideState edit@ ExtendImport { .. } = do
163
166
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
+ <> " )"
165
179
void $ LSP. sendRequest SWorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing wedit) (\ _ -> pure () )
166
180
return $ Right Null
167
181
168
- extendImportHandler' :: IdeState -> ExtendImport -> MaybeT IO WorkspaceEdit
182
+ extendImportHandler' :: IdeState -> ExtendImport -> MaybeT IO ( NormalizedFilePath , WorkspaceEdit )
169
183
extendImportHandler' ideState ExtendImport {.. }
170
184
| Just fp <- uriToFilePath doc,
171
185
nfp <- toNormalizedFilePath' fp =
@@ -181,7 +195,7 @@ extendImportHandler' ideState ExtendImport {..}
181
195
wantedModule = mkModuleName (T. unpack importName)
182
196
wantedQual = mkModuleName . T. unpack <$> importQual
183
197
imp <- liftMaybe $ find (isWantedModule wantedModule wantedQual) imps
184
- liftEither $
198
+ fmap (nfp,) $ liftEither $
185
199
rewriteToWEdit df doc (annsA ps) $
186
200
extendImport (T. unpack <$> thingParent) (T. unpack newThing) imp
187
201
| otherwise =
0 commit comments