@@ -756,7 +756,7 @@ removeImportTests = testGroup "remove import actions"
756
756
]
757
757
docB <- createDoc " ModuleB.hs" " haskell" contentB
758
758
_ <- waitForDiagnostics
759
- [CACodeAction action@ CodeAction { _title = actionTitle }]
759
+ [CACodeAction action@ CodeAction { _title = actionTitle }, _ ]
760
760
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
761
761
liftIO $ " Remove import" @=? actionTitle
762
762
executeCodeAction action
@@ -782,7 +782,7 @@ removeImportTests = testGroup "remove import actions"
782
782
]
783
783
docB <- createDoc " ModuleB.hs" " haskell" contentB
784
784
_ <- waitForDiagnostics
785
- [CACodeAction action@ CodeAction { _title = actionTitle }]
785
+ [CACodeAction action@ CodeAction { _title = actionTitle }, _ ]
786
786
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
787
787
liftIO $ " Remove import" @=? actionTitle
788
788
executeCodeAction action
@@ -811,7 +811,7 @@ removeImportTests = testGroup "remove import actions"
811
811
]
812
812
docB <- createDoc " ModuleB.hs" " haskell" contentB
813
813
_ <- waitForDiagnostics
814
- [CACodeAction action@ CodeAction { _title = actionTitle }]
814
+ [CACodeAction action@ CodeAction { _title = actionTitle }, _ ]
815
815
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
816
816
liftIO $ " Remove stuffA, stuffC from import" @=? actionTitle
817
817
executeCodeAction action
@@ -840,7 +840,7 @@ removeImportTests = testGroup "remove import actions"
840
840
]
841
841
docB <- createDoc " ModuleB.hs" " haskell" contentB
842
842
_ <- waitForDiagnostics
843
- [CACodeAction action@ CodeAction { _title = actionTitle }]
843
+ [CACodeAction action@ CodeAction { _title = actionTitle }, _ ]
844
844
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
845
845
liftIO $ " Remove !!, <?> from import" @=? actionTitle
846
846
executeCodeAction action
@@ -868,7 +868,7 @@ removeImportTests = testGroup "remove import actions"
868
868
]
869
869
docB <- createDoc " ModuleB.hs" " haskell" contentB
870
870
_ <- waitForDiagnostics
871
- [CACodeAction action@ CodeAction { _title = actionTitle }]
871
+ [CACodeAction action@ CodeAction { _title = actionTitle }, _ ]
872
872
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
873
873
liftIO $ " Remove A from import" @=? actionTitle
874
874
executeCodeAction action
@@ -895,7 +895,7 @@ removeImportTests = testGroup "remove import actions"
895
895
]
896
896
docB <- createDoc " ModuleB.hs" " haskell" contentB
897
897
_ <- waitForDiagnostics
898
- [CACodeAction action@ CodeAction { _title = actionTitle }]
898
+ [CACodeAction action@ CodeAction { _title = actionTitle }, _ ]
899
899
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
900
900
liftIO $ " Remove A, E, F from import" @=? actionTitle
901
901
executeCodeAction action
@@ -919,7 +919,7 @@ removeImportTests = testGroup "remove import actions"
919
919
]
920
920
docB <- createDoc " ModuleB.hs" " haskell" contentB
921
921
_ <- waitForDiagnostics
922
- [CACodeAction action@ CodeAction { _title = actionTitle }]
922
+ [CACodeAction action@ CodeAction { _title = actionTitle }, _ ]
923
923
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
924
924
liftIO $ " Remove import" @=? actionTitle
925
925
executeCodeAction action
@@ -929,6 +929,38 @@ removeImportTests = testGroup "remove import actions"
929
929
, " module ModuleB where"
930
930
]
931
931
liftIO $ expectedContentAfterAction @=? contentAfterAction
932
+ , testSession " remove all" $ do
933
+ let content = T. unlines
934
+ [ " {-# OPTIONS_GHC -Wunused-imports #-}"
935
+ , " module ModuleA where"
936
+ , " import Data.Function (fix, (&))"
937
+ , " import qualified Data.Functor.Const"
938
+ , " import Data.Functor.Identity"
939
+ , " import Data.Functor.Sum (Sum (InL, InR))"
940
+ , " import qualified Data.Kind as K (Constraint, Type)"
941
+ , " x = InL (Identity 123)"
942
+ , " y = fix id"
943
+ , " type T = K.Type"
944
+ ]
945
+ doc <- createDoc " ModuleC.hs" " haskell" content
946
+ _ <- waitForDiagnostics
947
+ [_, _, _, _, CACodeAction action@ CodeAction { _title = actionTitle }]
948
+ <- getCodeActions doc (Range (Position 2 0 ) (Position 2 5 ))
949
+ liftIO $ " Remove all redundant imports" @=? actionTitle
950
+ executeCodeAction action
951
+ contentAfterAction <- documentContents doc
952
+ let expectedContentAfterAction = T. unlines
953
+ [ " {-# OPTIONS_GHC -Wunused-imports #-}"
954
+ , " module ModuleA where"
955
+ , " import Data.Function (fix)"
956
+ , " import Data.Functor.Identity"
957
+ , " import Data.Functor.Sum (Sum (InL))"
958
+ , " import qualified Data.Kind as K (Type)"
959
+ , " x = InL (Identity 123)"
960
+ , " y = fix id"
961
+ , " type T = K.Type"
962
+ ]
963
+ liftIO $ expectedContentAfterAction @=? contentAfterAction
932
964
]
933
965
934
966
extendImportTests :: TestTree
0 commit comments