Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soulomoon/refactor session #15

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
e6595bb
migrate boot test
soulomoon May 13, 2024
25108f4
Merge branch 'master' into soulomoon/update-ghcide-tests-hls-test-uti…
soulomoon May 13, 2024
542ea26
restrict the cwd to the outermost layer
soulomoon May 14, 2024
f7611a2
remove makeAbsolute
soulomoon May 14, 2024
67438ef
fix import
soulomoon May 14, 2024
9238ff6
fix more dir
soulomoon May 14, 2024
8c709ab
use abs path in template haskell
soulomoon May 14, 2024
5b15ebf
fix reference test
soulomoon May 14, 2024
2eae58b
fix ExceptionTests
soulomoon May 14, 2024
f2c1c61
fix exceptionTests
soulomoon May 14, 2024
308e726
fix
soulomoon May 14, 2024
543b270
Merge branch 'master' into soulomoon/remove-set-current-dir
soulomoon May 14, 2024
2baa0c9
fix hls
soulomoon May 14, 2024
2ebfafc
use lsp root dir
soulomoon May 14, 2024
042df98
disable stan test
soulomoon May 14, 2024
f8f37a0
Revert "disable stan test"
soulomoon May 14, 2024
6a11d1e
special function that shift to root
soulomoon May 14, 2024
7dce0f3
remove trace
soulomoon May 14, 2024
289528a
use absolute root
soulomoon May 14, 2024
ca1c2b8
change to test config
soulomoon May 15, 2024
a3dc7ce
add goldenWithTestConfig
soulomoon May 15, 2024
1d0f544
fix
soulomoon May 15, 2024
7254731
fix notes
soulomoon May 15, 2024
2a25a1f
fix windows
soulomoon May 15, 2024
3997849
relatex test
soulomoon May 15, 2024
e2ff7d0
migrate exception tests
soulomoon May 16, 2024
91d31d8
clean up
soulomoon May 16, 2024
edca60d
remove testWithDummyPluginAndCap'
soulomoon May 16, 2024
17e3305
use single thread in test
soulomoon May 16, 2024
4c88650
move semantic tokens test
soulomoon May 16, 2024
c0ed673
clean up DependentFileTest
soulomoon May 16, 2024
8223c65
merge file tree and config root
soulomoon May 16, 2024
9882ede
update doc
soulomoon May 16, 2024
fc745c9
clean up consultCradle
soulomoon May 16, 2024
9eb3763
lift toAbsolute
soulomoon May 16, 2024
80bd4de
clean up
soulomoon May 16, 2024
836c1b7
fix
soulomoon May 16, 2024
faf0cc7
shift to the lsp root if the root is not the current directory
soulomoon May 16, 2024
887f8ed
spawn to tmp dir by default
soulomoon May 16, 2024
1320577
fix exceptionTests
soulomoon May 16, 2024
8826256
clear up
soulomoon May 16, 2024
53cfa5f
migrate THTests
soulomoon May 16, 2024
5dc3035
fix Retrie
soulomoon May 16, 2024
f3cd2e2
migrate ClientSettingsTests CodeLensTests CPPTests CradleTests
soulomoon May 16, 2024
9298cc0
add comment
soulomoon May 16, 2024
2735555
Merge branch 'master' into soulomoon/remove-set-current-dir
soulomoon May 17, 2024
785d22a
Merge branch 'master' into soulomoon/remove-set-current-dir
soulomoon May 18, 2024
92b8bae
Merge branch 'master' into soulomoon/remove-set-current-dir
soulomoon May 18, 2024
1bb8c51
move recorder first
soulomoon May 19, 2024
3a5c2cf
Merge remote-tracking branch 'refs/remotes/origin/soulomoon/remove-se…
soulomoon May 19, 2024
bb45003
rename
soulomoon May 19, 2024
166bbe9
clean up
soulomoon May 19, 2024
1844682
Merge branch 'master' into soulomoon/remove-set-current-dir
soulomoon May 20, 2024
48bc29b
fix test
soulomoon May 21, 2024
b53c8c5
refactor session
soulomoon May 21, 2024
a8ecbf9
mask the getOptions
soulomoon May 21, 2024
c11f001
remove the mask
soulomoon May 21, 2024
021badc
put wait in sync
soulomoon May 21, 2024
5a982e9
run in async
soulomoon May 21, 2024
569a315
add CradleLoc
soulomoon May 21, 2024
c417729
reduce use normalized path
soulomoon May 21, 2024
6a01a45
clean up
soulomoon May 21, 2024
b6596f4
move restart to async
soulomoon May 21, 2024
997fd93
lift UnlifIO
soulomoon May 21, 2024
4409fe7
session using IO
soulomoon May 21, 2024
40d1e3b
fix
soulomoon May 21, 2024
2997348
add rule to session loader
soulomoon May 21, 2024
6c4a848
use restart to do the shakeEnqueue
soulomoon May 21, 2024
eda4227
cleanup
soulomoon May 21, 2024
4697009
move extends out of restart
soulomoon May 22, 2024
98a8ca1
install cradle deps check as rule
soulomoon May 22, 2024
fa2c7c1
fix always add SessionCacheVersion deps
soulomoon May 22, 2024
0a4f695
fix
soulomoon May 22, 2024
83140cf
restart only on cache changed
soulomoon May 22, 2024
4c31646
fix
soulomoon May 22, 2024
a03b8b3
fix
soulomoon May 22, 2024
5d50087
para more
soulomoon May 22, 2024
7c9e5d2
fix and revert para
soulomoon May 22, 2024
4f416cd
fix
soulomoon May 23, 2024
17922a5
move parallel more
soulomoon May 23, 2024
2061a71
clear early
soulomoon May 23, 2024
03b5add
double check
soulomoon May 23, 2024
84cea5f
avoid trigger more
soulomoon May 23, 2024
ebb1c9e
serialize
soulomoon May 23, 2024
188aa3c
less lock
soulomoon May 24, 2024
da064cd
lock
soulomoon May 24, 2024
811414f
faster
soulomoon May 24, 2024
0418e06
faster
soulomoon May 24, 2024
0077033
standardize dbThread
soulomoon May 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exe/Wrapper.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE CPP #-}

