Skip to content

Commit

Permalink
Refactoring: remove isTesting from ShakeExtras (#469)
Browse files Browse the repository at this point in the history
isTesting got added to ShakeExtras unnecessarily
  • Loading branch information
pepeiborra authored Mar 9, 2020
1 parent da92de2 commit 0bf4e91
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ main = do
let options = (defaultIdeOptions $ loadSession dir)
{ optReportProgress = clientSupportsProgress caps
, optShakeProfiling = argsShakeProfiling
, optTesting = IdeTesting argsTesting
, optTesting = argsTesting
}
debouncer <- newAsyncDebouncer
initialise caps (cradleRules >> mainRule >> pluginRules plugins >> action kick)
Expand Down
8 changes: 5 additions & 3 deletions exe/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import Data.Functor ((<&>))
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Development.IDE.Core.Rules (defineNoFile)
import Development.IDE.Core.Shake (ShakeExtras(ShakeExtras,isTesting), getShakeExtras, sendEvent, define, useNoFile_)
import Development.IDE.Core.Service (getIdeOptions)
import Development.IDE.Core.Shake (sendEvent, define, useNoFile_)
import Development.IDE.GHC.Util
import Development.IDE.Types.Location (fromNormalizedFilePath)
import Development.IDE.Types.Options (IdeOptions(IdeOptions, optTesting))
import Development.Shake
import DynFlags (gopt_set, gopt_unset,
updOptLevel)
Expand Down Expand Up @@ -60,13 +62,13 @@ cradleToSession :: Rules ()
cradleToSession = define $ \LoadCradle nfp -> do
let f = fromNormalizedFilePath nfp

ShakeExtras{isTesting} <- getShakeExtras
IdeOptions{optTesting} <- getIdeOptions

-- If the path points to a directory, load the implicit cradle
mbYaml <- doesDirectoryExist f <&> \isDir -> if isDir then Nothing else Just f
cradle <- liftIO $ maybe (loadImplicitCradle $ addTrailingPathSeparator f) loadCradle mbYaml

when isTesting $
when optTesting $
sendEvent $ notifyCradleLoaded f

cmpOpts <- liftIO $ getComponentOptions cradle
Expand Down
1 change: 0 additions & 1 deletion src/Development/IDE/Core/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ initialise caps mainRule getLspId toDiags logger debouncer options vfs =
logger
debouncer
(optShakeProfiling options)
(optTesting options)
(optReportProgress options)
shakeOptions
{ shakeThreads = optThreads options
Expand Down
5 changes: 1 addition & 4 deletions src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ data ShakeExtras = ShakeExtras
-- positions in a version of that document to positions in the latest version
,inProgress :: Var (HMap.HashMap NormalizedFilePath Int)
-- ^ How many rules are running for each file
,isTesting :: Bool
-- ^ enable additional messages used by the test suite to check invariants
}

getShakeExtras :: Action ShakeExtras
Expand Down Expand Up @@ -299,12 +297,11 @@ shakeOpen :: IO LSP.LspId
-> Logger
-> Debouncer NormalizedUri
-> Maybe FilePath
-> IdeTesting
-> IdeReportProgress
-> ShakeOptions
-> Rules ()
-> IO IdeState
shakeOpen getLspId eventer logger debouncer shakeProfileDir (IdeTesting isTesting) (IdeReportProgress reportProgress) opts rules = do
shakeOpen getLspId eventer logger debouncer shakeProfileDir (IdeReportProgress reportProgress) opts rules = do
inProgress <- newVar HMap.empty
shakeExtras <- do
globals <- newVar HMap.empty
Expand Down
6 changes: 2 additions & 4 deletions src/Development/IDE/Types/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module Development.IDE.Types.Options
, IdePreprocessedSource(..)
, IdeReportProgress(..)
, IdeDefer(..)
, IdeTesting(..)
, clientSupportsProgress
, IdePkgLocationOptions(..)
, defaultIdeOptions
Expand Down Expand Up @@ -41,7 +40,7 @@ data IdeOptions = IdeOptions
-- meaning we keep everything in memory but the daml CLI compiler uses this for incremental builds.
, optShakeProfiling :: Maybe FilePath
-- ^ Set to 'Just' to create a directory of profiling reports.
, optTesting :: IdeTesting
, optTesting :: Bool
-- ^ Whether to enable additional lsp messages used by the test suite for checking invariants
, optReportProgress :: IdeReportProgress
-- ^ Whether to report progress during long operations.
Expand All @@ -68,7 +67,6 @@ data IdePreprocessedSource = IdePreprocessedSource

newtype IdeReportProgress = IdeReportProgress Bool
newtype IdeDefer = IdeDefer Bool
newtype IdeTesting = IdeTesting Bool

clientSupportsProgress :: LSP.ClientCapabilities -> IdeReportProgress
clientSupportsProgress caps = IdeReportProgress $ Just True ==
Expand All @@ -87,7 +85,7 @@ defaultIdeOptions session = IdeOptions
,optLanguageSyntax = "haskell"
,optNewColonConvention = False
,optDefer = IdeDefer True
,optTesting = IdeTesting False
,optTesting = False
}


Expand Down

0 comments on commit 0bf4e91

Please sign in to comment.