Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f3cfe9d

Browse files
committed
Update the diagnostic publishing function
1 parent cb51e9e commit f3cfe9d

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ modifyCache f = modifyModuleCache f
7171

7272
-- ---------------------------------------------------------------------
7373

74-
type PublishDiagnostics = Int -> J.NormalizedUri -> J.TextDocumentVersion -> J.DiagnosticsBySource -> IO ()
74+
type PublishDiagnostics = J.NormalizedUri -> J.TextDocumentVersion -> J.DiagnosticsBySource -> IO ()
7575

7676
-- | Run the given action in context and initialise a session with hie-bios.
7777
-- If a context is given, the context is used to initialise a session for GHC.
@@ -186,7 +186,7 @@ loadCradle publishDiagnostics iniDynFlags (NewCradle fp) def action = do
186186
source = Just "bios"
187187
diag = Diagnostic range sev Nothing source (Text.unlines msgTxt) Nothing
188188

189-
liftIO $ publishDiagnostics maxBound normalizedUri Nothing
189+
liftIO $ publishDiagnostics normalizedUri Nothing
190190
(Map.singleton source (SL.singleton diag))
191191

192192
return $ IdeResultFail $ IdeError

src/Haskell/Ide/Engine/Server.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,17 @@ updatePositionMap uri changes = pluginGetFile "updatePositionMap: " uri $ \file
359359
-- ---------------------------------------------------------------------
360360

361361
publishDiagnostics :: (MonadIO m, MonadReader REnv m)
362-
=> Int -> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
363-
publishDiagnostics maxToSend uri' mv diags = do
362+
=> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
363+
publishDiagnostics uri' mv diags = do
364364
lf <- asks lspFuncs
365-
publishDiagnostics' lf maxToSend uri' mv diags
365+
publishDiagnostics' lf uri' mv diags
366366

367367

368368
publishDiagnostics' :: MonadIO m
369-
=> Core.LspFuncs c -> Int -> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
370-
publishDiagnostics' lf maxToSend uri' mv diags =
371-
liftIO $ Core.publishDiagnosticsFunc lf maxToSend uri' mv diags
369+
=> Core.LspFuncs Config -> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
370+
publishDiagnostics' lf uri' mv diags = do
371+
config <- liftIO $ fromMaybe Data.Default.def <$> Core.config lf
372+
liftIO $ Core.publishDiagnosticsFunc lf (maxNumberOfProblems config) uri' mv diags
372373

373374

374375
-- ---------------------------------------------------------------------
@@ -943,18 +944,17 @@ requestDiagnosticsNormal tn file mVer = do
943944
sendOneGhc :: J.DiagnosticSource -> (J.NormalizedUri, [Diagnostic]) -> R ()
944945
sendOneGhc pid (fileUri,ds) = do
945946
if any (hasSeverity J.DsError) ds
946-
then publishDiagnostics maxToSend fileUri Nothing
947+
then publishDiagnostics fileUri Nothing
947948
(Map.fromList [(Just "hlint",SL.toSortedList []),(Just pid,SL.toSortedList ds)])
948949
else sendOne pid (fileUri,ds)
949950

950951
sendOne pid (fileUri,ds) = do
951-
publishDiagnostics maxToSend fileUri Nothing (Map.fromList [(Just pid,SL.toSortedList ds)])
952+
publishDiagnostics fileUri Nothing (Map.fromList [(Just pid,SL.toSortedList ds)])
952953

953954
hasSeverity :: J.DiagnosticSeverity -> J.Diagnostic -> Bool
954955
hasSeverity sev (J.Diagnostic _ (Just s) _ _ _ _) = s == sev
955956
hasSeverity _ _ = False
956-
sendEmpty = publishDiagnostics maxToSend (J.toNormalizedUri file) Nothing (Map.fromList [(Just "bios",SL.toSortedList [])])
957-
maxToSend = maxNumberOfProblems clientConfig
957+
sendEmpty = publishDiagnostics (J.toNormalizedUri file) Nothing (Map.fromList [(Just "bios",SL.toSortedList [])])
958958

959959
let sendHlint = hlintOn clientConfig
960960
when sendHlint $ do

test/dispatcher/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ startServer = do
8181
(\lid errCode e -> logToChan logChan ("received an error", Left (lid, errCode, e)))
8282
(\g x -> g x)
8383
dummyLspFuncs
84+
(\_ _ _ -> return ())
8485
(Just crdl)
8586

8687
return (scheduler, logChan, dispatcher)

test/plugin-dispatcher/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ newPluginSpec = do
5151
(\_ _ _ -> return ())
5252
(\f x -> f x)
5353
dummyLspFuncs
54+
(\_ _ _ -> return ())
5455
(Just crdl)
5556

5657
updateDocument scheduler (filePathToUri "test") 3

0 commit comments

Comments
 (0)