Check warning on line 1 in exe/Wrapper.hs

View workflow job for this annotation

GitHub Actions / Hlint check run

Warning in module Main: Use module export list ▫︎ Found: "module Main where" ▫︎ Perhaps: "module Main (\n module Main\n ) where" ▫︎ Note: an explicit list is usually better
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down Expand Up @@ -269,7 +269,8 @@
-- to shut down the LSP.
launchErrorLSP :: Recorder (WithPriority (Doc ())) -> T.Text -> IO ()
launchErrorLSP recorder errorMsg = do
let defaultArguments = Main.defaultArguments (cmapWithPrio pretty recorder) (IdePlugins [])
cwd <- getCurrentDirectory
let defaultArguments = Main.defaultArguments (cmapWithPrio pretty recorder) cwd (IdePlugins [])

inH <- Main.argsHandleIn defaultArguments

Expand Down
6 changes: 3 additions & 3 deletions ghcide/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ main = withTelemetryRecorder $ \telemetryRecorder -> do

let arguments =
if argsTesting
then IDEMain.testing (cmapWithPrio LogIDEMain recorder) hlsPlugins
else IDEMain.defaultArguments (cmapWithPrio LogIDEMain recorder) hlsPlugins
then IDEMain.testing (cmapWithPrio LogIDEMain recorder) argsCwd hlsPlugins
else IDEMain.defaultArguments (cmapWithPrio LogIDEMain recorder) argsCwd hlsPlugins

