@@ -1197,6 +1197,33 @@ removeImportTests = testGroup "remove import actions"
1197
1197
, " type T = K.Type"
1198
1198
]
1199
1199
liftIO $ expectedContentAfterAction @=? contentAfterAction
1200
+ , testSession " remove unused operators whose name ends with '.'" $ do
1201
+ let contentA = T. unlines
1202
+ [ " module ModuleA where"
1203
+ , " (@.) = 0 -- Must have an operator whose name ends with '.'"
1204
+ , " a = 1 -- .. but also something else"
1205
+ ]
1206
+ _docA <- createDoc " ModuleA.hs" " haskell" contentA
1207
+ let contentB = T. unlines
1208
+ [ " {-# OPTIONS_GHC -Wunused-imports #-}"
1209
+ , " module ModuleB where"
1210
+ , " import ModuleA (a, (@.))"
1211
+ , " x = a -- Must use something from module A, but not (@.)"
1212
+ ]
1213
+ docB <- createDoc " ModuleB.hs" " haskell" contentB
1214
+ _ <- waitForDiagnostics
1215
+ [InR action@ CodeAction { _title = actionTitle }, _]
1216
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1217
+ liftIO $ " Remove @. from import" @=? actionTitle
1218
+ executeCodeAction action
1219
+ contentAfterAction <- documentContents docB
1220
+ let expectedContentAfterAction = T. unlines
1221
+ [ " {-# OPTIONS_GHC -Wunused-imports #-}"
1222
+ , " module ModuleB where"
1223
+ , " import ModuleA (a)"
1224
+ , " x = a -- Must use something from module A, but not (@.)"
1225
+ ]
1226
+ liftIO $ expectedContentAfterAction @=? contentAfterAction
1200
1227
]
1201
1228
1202
1229
extendImportTests :: TestTree
@@ -3358,6 +3385,18 @@ removeExportTests = testGroup "remove export actions"
3358
3385
, " import qualified Data.List as M"
3359
3386
, " a :: ()"
3360
3387
, " a = ()" ])
3388
+ , testSession " qualified re-export ending in '.'" $ template
3389
+ (T. unlines
3390
+ [ " module A ((M.@.),a) where"
3391
+ , " import qualified Data.List as M"
3392
+ , " a :: ()"
3393
+ , " a = ()" ])
3394
+ " Remove ‘M.@.’ from export"
3395
+ (Just $ T. unlines
3396
+ [ " module A (a) where"
3397
+ , " import qualified Data.List as M"
3398
+ , " a :: ()"
3399
+ , " a = ()" ])
3361
3400
, testSession " export module" $ template
3362
3401
(T. unlines
3363
3402
[ " module A (module B) where"
0 commit comments