@@ -30,6 +30,7 @@ import qualified Control.Exception as E
30
30
import Control.Lens (_1 , _3 , (%~) , (<&>) , (^.) )
31
31
import Control.Monad (guard , join , void , when )
32
32
import Control.Monad.IO.Class (MonadIO (liftIO ))
33
+ import Control.Monad.Trans (lift )
33
34
import Control.Monad.Trans.Except (ExceptT (.. ))
34
35
import Data.Aeson (toJSON )
35
36
import Data.Char (isSpace )
@@ -78,10 +79,12 @@ import qualified GHC.LanguageExtensions.Type as LangExt (Extension (..))
78
79
79
80
import Development.IDE.Core.FileStore (setSomethingModified )
80
81
import Development.IDE.Types.Shake (toKey )
82
+ import Ide.Plugin.Config (Config )
81
83
import Ide.Plugin.Eval.Code (Statement , asStatements ,
82
84
evalSetup , myExecStmt ,
83
85
propSetup , resultRange ,
84
86
testCheck , testRanges )
87
+ import Ide.Plugin.Eval.Config (getDiffProperty )
85
88
import Ide.Plugin.Eval.GHC (addImport , addPackages ,
86
89
hasPackage , showDynFlags )
87
90
import Ide.Plugin.Eval.Parse.Comments (commentsToSections )
@@ -176,16 +179,16 @@ codeLens st plId CodeLensParams{_textDocument} =
176
179
evalCommandName :: CommandId
177
180
evalCommandName = " evalCommand"
178
181
179
- evalCommand :: PluginCommand IdeState
180
- evalCommand = PluginCommand evalCommandName " evaluate" runEvalCmd
182
+ evalCommand :: PluginId -> PluginCommand IdeState
183
+ evalCommand plId = PluginCommand evalCommandName " evaluate" ( runEvalCmd plId)
181
184
182
185
type EvalId = Int
183
186
184
- runEvalCmd :: CommandFunction IdeState EvalParams
185
- runEvalCmd st EvalParams {.. } =
187
+ runEvalCmd :: PluginId -> CommandFunction IdeState EvalParams
188
+ runEvalCmd plId st EvalParams {.. } =
186
189
let dbg = logWith st
187
190
perf = timed dbg
188
- cmd :: ExceptT String (LspM c ) WorkspaceEdit
191
+ cmd :: ExceptT String (LspM Config ) WorkspaceEdit
189
192
cmd = do
190
193
let tests = map (\ (a,_,b) -> (a,b)) $ testsBySection sections
191
194
@@ -300,12 +303,13 @@ runEvalCmd st EvalParams{..} =
300
303
-- Evaluation takes place 'inside' the module
301
304
setContext [Compat. IIModule modName]
302
305
Right <$> getSession
303
-
306
+ diff <- lift $ getDiffProperty plId
304
307
edits <-
305
308
perf " edits" $
306
309
liftIO $
307
310
evalGhcEnv hscEnv' $
308
311
runTests
312
+ diff
309
313
(st, fp)
310
314
tests
311
315
@@ -347,8 +351,8 @@ testsBySection sections =
347
351
348
352
type TEnv = (IdeState , String )
349
353
350
- runTests :: TEnv -> [(Section , Test )] -> Ghc [TextEdit ]
351
- runTests e@ (_st, _) tests = do
354
+ runTests :: Bool -> TEnv -> [(Section , Test )] -> Ghc [TextEdit ]
355
+ runTests diff e@ (_st, _) tests = do
352
356
df <- getInteractiveDynFlags
353
357
evalSetup
354
358
when (hasQuickCheck df && needsQuickCheck tests) $ void $ evals e df propSetup
@@ -363,7 +367,7 @@ runTests e@(_st, _) tests = do
363
367
rs <- runTest e df test
364
368
dbg " TEST RESULTS" rs
365
369
366
- let checkedResult = testCheck (section, test) rs
370
+ let checkedResult = testCheck diff (section, test) rs
367
371
368
372
let edit = asEdit (sectionFormat section) test (map pad checkedResult)
369
373
dbg " TEST EDIT" edit
0 commit comments