@@ -55,12 +55,12 @@ import Development.IDE.Test (Cursor,
55
55
flushMessages ,
56
56
getInterfaceFilesDir ,
57
57
getStoredKeys ,
58
+ isReferenceReady ,
59
+ referenceReady ,
58
60
standardizeQuotes ,
59
61
waitForAction ,
60
62
waitForGC ,
61
- waitForTypecheck ,
62
- isReferenceReady ,
63
- referenceReady )
63
+ waitForTypecheck )
64
64
import Development.IDE.Test.Runfiles
65
65
import qualified Development.IDE.Types.Diagnostics as Diagnostics
66
66
import Development.IDE.Types.Location
@@ -97,6 +97,7 @@ import Test.QuickCheck
97
97
import Control.Concurrent.Async
98
98
import Control.Lens (to , (^.) )
99
99
import Control.Monad.Extra (whenJust )
100
+ import Data.Function ((&) )
100
101
import Data.IORef
101
102
import Data.IORef.Extra (atomicModifyIORef_ )
102
103
import Data.String (IsString (fromString ))
@@ -107,6 +108,18 @@ import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide
107
108
import Development.IDE.Plugin.Test (TestRequest (BlockSeconds ),
108
109
WaitForIdeRuleResult (.. ),
109
110
blockCommandId )
111
+ import Development.IDE.Types.Logger (Logger (Logger ),
112
+ LoggingColumn (DataColumn , PriorityColumn ),
113
+ Pretty (pretty ),
114
+ Priority (Debug ),
115
+ Recorder (Recorder , logger_ ),
116
+ WithPriority (WithPriority , priority ),
117
+ cfilter ,
118
+ cmapWithPrio ,
119
+ makeDefaultStderrRecorder )
120
+ import qualified FuzzySearch
121
+ import GHC.Stack (emptyCallStack )
122
+ import qualified HieDbRetry
110
123
import Ide.PluginUtils (pluginDescToIdePlugins )
111
124
import Ide.Types
112
125
import qualified Language.LSP.Types as LSP
@@ -120,19 +133,14 @@ import Test.Tasty.Ingredients.Rerun
120
133
import Test.Tasty.QuickCheck
121
134
import Text.Printf (printf )
122
135
import Text.Regex.TDFA ((=~) )
123
- import qualified HieDbRetry
124
- import Development.IDE.Types.Logger (WithPriority (WithPriority , priority ), Priority (Debug ), cmapWithPrio , Recorder (Recorder , logger_ ), makeDefaultStderrRecorder , cfilter , LoggingColumn (PriorityColumn , DataColumn ), Logger (Logger ), Pretty (pretty ))
125
- import Data.Function ((&) )
126
- import GHC.Stack (emptyCallStack )
127
- import qualified FuzzySearch
128
136
129
- data Log
130
- = LogGhcIde Ghcide. Log
137
+ data Log
138
+ = LogGhcIde Ghcide. Log
131
139
| LogIDEMain IDE. Log
132
140
133
141
instance Pretty Log where
134
142
pretty = \ case
135
- LogGhcIde log -> pretty log
143
+ LogGhcIde log -> pretty log
136
144
LogIDEMain log -> pretty log
137
145
138
146
-- | Wait for the next progress begin step
@@ -2411,7 +2419,7 @@ insertNewDefinitionTests = testGroup "insert new definition actions"
2411
2419
liftIO $ contentAfterAction @?= T. unlines (txtB ++
2412
2420
[ " "
2413
2421
, " select :: [Bool] -> Bool"
2414
- , " select = error \" not implemented \" "
2422
+ , " select = _ "
2415
2423
]
2416
2424
++ txtB')
2417
2425
, testSession " define a hole" $ do
@@ -2438,9 +2446,61 @@ insertNewDefinitionTests = testGroup "insert new definition actions"
2438
2446
," foo False = False"
2439
2447
, " "
2440
2448
, " select :: [Bool] -> Bool"
2441
- , " select = error \" not implemented \" "
2449
+ , " select = _ "
2442
2450
]
2443
2451
++ txtB')
2452
+ , testSession " insert new function definition - Haddock comments" $ do
2453
+ let start = [" foo :: Int -> Bool"
2454
+ , " foo x = select (x + 1)"
2455
+ , " "
2456
+ , " -- | This is a haddock comment"
2457
+ , " haddock :: Int -> Int"
2458
+ , " haddock = undefined"
2459
+ ]
2460
+ let expected = [" foo :: Int -> Bool"
2461
+ , " foo x = select (x + 1)"
2462
+ , " "
2463
+ , " select :: Int -> Bool"
2464
+ , " select = _"
2465
+ , " "
2466
+ , " -- | This is a haddock comment"
2467
+ , " haddock :: Int -> Int"
2468
+ , " haddock = undefined" ]
2469
+ docB <- createDoc " ModuleB.hs" " haskell" (T. unlines start)
2470
+ _ <- waitForDiagnostics
2471
+ InR action@ CodeAction { _title = actionTitle } : _
2472
+ <- sortOn (\ (InR CodeAction {_title= x}) -> x) <$>
2473
+ getCodeActions docB (R 1 0 0 50 )
2474
+ liftIO $ actionTitle @?= " Define select :: Int -> Bool"
2475
+ executeCodeAction action
2476
+ contentAfterAction <- documentContents docB
2477
+ liftIO $ contentAfterAction @?= T. unlines expected
2478
+ , testSession " insert new function definition - normal comments" $ do
2479
+ let start = [" foo :: Int -> Bool"
2480
+ , " foo x = select (x + 1)"
2481
+ , " "
2482
+ , " -- This is a normal comment"
2483
+ , " normal :: Int -> Int"
2484
+ , " normal = undefined"
2485
+ ]
2486
+ let expected = [" foo :: Int -> Bool"
2487
+ , " foo x = select (x + 1)"
2488
+ , " "
2489
+ , " select :: Int -> Bool"
2490
+ , " select = _"
2491
+ , " "
2492
+ , " -- This is a normal comment"
2493
+ , " normal :: Int -> Int"
2494
+ , " normal = undefined" ]
2495
+ docB <- createDoc " ModuleB.hs" " haskell" (T. unlines start)
2496
+ _ <- waitForDiagnostics
2497
+ InR action@ CodeAction { _title = actionTitle } : _
2498
+ <- sortOn (\ (InR CodeAction {_title= x}) -> x) <$>
2499
+ getCodeActions docB (R 1 0 0 50 )
2500
+ liftIO $ actionTitle @?= " Define select :: Int -> Bool"
2501
+ executeCodeAction action
2502
+ contentAfterAction <- documentContents docB
2503
+ liftIO $ contentAfterAction @?= T. unlines expected
2444
2504
]
2445
2505
2446
2506
@@ -5613,7 +5673,7 @@ bootTests = testGroup "boot"
5613
5673
hoverResponseOrReadyMessage <- skipManyTill anyMessage ((Left <$> parseHoverResponse) <|> (Right <$> parseReadyMessage))
5614
5674
_ <- skipManyTill anyMessage $
5615
5675
case hoverResponseOrReadyMessage of
5616
- Left _ -> void parseReadyMessage
5676
+ Left _ -> void parseReadyMessage
5617
5677
Right _ -> void parseHoverResponse
5618
5678
closeDoc cDoc
5619
5679
cdoc <- createDoc cPath " haskell" cSource
0 commit comments