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

Commit fdad4c8

Browse files
fendorAvi-D-coder
authored andcommitted
Update the diagnostic publishing function
1 parent 19256f3 commit fdad4c8

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
@@ -363,16 +363,17 @@ updatePositionMap uri changes = pluginGetFile "updatePositionMap: " uri $ \file
363363
-- ---------------------------------------------------------------------
364364

365365
publishDiagnostics :: (MonadIO m, MonadReader REnv m)
366-
=> Int -> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
367-
publishDiagnostics maxToSend uri' mv diags = do
366+
=> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
367+
publishDiagnostics uri' mv diags = do
368368
lf <- asks lspFuncs
369-
publishDiagnostics' lf maxToSend uri' mv diags
369+
publishDiagnostics' lf uri' mv diags
370370

371371

372372
publishDiagnostics' :: MonadIO m
373-
=> Core.LspFuncs c -> Int -> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
374-
publishDiagnostics' lf maxToSend uri' mv diags =
375-
liftIO $ Core.publishDiagnosticsFunc lf maxToSend uri' mv diags
373+
=> Core.LspFuncs Config -> J.NormalizedUri -> J.TextDocumentVersion -> DiagnosticsBySource -> m ()
374+
publishDiagnostics' lf uri' mv diags = do
375+
config <- liftIO $ fromMaybe Data.Default.def <$> Core.config lf
376+
liftIO $ Core.publishDiagnosticsFunc lf (maxNumberOfProblems config) uri' mv diags
376377

377378

378379
-- ---------------------------------------------------------------------
@@ -947,18 +948,17 @@ requestDiagnosticsNormal tn file mVer = do
947948
sendOneGhc :: J.DiagnosticSource -> (J.NormalizedUri, [Diagnostic]) -> R ()
948949
sendOneGhc pid (fileUri,ds) = do
949950
if any (hasSeverity J.DsError) ds
950-
then publishDiagnostics maxToSend fileUri Nothing
951+
then publishDiagnostics fileUri Nothing
951952
(Map.fromList [(Just "hlint",SL.toSortedList []),(Just pid,SL.toSortedList ds)])
952953
else sendOne pid (fileUri,ds)
953954

954955
sendOne pid (fileUri,ds) = do
955-
publishDiagnostics maxToSend fileUri Nothing (Map.fromList [(Just pid,SL.toSortedList ds)])
956+
publishDiagnostics fileUri Nothing (Map.fromList [(Just pid,SL.toSortedList ds)])
956957

957958
hasSeverity :: J.DiagnosticSeverity -> J.Diagnostic -> Bool
958959
hasSeverity sev (J.Diagnostic _ (Just s) _ _ _ _) = s == sev
959960
hasSeverity _ _ = False
960-
sendEmpty = publishDiagnostics maxToSend (J.toNormalizedUri file) Nothing (Map.fromList [(Just "bios",SL.toSortedList [])])
961-
maxToSend = maxNumberOfProblems clientConfig
961+
sendEmpty = publishDiagnostics (J.toNormalizedUri file) Nothing (Map.fromList [(Just "bios",SL.toSortedList [])])
962962

963963
let sendHlint = hlintOn clientConfig
964964
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)