Skip to content

Commit ecb7ca0

Browse files
authored
Merge branch 'master' into hls-testing
2 parents abaec17 + f4ce73f commit ecb7ca0

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

exe/Main.hs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
{-# LANGUAGE OverloadedStrings #-}
66
module Main(main) where
77

8+
import Control.Arrow ((&&&))
89
import Control.Monad.IO.Class (liftIO)
910
import Data.Function ((&))
1011
import Data.Text (Text)
12+
import qualified Development.IDE.Main as GhcideMain
1113
import Development.IDE.Types.Logger (Doc,
1214
Priority (Debug, Error, Info),
1315
WithPriority (WithPriority, priority),
1416
cfilter, cmapWithPrio,
1517
defaultLayoutOptions,
1618
layoutPretty,
1719
makeDefaultStderrRecorder,
18-
renderStrict,
20+
payload, renderStrict,
1921
withDefaultRecorder)
2022
import qualified Development.IDE.Types.Logger as Logger
2123
import Ide.Arguments (Arguments (..),
@@ -62,24 +64,28 @@ main = do
6264
liftIO $ (cb1 <> cb2) env
6365
}
6466

65-
let (minPriority, logFilePath, includeExamplePlugins) =
67+
let (argsTesting, minPriority, logFilePath, includeExamplePlugins) =
6668
case args of
6769
Ghcide GhcideArguments{ argsTesting, argsDebugOn, argsLogFile, argsExamplePlugin } ->
6870
let minPriority = if argsDebugOn || argsTesting then Debug else Info
69-
in (minPriority, argsLogFile, argsExamplePlugin)
70-
_ -> (Info, Nothing, False)
71+
in (argsTesting, minPriority, argsLogFile, argsExamplePlugin)
72+
_ -> (False, Info, Nothing, False)
7173

7274
withDefaultRecorder logFilePath Nothing minPriority $ \textWithPriorityRecorder -> do
7375
let
74-
recorder = cmapWithPrio pretty $ mconcat
76+
recorder = cmapWithPrio (pretty &&& id) $ mconcat
7577
[textWithPriorityRecorder
7678
& cfilter (\WithPriority{ priority } -> priority >= minPriority)
79+
& cmapWithPrio fst
7780
, lspMessageRecorder
7881
& cfilter (\WithPriority{ priority } -> priority >= Error)
79-
& cmapWithPrio renderDoc
82+
& cmapWithPrio (renderDoc . fst)
8083
, lspLogRecorder
8184
& cfilter (\WithPriority{ priority } -> priority >= minPriority)
82-
& cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions)
85+
& cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions . fst)
86+
-- do not log heap stats to the LSP log as they interfere with the
87+
-- ability of lsp-test to detect a stuck server in tests and benchmarks
88+
& if argsTesting then cfilter (not . heapStats . snd . payload) else id
8389
]
8490
plugins = (Plugins.idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins)
8591

@@ -96,3 +102,7 @@ renderDoc d = renderStrict $ layoutPretty defaultLayoutOptions $ vsep
96102

97103
issueTrackerUrl :: Doc a
98104
issueTrackerUrl = "https://github.com/haskell/haskell-language-server/issues"
105+
106+
heapStats :: Log -> Bool
107+
heapStats (LogIdeMain (IdeMain.LogIDEMain (GhcideMain.LogHeapStats _))) = True
108+
heapStats _ = False

ghcide/src/Development/IDE/Core/ProgressReporting.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ data State
6363
-- | State transitions used in 'delayedProgressReporting'
6464
data Transition = Event ProgressEvent | StopProgress
6565

66-
updateState :: IO () -> Transition -> State -> IO State
66+
updateState :: IO (Async ()) -> Transition -> State -> IO State
6767
updateState _ _ Stopped = pure Stopped
68-
updateState start (Event KickStarted) NotStarted = Running <$> async start
69-
updateState start (Event KickStarted) (Running a) = cancel a >> Running <$> async start
68+
updateState start (Event KickStarted) NotStarted = Running <$> start
69+
updateState start (Event KickStarted) (Running a) = cancel a >> Running <$> start
7070
updateState _ (Event KickCompleted) (Running a) = cancel a $> NotStarted
7171
updateState _ (Event KickCompleted) st = pure st
7272
updateState _ StopProgress (Running a) = cancel a $> Stopped
@@ -110,12 +110,13 @@ delayedProgressReporting
110110
-> Maybe (LSP.LanguageContextEnv c)
111111
-> ProgressReportingStyle
112112
-> IO ProgressReporting
113-
delayedProgressReporting before after lspEnv optProgressStyle = do
113+
delayedProgressReporting before after Nothing optProgressStyle = noProgressReporting
114+
delayedProgressReporting before after (Just lspEnv) optProgressStyle = do
114115
inProgressState <- newInProgress
115116
progressState <- newVar NotStarted
116117
let progressUpdate event = updateStateVar $ Event event
117118
progressStop = updateStateVar StopProgress
118-
updateStateVar = modifyVar_ progressState . updateState (mRunLspT lspEnv $ lspShakeProgress inProgressState)
119+
updateStateVar = modifyVar_ progressState . updateState (lspShakeProgress inProgressState)
119120

120121
inProgress = updateStateForFile inProgressState
121122
return ProgressReporting{..}
@@ -127,11 +128,11 @@ delayedProgressReporting before after lspEnv optProgressStyle = do
127128
u <- ProgressTextToken . T.pack . show . hashUnique <$> liftIO newUnique
128129

129130
b <- liftIO newBarrier
130-
void $ LSP.sendRequest LSP.SWindowWorkDoneProgressCreate
131+
void $ LSP.runLspT lspEnv $ LSP.sendRequest LSP.SWindowWorkDoneProgressCreate
131132
LSP.WorkDoneProgressCreateParams { _token = u } $ liftIO . signalBarrier b
132-
ready <- liftIO $ waitBarrier b
133-
134-
for_ ready $ const $ bracket_ (start u) (stop u) (loop u 0)
133+
liftIO $ async $ do
134+
ready <- waitBarrier b
135+
LSP.runLspT lspEnv $ for_ ready $ const $ bracket_ (start u) (stop u) (loop u 0)
135136
where
136137
start id = LSP.sendNotification LSP.SProgress $
137138
LSP.ProgressParams

0 commit comments

Comments
 (0)