@@ -81,7 +81,6 @@ import Development.IDE.Plugin.Test (TestRequest (BlockSeconds, GetInterfaceFiles
81
81
import Control.Monad.Extra (whenJust )
82
82
import qualified Language.LSP.Types.Lens as L
83
83
import Control.Lens ((^.) )
84
- import Data.Functor
85
84
import Data.Tuple.Extra
86
85
87
86
waitForProgressBegin :: Session ()
@@ -706,7 +705,6 @@ codeActionTests = testGroup "code actions"
706
705
, suggestImportTests
707
706
, suggestHideShadowTests
708
707
, suggestImportDisambiguationTests
709
- , disableWarningTests
710
708
, fixConstructorImportTests
711
709
, importRenameActionTests
712
710
, fillTypedHoleTests
@@ -913,8 +911,9 @@ removeImportTests = testGroup "remove import actions"
913
911
]
914
912
docB <- createDoc " ModuleB.hs" " haskell" contentB
915
913
_ <- waitForDiagnostics
916
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove import" )
917
- =<< getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
914
+ [InR action@ CodeAction { _title = actionTitle }, _]
915
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
916
+ liftIO $ " Remove import" @=? actionTitle
918
917
executeCodeAction action
919
918
contentAfterAction <- documentContents docB
920
919
let expectedContentAfterAction = T. unlines
@@ -938,8 +937,9 @@ removeImportTests = testGroup "remove import actions"
938
937
]
939
938
docB <- createDoc " ModuleB.hs" " haskell" contentB
940
939
_ <- waitForDiagnostics
941
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove import" )
942
- =<< getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
940
+ [InR action@ CodeAction { _title = actionTitle }, _]
941
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
942
+ liftIO $ " Remove import" @=? actionTitle
943
943
executeCodeAction action
944
944
contentAfterAction <- documentContents docB
945
945
let expectedContentAfterAction = T. unlines
@@ -966,8 +966,9 @@ removeImportTests = testGroup "remove import actions"
966
966
]
967
967
docB <- createDoc " ModuleB.hs" " haskell" contentB
968
968
_ <- waitForDiagnostics
969
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove stuffA, stuffC from import" )
970
- =<< getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
969
+ [InR action@ CodeAction { _title = actionTitle }, _]
970
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
971
+ liftIO $ " Remove stuffA, stuffC from import" @=? actionTitle
971
972
executeCodeAction action
972
973
contentAfterAction <- documentContents docB
973
974
let expectedContentAfterAction = T. unlines
@@ -994,8 +995,9 @@ removeImportTests = testGroup "remove import actions"
994
995
]
995
996
docB <- createDoc " ModuleB.hs" " haskell" contentB
996
997
_ <- waitForDiagnostics
997
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove !!, <?> from import" )
998
- =<< getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
998
+ [InR action@ CodeAction { _title = actionTitle }, _]
999
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1000
+ liftIO $ " Remove !!, <?> from import" @=? actionTitle
999
1001
executeCodeAction action
1000
1002
contentAfterAction <- documentContents docB
1001
1003
let expectedContentAfterAction = T. unlines
@@ -1021,8 +1023,9 @@ removeImportTests = testGroup "remove import actions"
1021
1023
]
1022
1024
docB <- createDoc " ModuleB.hs" " haskell" contentB
1023
1025
_ <- waitForDiagnostics
1024
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove A from import" )
1025
- =<< getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1026
+ [InR action@ CodeAction { _title = actionTitle }, _]
1027
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1028
+ liftIO $ " Remove A from import" @=? actionTitle
1026
1029
executeCodeAction action
1027
1030
contentAfterAction <- documentContents docB
1028
1031
let expectedContentAfterAction = T. unlines
@@ -1047,8 +1050,9 @@ removeImportTests = testGroup "remove import actions"
1047
1050
]
1048
1051
docB <- createDoc " ModuleB.hs" " haskell" contentB
1049
1052
_ <- waitForDiagnostics
1050
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove A, E, F from import" )
1051
- =<< getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1053
+ [InR action@ CodeAction { _title = actionTitle }, _]
1054
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1055
+ liftIO $ " Remove A, E, F from import" @=? actionTitle
1052
1056
executeCodeAction action
1053
1057
contentAfterAction <- documentContents docB
1054
1058
let expectedContentAfterAction = T. unlines
@@ -1070,8 +1074,9 @@ removeImportTests = testGroup "remove import actions"
1070
1074
]
1071
1075
docB <- createDoc " ModuleB.hs" " haskell" contentB
1072
1076
_ <- waitForDiagnostics
1073
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove import" )
1074
- =<< getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1077
+ [InR action@ CodeAction { _title = actionTitle }, _]
1078
+ <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
1079
+ liftIO $ " Remove import" @=? actionTitle
1075
1080
executeCodeAction action
1076
1081
contentAfterAction <- documentContents docB
1077
1082
let expectedContentAfterAction = T. unlines
@@ -1094,8 +1099,9 @@ removeImportTests = testGroup "remove import actions"
1094
1099
]
1095
1100
doc <- createDoc " ModuleC.hs" " haskell" content
1096
1101
_ <- waitForDiagnostics
1097
- action <- assertJust " Code action not found" . firstJust (caWithTitle " Remove all redundant imports" )
1098
- =<< getCodeActions doc (Range (Position 2 0 ) (Position 2 5 ))
1102
+ [_, _, _, _, InR action@ CodeAction { _title = actionTitle }]
1103
+ <- getCodeActions doc (Range (Position 2 0 ) (Position 2 5 ))
1104
+ liftIO $ " Remove all redundant imports" @=? actionTitle
1099
1105
executeCodeAction action
1100
1106
contentAfterAction <- documentContents doc
1101
1107
let expectedContentAfterAction = T. unlines
@@ -1111,10 +1117,6 @@ removeImportTests = testGroup "remove import actions"
1111
1117
]
1112
1118
liftIO $ expectedContentAfterAction @=? contentAfterAction
1113
1119
]
1114
- where
1115
- caWithTitle t = \ case
1116
- InR a@ CodeAction {_title} -> guard (_title == t) >> Just a
1117
- _ -> Nothing
1118
1120
1119
1121
extendImportTests :: TestTree
1120
1122
extendImportTests = testGroup " extend import actions"
@@ -1784,57 +1786,6 @@ suggestHideShadowTests =
1784
1786
, " (++) = id"
1785
1787
]
1786
1788
1787
- disableWarningTests :: TestTree
1788
- disableWarningTests =
1789
- testGroup " disable warnings" $
1790
- [
1791
- ( " missing-signatures"
1792
- , T. unlines
1793
- [ " {-# OPTIONS_GHC -Wall #-}"
1794
- , " main = putStrLn \" hello\" "
1795
- ]
1796
- , T. unlines
1797
- [ " {-# OPTIONS_GHC -Wall #-}"
1798
- , " {-# OPTIONS_GHC -Wno-missing-signatures #-}"
1799
- , " main = putStrLn \" hello\" "
1800
- ]
1801
- )
1802
- ,
1803
- ( " unused-imports"
1804
- , T. unlines
1805
- [ " {-# OPTIONS_GHC -Wall #-}"
1806
- , " "
1807
- , " "
1808
- , " module M where"
1809
- , " "
1810
- , " import Data.Functor"
1811
- ]
1812
- , T. unlines
1813
- [ " {-# OPTIONS_GHC -Wall #-}"
1814
- , " {-# OPTIONS_GHC -Wno-unused-imports #-}"
1815
- , " "
1816
- , " "
1817
- , " module M where"
1818
- , " "
1819
- , " import Data.Functor"
1820
- ]
1821
- )
1822
- ]
1823
- <&> \ (warning, initialContent, expectedContent) -> testSession (T. unpack warning) $ do
1824
- doc <- createDoc " Module.hs" " haskell" initialContent
1825
- _ <- waitForDiagnostics
1826
- codeActs <- mapMaybe caResultToCodeAct <$> getCodeActions doc (Range (Position 0 0 ) (Position 0 0 ))
1827
- case find (\ CodeAction {_title} -> _title == " Disable \" " <> warning <> " \" warnings" ) codeActs of
1828
- Nothing -> liftIO $ assertFailure " No code action with expected title"
1829
- Just action -> do
1830
- executeCodeAction action
1831
- contentAfterAction <- documentContents doc
1832
- liftIO $ expectedContent @=? contentAfterAction
1833
- where
1834
- caResultToCodeAct = \ case
1835
- InL _ -> Nothing
1836
- InR c -> Just c
1837
-
1838
1789
insertNewDefinitionTests :: TestTree
1839
1790
insertNewDefinitionTests = testGroup " insert new definition actions"
1840
1791
[ testSession " insert new function definition" $ do
@@ -2586,12 +2537,7 @@ removeRedundantConstraintsTests = let
2586
2537
doc <- createDoc " Testing.hs" " haskell" code
2587
2538
_ <- waitForDiagnostics
2588
2539
actionsOrCommands <- getCodeActions doc (Range (Position 4 0 ) (Position 4 maxBound ))
2589
- liftIO $ assertBool " Found some actions (other than \" disable warnings\" )"
2590
- $ all isDisableWarningAction actionsOrCommands
2591
- where
2592
- isDisableWarningAction = \ case
2593
- InR CodeAction {_title} -> " Disable" `T.isPrefixOf` _title && " warnings" `T.isSuffixOf` _title
2594
- _ -> False
2540
+ liftIO $ assertBool " Found some actions" (null actionsOrCommands)
2595
2541
2596
2542
in testGroup " remove redundant function constraints"
2597
2543
[ check
@@ -4786,9 +4732,7 @@ asyncTests = testGroup "async"
4786
4732
void waitForDiagnostics
4787
4733
actions <- getCodeActions doc (Range (Position 1 0 ) (Position 1 0 ))
4788
4734
liftIO $ [ _title | InR CodeAction {_title} <- actions] @=?
4789
- [ " add signature: foo :: a -> a"
4790
- , " Disable \" missing-signatures\" warnings"
4791
- ]
4735
+ [ " add signature: foo :: a -> a" ]
4792
4736
, testSession " request" $ do
4793
4737
-- Execute a custom request that will block for 1000 seconds
4794
4738
void $ sendRequest (SCustomMethod " test" ) $ toJSON $ BlockSeconds 1000
@@ -4800,9 +4744,7 @@ asyncTests = testGroup "async"
4800
4744
void waitForDiagnostics
4801
4745
actions <- getCodeActions doc (Range (Position 0 0 ) (Position 0 0 ))
4802
4746
liftIO $ [ _title | InR CodeAction {_title} <- actions] @=?
4803
- [ " add signature: foo :: a -> a"
4804
- , " Disable \" missing-signatures\" warnings"
4805
- ]
4747
+ [ " add signature: foo :: a -> a" ]
4806
4748
]
4807
4749
4808
4750
0 commit comments