IDEMain.defaultMain (cmapWithPrio LogIDEMain recorder) arguments
{ IDEMain.argsProjectRoot = Just argsCwd
{ IDEMain.argsProjectRoot = argsCwd
, IDEMain.argCommand = argsCommand
, IDEMain.argsHlsPlugins = IDEMain.argsHlsPlugins arguments <> pluginDescToIdePlugins [lspRecorderPlugin]

Expand Down
792 changes: 444 additions & 348 deletions ghcide/session-loader/Development/IDE/Session.hs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Development.IDE.Core.Shake as X (FastResult (..),
defineNoDiagnostics,
getClientConfig,
getPluginConfigAction,
ideLogger,
ideLogger, rootDir,
runIdeAction,
shakeExtras, use,
useNoFile,
Expand Down
15 changes: 14 additions & 1 deletion ghcide/src/Development/IDE/Core/RuleTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -492,14 +492,27 @@ data AddWatchedFile = AddWatchedFile deriving (Eq, Show, Typeable, Generic)
instance Hashable AddWatchedFile
instance NFData AddWatchedFile

data CradleLoc = CradleLoc deriving (Eq, Show, Typeable, Generic)
instance Hashable CradleLoc
instance NFData CradleLoc
type instance RuleResult CradleLoc = Maybe FilePath

data HieYaml = HieYaml deriving (Eq, Show, Typeable, Generic)
instance Hashable HieYaml
instance NFData HieYaml

data SessionCacheVersion = SessionCacheVersion deriving (Eq, Show, Typeable, Generic)
instance Hashable SessionCacheVersion
instance NFData SessionCacheVersion
type instance RuleResult SessionCacheVersion = Int

-- A local rule type to get caching. We want to use newCache, but it has
-- thread killed exception issues, so we lift it to a full rule.
-- https://github.com/digital-asset/daml/pull/2808#issuecomment-529639547
type instance RuleResult GhcSessionIO = IdeGhcSession

data IdeGhcSession = IdeGhcSession
{ loadSessionFun :: FilePath -> IO (IdeResult HscEnvEq, [FilePath])
{ loadSessionFun :: NormalizedFilePath -> Action (IdeResult HscEnvEq, [FilePath])
-- ^ Returns the Ghc session and the cradle dependencies
, sessionVersion :: !Int
-- ^ Used as Shake key, versions must be unique and not reused
Expand Down
14 changes: 8 additions & 6 deletions ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ import Language.LSP.Server (LspT)
import qualified Language.LSP.Server as LSP
import Language.LSP.VFS
import Prelude hiding (mod)
import System.Directory (doesFileExist,
makeAbsolute)
import System.Directory (doesFileExist)
import System.Info.Extra (isWindows)


Expand All @@ -179,6 +178,8 @@ import GHC (mgModSummaries)

#if MIN_VERSION_ghc(9,3,0)
import qualified Data.IntMap as IM
import HIE.Bios (findCradle)
import System.FilePath (normalise)
#endif


Expand All @@ -192,6 +193,7 @@ data Log
| LogTypecheckedFOI !NormalizedFilePath
deriving Show


instance Pretty Log where
pretty = \case
LogShake msg -> pretty msg
Expand Down Expand Up @@ -719,13 +721,13 @@ loadGhcSession recorder ghcSessionDepsConfig = do

defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \GhcSession file -> do
IdeGhcSession{loadSessionFun} <- useNoFile_ GhcSessionIO
(val,deps) <- liftIO $ loadSessionFun $ fromNormalizedFilePath file
-- loading is always returning a absolute path now
(val,deps) <- loadSessionFun file

-- add the deps to the Shake graph
let addDependency fp = do
-- VSCode uses absolute paths in its filewatch notifications
afp <- liftIO $ makeAbsolute fp
let nfp = toNormalizedFilePath' afp
let nfp = toNormalizedFilePath' fp
itExists <- getFileExists nfp
when itExists $ void $ do
use_ GetModificationTime nfp
Expand Down Expand Up @@ -853,7 +855,7 @@ getModIfaceFromDiskAndIndexRule recorder =
hie_loc = Compat.ml_hie_file $ ms_location ms
fileHash <- liftIO $ Util.getFileHash hie_loc
mrow <- liftIO $ withHieDb (\hieDb -> HieDb.lookupHieFileFromSource hieDb (fromNormalizedFilePath f))
hie_loc' <- liftIO $ traverse (makeAbsolute . HieDb.hieModuleHieFile) mrow
let hie_loc' = HieDb.hieModuleHieFile <$> mrow
case mrow of
Just row
| fileHash == HieDb.modInfoHash (HieDb.hieModInfo row)
Expand Down
8 changes: 5 additions & 3 deletions ghcide/src/Development/IDE/Core/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ initialise :: Recorder (WithPriority Log)
-> WithHieDb
-> IndexQueue
-> Monitoring
-> FilePath
-> IO IdeState
initialise recorder defaultConfig plugins mainRule lspEnv debouncer options withHieDb hiedbChan metrics = do
initialise recorder defaultConfig plugins mainRule lspEnv debouncer options withHieDb hiedbChan metrics rootDir = do
shakeProfiling <- do
let fromConf = optShakeProfiling options
fromEnv <- lookupEnv "GHCIDE_BUILD_PROFILING"
Expand All @@ -86,11 +87,12 @@ initialise recorder defaultConfig plugins mainRule lspEnv debouncer options with
hiedbChan
(optShakeOptions options)
metrics
$ do
(do
addIdeGlobal $ GlobalIdeOptions options
ofInterestRules (cmapWithPrio LogOfInterest recorder)
fileExistsRules (cmapWithPrio LogFileExists recorder) lspEnv
mainRule
mainRule)
rootDir

-- | Shutdown the Compiler Service.
shutdown :: IdeState -> IO ()
Expand Down
6 changes: 4 additions & 2 deletions ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
-- always stored as real Haskell values, whereas Shake serialises all 'A' values
-- between runs. To deserialise a Shake value, we just consult Values.
module Development.IDE.Core.Shake(
IdeState, shakeSessionInit, shakeExtras, shakeDb,
IdeState, shakeSessionInit, shakeExtras, shakeDb, rootDir,
ShakeExtras(..), getShakeExtras, getShakeExtrasRules,
KnownTargets, Target(..), toKnownFiles,
IdeRule, IdeResult,
Expand Down Expand Up @@ -535,6 +535,7 @@ data IdeState = IdeState
,shakeExtras :: ShakeExtras
,shakeDatabaseProfile :: ShakeDatabase -> IO (Maybe FilePath)
,stopMonitoring :: IO ()
,rootDir :: FilePath
}


Expand Down Expand Up @@ -623,11 +624,12 @@ shakeOpen :: Recorder (WithPriority Log)
-> ShakeOptions
-> Monitoring
-> Rules ()
-> FilePath
-> IO IdeState
shakeOpen recorder lspEnv defaultConfig idePlugins debouncer
shakeProfileDir (IdeReportProgress reportProgress)
ideTesting@(IdeTesting testing)
withHieDb indexQueue opts monitoring rules = mdo
withHieDb indexQueue opts monitoring rules rootDir = mdo

#if MIN_VERSION_ghc(9,3,0)
ideNc <- initNameCache 'r' knownKeyNames
Expand Down
20 changes: 12 additions & 8 deletions ghcide/src/Development/IDE/LSP/LanguageServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ runLanguageServer recorder options inH outH defaultConfig parseConfig onConfigCh
setupLSP ::
forall config err.
Recorder (WithPriority Log)
-> FilePath -- ^ root directory
-> (FilePath -> IO FilePath) -- ^ Map root paths to the location of the hiedb for the project
-> LSP.Handlers (ServerM config)
-> (LSP.LanguageContextEnv config -> Maybe FilePath -> WithHieDb -> IndexQueue -> IO IdeState)
-> (LSP.LanguageContextEnv config -> FilePath -> WithHieDb -> IndexQueue -> IO IdeState)
-> MVar ()
-> IO (LSP.LanguageContextEnv config -> TRequestMessage Method_Initialize -> IO (Either err (LSP.LanguageContextEnv config, IdeState)),
LSP.Handlers (ServerM config),
(LanguageContextEnv config, IdeState) -> ServerM config <~> IO)
setupLSP recorder getHieDbLoc userHandlers getIdeState clientMsgVar = do
setupLSP recorder defaultRoot getHieDbLoc userHandlers getIdeState clientMsgVar = do
-- Send everything over a channel, since you need to wait until after initialise before
-- LspFuncs is available
clientMsgChan :: Chan ReactorMessage <- newChan
Expand Down Expand Up @@ -177,7 +178,7 @@ setupLSP recorder getHieDbLoc userHandlers getIdeState clientMsgVar = do
-- Cancel requests are special since they need to be handled
-- out of order to be useful. Existing handlers are run afterwards.

let doInitialize = handleInit recorder getHieDbLoc getIdeState reactorLifetime exit clearReqId waitForCancel clientMsgChan
let doInitialize = handleInit recorder defaultRoot getHieDbLoc getIdeState reactorLifetime exit clearReqId waitForCancel clientMsgChan

let interpretHandler (env, st) = LSP.Iso (LSP.runLspT env . flip (runReaderT . unServerM) (clientMsgChan,st)) liftIO

Expand All @@ -186,19 +187,22 @@ setupLSP recorder getHieDbLoc userHandlers getIdeState clientMsgVar = do

handleInit
:: Recorder (WithPriority Log)
-> FilePath
-> (FilePath -> IO FilePath)
-> (LSP.LanguageContextEnv config -> Maybe FilePath -> WithHieDb -> IndexQueue -> IO IdeState)
-> (LSP.LanguageContextEnv config -> FilePath -> WithHieDb -> IndexQueue -> IO IdeState)
-> MVar ()
-> IO ()
-> (SomeLspId -> IO ())
-> (SomeLspId -> IO ())
-> Chan ReactorMessage
-> LSP.LanguageContextEnv config -> TRequestMessage Method_Initialize -> IO (Either err (LSP.LanguageContextEnv config, IdeState))
handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId waitForCancel clientMsgChan env (TRequestMessage _ _ m params) = otTracedHandler "Initialize" (show m) $ \sp -> do
handleInit recorder defaultRoot getHieDbLoc getIdeState lifetime exitClientMsg clearReqId waitForCancel clientMsgChan env (TRequestMessage _ _ m params) = otTracedHandler "Initialize" (show m) $ \sp -> do
traceWithSpan sp params
let root = LSP.resRootPath env
dir <- maybe getCurrentDirectory return root
dbLoc <- getHieDbLoc dir
-- only shift if lsp root is different from the rootDir
root <- case LSP.resRootPath env of
Just lspRoot | lspRoot /= defaultRoot -> setCurrentDirectory lspRoot >> return lspRoot
_ -> pure defaultRoot
dbLoc <- getHieDbLoc root
let initConfig = parseConfiguration params
logWith recorder Info $ LogRegisteringIdeConfig initConfig
dbMVar <- newEmptyMVar
Expand Down
45 changes: 21 additions & 24 deletions ghcide/src/Development/IDE/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ commandP plugins =


data Arguments = Arguments
{ argsProjectRoot :: Maybe FilePath
{ argsProjectRoot :: FilePath
, argCommand :: Command
, argsRules :: Rules ()
, argsHlsPlugins :: IdePlugins IdeState
Expand All @@ -226,9 +226,9 @@ data Arguments = Arguments
, argsDisableKick :: Bool -- ^ flag to disable kick used for testing
}

defaultArguments :: Recorder (WithPriority Log) -> IdePlugins IdeState -> Arguments
defaultArguments recorder plugins = Arguments
{ argsProjectRoot = Nothing
defaultArguments :: Recorder (WithPriority Log) -> FilePath -> IdePlugins IdeState -> Arguments
defaultArguments recorder fp plugins = Arguments
{ argsProjectRoot = fp
, argCommand = LSP
, argsRules = mainRule (cmapWithPrio LogRules recorder) def
, argsGhcidePlugin = mempty
Expand Down Expand Up @@ -271,11 +271,11 @@ defaultArguments recorder plugins = Arguments
}


testing :: Recorder (WithPriority Log) -> IdePlugins IdeState -> Arguments
testing recorder plugins =
testing :: Recorder (WithPriority Log) -> FilePath -> IdePlugins IdeState -> Arguments
testing recorder fp plugins =
let
arguments@Arguments{ argsHlsPlugins, argsIdeOptions, argsLspOptions } =
defaultArguments recorder plugins
arguments@Arguments{ argsHlsPlugins, argsIdeOptions, argsLspOptions } =
defaultArguments recorder fp plugins
hlsPlugins = pluginDescToIdePlugins $
idePluginsToPluginDesc argsHlsPlugins
++ [Test.blockCommandDescriptor "block-command", Test.plugin]
Expand Down Expand Up @@ -326,22 +326,18 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
logWith recorder Info $ LogLspStart (pluginId <$> ipMap argsHlsPlugins)

ideStateVar <- newEmptyMVar
let getIdeState :: LSP.LanguageContextEnv Config -> Maybe FilePath -> WithHieDb -> IndexQueue -> IO IdeState
let getIdeState :: LSP.LanguageContextEnv Config -> FilePath -> WithHieDb -> IndexQueue -> IO IdeState
getIdeState env rootPath withHieDb hieChan = do
traverse_ IO.setCurrentDirectory rootPath
t <- ioT
logWith recorder Info $ LogLspStartDuration t

dir <- maybe IO.getCurrentDirectory return rootPath

-- We want to set the global DynFlags right now, so that we can use
-- `unsafeGlobalDynFlags` even before the project is configured
_mlibdir <-
setInitialDynFlags (cmapWithPrio LogSession recorder) dir argsSessionLoadingOptions
setInitialDynFlags (cmapWithPrio LogSession recorder) rootPath argsSessionLoadingOptions
-- TODO: should probably catch/log/rethrow at top level instead
`catchAny` (\e -> logWith recorder Error (LogSetInitialDynFlagsException e) >> pure Nothing)

sessionLoader <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions dir
(sessionLoaderRule, sessionLoader) <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions rootPath
config <- LSP.runLspT env LSP.getConfig
let def_options = argsIdeOptions config sessionLoader

Expand All @@ -360,17 +356,18 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
(cmapWithPrio LogService recorder)
argsDefaultHlsConfig
argsHlsPlugins
rules
(rules <> sessionLoaderRule)
(Just env)
debouncer
ideOptions
withHieDb
hieChan
monitoring
rootPath
putMVar ideStateVar ide
pure ide

let setup = setupLSP (cmapWithPrio LogLanguageServer recorder) argsGetHieDbLoc (pluginHandlers plugins) getIdeState
let setup = setupLSP (cmapWithPrio LogLanguageServer recorder) argsProjectRoot argsGetHieDbLoc (pluginHandlers plugins) getIdeState
-- See Note [Client configuration in Rules]
onConfigChange cfg = do
-- TODO: this is nuts, we're converting back to JSON just to get a fingerprint
Expand All @@ -388,7 +385,7 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
runLanguageServer (cmapWithPrio LogLanguageServer recorder) options inH outH argsDefaultHlsConfig argsParseConfig onConfigChange setup
dumpSTMStats
Check argFiles -> do
dir <- maybe IO.getCurrentDirectory return argsProjectRoot
let dir = argsProjectRoot
dbLoc <- getHieDbLoc dir
runWithDb (cmapWithPrio LogSession recorder) dbLoc $ \hiedb hieChan -> do
-- GHC produces messages with UTF8 in them, so make sure the terminal doesn't error
Expand All @@ -411,14 +408,14 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
putStrLn $ "Found " ++ show n ++ " cradle" ++ ['s' | n /= 1]
when (n > 0) $ putStrLn $ " (" ++ intercalate ", " (catMaybes ucradles) ++ ")"
putStrLn "\nStep 3/4: Initializing the IDE"
sessionLoader <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions dir
(sessionLoaderRule, sessionLoader) <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions dir
let def_options = argsIdeOptions argsDefaultHlsConfig sessionLoader
ideOptions = def_options
{ optCheckParents = pure NeverCheck
, optCheckProject = pure False
, optModifyDynFlags = optModifyDynFlags def_options <> pluginModifyDynflags plugins
}
ide <- initialise (cmapWithPrio LogService recorder) argsDefaultHlsConfig argsHlsPlugins rules Nothing debouncer ideOptions hiedb hieChan mempty
ide <- initialise (cmapWithPrio LogService recorder) argsDefaultHlsConfig argsHlsPlugins (rules <> sessionLoaderRule) Nothing debouncer ideOptions hiedb hieChan mempty dir
shakeSessionInit (cmapWithPrio LogShake recorder) ide
registerIdeConfiguration (shakeExtras ide) $ IdeConfiguration mempty (hashed Nothing)

Expand All @@ -436,7 +433,7 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re

unless (null failed) (exitWith $ ExitFailure (length failed))
Db opts cmd -> do
root <- maybe IO.getCurrentDirectory return argsProjectRoot
let root = argsProjectRoot
dbLoc <- getHieDbLoc root
hPutStrLn stderr $ "Using hiedb at: " ++ dbLoc
mlibdir <- setInitialDynFlags (cmapWithPrio LogSession recorder) root def
Expand All @@ -446,17 +443,17 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
Just libdir -> retryOnSqliteBusy (cmapWithPrio LogSession recorder) rng (HieDb.runCommand libdir opts{HieDb.database = dbLoc} cmd)

Custom (IdeCommand c) -> do
root <- maybe IO.getCurrentDirectory return argsProjectRoot
let root = argsProjectRoot
dbLoc <- getHieDbLoc root
runWithDb (cmapWithPrio LogSession recorder) dbLoc $ \hiedb hieChan -> do
sessionLoader <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions "."
(sessionLoaderRule, sessionLoader) <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions "."
let def_options = argsIdeOptions argsDefaultHlsConfig sessionLoader
ideOptions = def_options
{ optCheckParents = pure NeverCheck
, optCheckProject = pure False
, optModifyDynFlags = optModifyDynFlags def_options <> pluginModifyDynflags plugins
}
ide <- initialise (cmapWithPrio LogService recorder) argsDefaultHlsConfig argsHlsPlugins rules Nothing debouncer ideOptions hiedb hieChan mempty
ide <- initialise (cmapWithPrio LogService recorder) argsDefaultHlsConfig argsHlsPlugins (rules <> sessionLoaderRule) Nothing debouncer ideOptions hiedb hieChan mempty root
shakeSessionInit (cmapWithPrio LogShake recorder) ide
registerIdeConfiguration (shakeExtras ide) $ IdeConfiguration mempty (hashed Nothing)
c ide
Expand Down
Loading
Loading