Skip to content

Commit d76a21f

Browse files
committed
Fix test
1 parent 7eeda96 commit d76a21f

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

ghcide/src/Development/IDE/Main.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Control.Exception.Safe (SomeException,
2121
import Control.Monad.Extra (concatMapM, unless,
2222
when)
2323
import qualified Data.Aeson.Encode.Pretty as A
24+
import Data.Coerce (coerce)
2425
import Data.Default (Default (def))
2526
import Data.Foldable (traverse_)
2627
import Data.Hashable (hashed)
@@ -92,7 +93,8 @@ import Development.IDE.Types.Logger (Logger,
9293
Recorder,
9394
WithPriority,
9495
cmapWithPrio,
95-
logWith, vsep, (<+>))
96+
logWith, nest, vsep,
97+
(<+>))
9698
import Development.IDE.Types.Monitoring (Monitoring)
9799
import Development.IDE.Types.Options (IdeGhcSession,
98100
IdeOptions (optCheckParents, optCheckProject, optReportProgress, optRunSubset),
@@ -146,7 +148,7 @@ import Text.Printf (printf)
146148

147149
data Log
148150
= LogHeapStats !HeapStats.Log
149-
| LogLspStart
151+
| LogLspStart [PluginId]
150152
| LogLspStartDuration !Seconds
151153
| LogShouldRunSubset !Bool
152154
| LogOnlyPartialGhc92Support
@@ -163,10 +165,12 @@ data Log
163165
instance Pretty Log where
164166
pretty = \case
165167
LogHeapStats log -> pretty log
166-
LogLspStart ->
167-
vsep
168-
[ "Staring LSP server..."
169-
, "If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!"]
168+
LogLspStart pluginIds ->
169+
nest 2 $ vsep
170+
[ "Starting LSP server..."
171+
, "If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!"
172+
, "PluginIds:" <+> pretty (coerce @_ @[T.Text] pluginIds)
173+
]
170174
LogLspStartDuration duration ->
171175
"Started LSP server in" <+> pretty (showDuration duration)
172176
LogShouldRunSubset shouldRunSubset ->
@@ -336,7 +340,7 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
336340
LT.putStrLn $ decodeUtf8 $ A.encodePretty $ pluginsToDefaultConfig argsHlsPlugins
337341
LSP -> withNumCapabilities (maybe (numProcessors `div` 2) fromIntegral argsThreads) $ do
338342
t <- offsetTime
339-
log Info LogLspStart
343+
log Info $ LogLspStart (pluginId <$> ipMap argsHlsPlugins)
340344

341345
let getIdeState :: LSP.LanguageContextEnv Config -> Maybe FilePath -> WithHieDb -> IndexQueue -> IO IdeState
342346
getIdeState env rootPath withHieDb hieChan = do

ghcide/test/exe/Main.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ initializeResponseTests = withResource acquire release tests where
290290
doTest = do
291291
ir <- getInitializeResponse
292292
let Just ExecuteCommandOptions {_commands = List commands} = getActual $ innerCaps ir
293-
zipWithM_ (\e o -> T.isSuffixOf e o @? show (e,o)) expected commands
293+
commandNames = (!! 2) . T.splitOn ":" <$> commands
294+
zipWithM_ (\e o -> T.isSuffixOf e o @? show (e,o)) (sort expected) (sort commandNames)
294295

295296
innerCaps :: ResponseMessage Initialize -> ServerCapabilities
296297
innerCaps (ResponseMessage _ _ (Right (InitializeResult c _))) = c

hls-plugin-api/src/Ide/PluginUtils.hs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module Ide.PluginUtils
3636
where
3737

3838

39+
import Control.Arrow ((&&&))
3940
import Control.Monad.Extra (maybeM)
4041
import Control.Monad.Trans.Class (lift)
4142
import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE)
@@ -224,15 +225,8 @@ positionInRange p (Range sp ep) = sp <= p && p < ep -- Range's end position is e
224225
-- ---------------------------------------------------------------------
225226

226227
allLspCmdIds' :: T.Text -> IdePlugins ideState -> [T.Text]
227-
allLspCmdIds' pid (IdePlugins ls) = mkPlugin (allLspCmdIds pid) (Just . pluginCommands)
228-
where
229-
justs (p, Just x) = [(p, x)]
230-
justs (_, Nothing) = []
231-
232-
233-
mkPlugin maker selector
234-
= maker $ concatMap (\p -> justs (pluginId p, selector p)) ls
235-
228+
allLspCmdIds' pid (IdePlugins ls) =
229+
allLspCmdIds pid $ map (pluginId &&& pluginCommands) ls
236230

237231
allLspCmdIds :: T.Text -> [(PluginId, [PluginCommand ideState])] -> [T.Text]
238232
allLspCmdIds pid commands = concatMap go commands

0 commit comments

Comments
 (0)