Skip to content

Commit bd7c9ba

Browse files
authored
improve logging in semantic tokens rule (#4135)
* improve logging in semantic tokens rule
1 parent 16912cc commit bd7c9ba

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ import Development.IDE (Action,
3333
WithPriority,
3434
cmapWithPrio, define,
3535
fromNormalizedFilePath,
36-
hieKind, use_)
37-
import Development.IDE.Core.PluginUtils (runActionE,
36+
hieKind)
37+
import Development.IDE.Core.PluginUtils (runActionE, useE,
3838
useWithStaleE)
3939
import Development.IDE.Core.Rules (toIdeResult)
4040
import Development.IDE.Core.RuleTypes (DocAndTyThingMap (..))
4141
import Development.IDE.Core.Shake (ShakeExtras (..),
4242
getShakeExtras,
43-
getVirtualFile,
44-
useWithStale_)
43+
getVirtualFile)
4544
import Development.IDE.GHC.Compat hiding (Warning)
4645
import Development.IDE.GHC.Compat.Util (mkFastString)
4746
import Ide.Logger (logWith)
@@ -124,8 +123,8 @@ semanticTokensFullDelta recorder state pid param = do
124123
getSemanticTokensRule :: Recorder (WithPriority SemanticLog) -> Rules ()
125124
getSemanticTokensRule recorder =
126125
define (cmapWithPrio LogShake recorder) $ \GetSemanticTokens nfp -> handleError recorder $ do
127-
(HAR {..}) <- lift $ use_ GetHieAst nfp
128-
(DKMap {getTyThingMap}, _) <- lift $ useWithStale_ GetDocMap nfp
126+
(HAR {..}) <- withExceptT LogDependencyError $ useE GetHieAst nfp
127+
(DKMap {getTyThingMap}, _) <- withExceptT LogDependencyError $ useWithStaleE GetDocMap nfp
129128
ast <- handleMaybe (LogNoAST $ show nfp) $ getAsts hieAst M.!? (HiePath . mkFastString . fromNormalizedFilePath) nfp
130129
virtualFile <- handleMaybeM LogNoVF $ getVirtualFile nfp
131130
let hsFinder = idSemantic getTyThingMap (hieKindFunMasksKind hieKind) refMap

plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Types.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import GHC.Generics (Generic)
1919
import Language.LSP.Protocol.Types
2020
-- import template haskell
2121
import Data.Text (Text)
22+
import Ide.Plugin.Error (PluginError)
2223
import Language.Haskell.TH.Syntax (Lift)
2324

2425

@@ -137,12 +138,12 @@ data HieFunMaskKind kind where
137138

138139
data SemanticLog
139140
= LogShake Shake.Log
141+
| LogDependencyError PluginError
140142
| LogNoAST FilePath
141143
| LogConfig SemanticTokensConfig
142144
| LogMsg String
143145
| LogNoVF
144146
| LogSemanticTokensDeltaMisMatch Text (Maybe Text)
145-
deriving (Show)
146147

147148
instance Pretty SemanticLog where
148149
pretty theLog = case theLog of
@@ -154,6 +155,7 @@ instance Pretty SemanticLog where
154155
LogSemanticTokensDeltaMisMatch previousIdFromRequest previousIdFromCache
155156
-> "SemanticTokensDeltaMisMatch: previousIdFromRequest: " <> pretty previousIdFromRequest
156157
<> " previousIdFromCache: " <> pretty previousIdFromCache
158+
LogDependencyError err -> "SemanticTokens' dependency error: " <> pretty err
157159

158160

159161
type SemanticTokenId = Text

0 commit comments

Comments
 (0)