Skip to content

Commit fae8f37

Browse files
author
Santiago Weight
committed
refact: remove unnecessary cpp
1 parent 1041a25 commit fae8f37

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import Development.IDE.Plugin.CodeAction.PositionIndexed
5757
import Development.IDE.Plugin.CodeAction.Util
5858
import Development.IDE.Plugin.Completions.Types
5959
import qualified Development.IDE.Plugin.Plugins.AddArgument
60+
import Development.IDE.Plugin.Plugins.Diagnostic
6061
import Development.IDE.Plugin.TypeLenses (suggestSignature)
6162
import Development.IDE.Types.Exports
6263
import Development.IDE.Types.Location
@@ -92,7 +93,6 @@ import qualified Text.Fuzzy.Parallel as TFP
9293
import Text.Regex.TDFA (mrAfter,
9394
(=~), (=~~))
9495
#if MIN_VERSION_ghc(9,2,0)
95-
import Development.IDE.Plugin.Plugins.Diagnostic
9696
import GHC (AddEpAnn (AddEpAnn),
9797
Anchor (anchor_op),
9898
AnchorOperation (..),
@@ -171,9 +171,7 @@ bindingsPluginDescriptor recorder plId = mkExactprintPluginDescriptor recorder $
171171
, wrap suggestImplicitParameter
172172
#endif
173173
, wrap suggestNewDefinition
174-
#if MIN_VERSION_ghc(9,2,1)
175174
, wrap Development.IDE.Plugin.Plugins.AddArgument.plugin
176-
#endif
177175
, wrap suggestDeleteUnusedBinding
178176
]
179177
plId

plugins/hls-refactor-plugin/src/Development/IDE/Plugin/Plugins/AddArgument.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
{-# LANGUAGE CPP #-}
12
module Development.IDE.Plugin.Plugins.AddArgument (plugin) where
23

34
#if !MIN_VERSION_ghc(9,2,1)
5+
import qualified Data.Text as T
6+
import Language.LSP.Types
7+
48
plugin :: [(T.Text, [TextEdit])]
59
plugin = []
610
#else
@@ -19,7 +23,7 @@ import GHC (EpAnn (..),
1923
import GHC.Hs (IsUnicodeSyntax (..))
2024
import Language.Haskell.GHC.ExactPrint.Transform (d1)
2125
import Development.IDE.GHC.Compat
22-
import Development.IDE
26+
import Development.IDE.GHC.Error ( spanContainsRange )
2327
import Language.LSP.Types
2428
import qualified Data.Text as T
2529
import Development.IDE.GHC.ExactPrint (modifyMgMatchesT', modifySigWithM, modifySmallestDeclWithM, genAnchor1)

plugins/hls-refactor-plugin/test/Test/AddArgument.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tests =
3232
#if !MIN_VERSION_ghc(9,2,1)
3333
[]
3434
#else
35-
[ mkGoldenAddArgTest "Hole" (r 0 0 0 50),
35+
[ mkGoldenAddArgTest' "Hole" (r 0 0 0 50) "_new_def",
3636
mkGoldenAddArgTest "NoTypeSuggestion" (r 0 0 0 50),
3737
mkGoldenAddArgTest "MultipleDeclAlts" (r 0 0 0 50),
3838
mkGoldenAddArgTest "AddArgWithSig" (r 1 0 1 50),
@@ -51,13 +51,17 @@ tests =
5151
r x y x' y' = Range (Position x y) (Position x' y')
5252

5353
mkGoldenAddArgTest :: FilePath -> Range -> TestTree
54-
mkGoldenAddArgTest testFileName range = do
54+
mkGoldenAddArgTest testFileName range = mkGoldenAddArgTest' testFileName range "new_def"
55+
56+
-- Make a golden test for the add argument action. Given varName is the name of the variable not yet defined.
57+
mkGoldenAddArgTest' :: FilePath -> Range -> T.Text -> TestTree
58+
mkGoldenAddArgTest' testFileName range varName = do
5559
let action docB = do
5660
_ <- waitForDiagnostics
5761
InR action@CodeAction {_title = actionTitle} : _ <-
5862
filter (\(InR CodeAction {_title = x}) -> "Add" `isPrefixOf` T.unpack x)
5963
<$> getCodeActions docB range
60-
liftIO $ actionTitle @?= "Add argument ‘new_def’ to function"
64+
liftIO $ actionTitle @?= ("Add argument ‘" <> varName <> "’ to function")
6165
executeCodeAction action
6266
goldenWithHaskellDoc
6367
(Refactor.bindingsPluginDescriptor mempty "ghcide-code-actions-bindings")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo _new_def = _new_def
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
foo True new_def = new_def
2+
foo False new_def = 1

0 commit comments

Comments
 (0)