Skip to content

Commit cbbf59f

Browse files
committed
Use lens for updating Diagnostic
1 parent 6eac56f commit cbbf59f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import Control.Concurrent.Strict
6464
import Control.DeepSeq
6565
import Control.Exception (evaluate)
6666
import Control.Exception.Safe
67-
import Control.Lens ((%~), (&))
67+
import Control.Lens ((%~), (&), (.~))
6868
import Control.Monad.Extra
6969
import Control.Monad.IO.Unlift
7070
import Control.Monad.Reader
@@ -162,6 +162,7 @@ import Ide.Types (DynFlagsModificat
162162
import Language.LSP.Protocol.Message (SMethod (SMethod_CustomMethod, SMethod_WindowShowMessage))
163163
import Language.LSP.Protocol.Types (MessageType (MessageType_Info),
164164
ShowMessageParams (ShowMessageParams))
165+
import qualified Language.LSP.Protocol.Lens as JL
165166
import Language.LSP.Server (LspT)
166167
import qualified Language.LSP.Server as LSP
167168
import Language.LSP.VFS
@@ -489,7 +490,7 @@ reportImportCyclesRule recorder =
489490
cycleErrorInFile _ _ = Nothing
490491
toDiag imp mods =
491492
ideErrorWithSource (Just "Import cycle detection") (Just DiagnosticSeverity_Error) fp ("Cyclic module dependency between " <> showCycle mods) Nothing
492-
& fdLspDiagnosticL %~ \lspDiag -> (lspDiag { _range = rng } :: Diagnostic)
493+
& fdLspDiagnosticL %~ JL.range .~ rng
493494
where rng = fromMaybe noRange $ srcSpanToRange (getLoc imp)
494495
fp = toNormalizedFilePath' $ fromMaybe noFilePath $ srcSpanToFilename (getLoc imp)
495496
getModuleName file = do

0 commit comments

Comments
 (0)