|
1 | 1 | {-# LANGUAGE DataKinds #-}
|
2 | 2 | {-# LANGUAGE DerivingStrategies #-}
|
| 3 | +{-# LANGUAGE FlexibleContexts #-} |
3 | 4 | {-# LANGUAGE FlexibleInstances #-}
|
4 | 5 | {-# LANGUAGE MultiParamTypeClasses #-}
|
5 | 6 | {-# LANGUAGE NamedFieldPuns #-}
|
6 | 7 | {-# LANGUAGE OverloadedLabels #-}
|
7 | 8 | {-# LANGUAGE OverloadedStrings #-}
|
8 | 9 | {-# LANGUAGE RecordWildCards #-}
|
9 | 10 | {-# LANGUAGE ScopedTypeVariables #-}
|
| 11 | +{-# LANGUAGE TemplateHaskell #-} |
10 | 12 | {-# LANGUAGE TypeFamilies #-}
|
11 | 13 | {-# LANGUAGE UnicodeSyntax #-}
|
12 | 14 |
|
13 | 15 | -- |
|
14 | 16 | -- This module provides the core functionality of the plugin.
|
15 |
| -module Ide.Plugin.SemanticTokens.Internal (semanticTokensFull, getSemanticTokensRule, persistentGetSemanticTokensRule) where |
| 17 | +module Ide.Plugin.SemanticTokens.Internal (semanticTokensFull, getSemanticTokensRule, persistentGetSemanticTokensRule, semanticConfigProperties) where |
16 | 18 |
|
17 |
| -import Control.Lens ((^.)) |
18 |
| -import Control.Monad.Except (ExceptT, liftEither, |
19 |
| - withExceptT) |
20 |
| -import Control.Monad.Trans (lift) |
21 |
| -import Control.Monad.Trans.Except (runExceptT) |
22 |
| -import Data.Aeson (ToJSON (toJSON)) |
23 |
| -import qualified Data.Map as Map |
24 |
| -import Development.IDE (Action, |
25 |
| - GetDocMap (GetDocMap), |
26 |
| - GetHieAst (GetHieAst), |
27 |
| - HieAstResult (HAR, hieAst, hieModule, refMap), |
28 |
| - IdeResult, IdeState, |
29 |
| - Priority (..), Recorder, |
30 |
| - Rules, WithPriority, |
31 |
| - cmapWithPrio, define, |
32 |
| - fromNormalizedFilePath, |
33 |
| - hieKind, logPriority, |
34 |
| - usePropertyAction, use_) |
35 |
| -import Development.IDE.Core.PluginUtils (runActionE, |
36 |
| - useWithStaleE) |
37 |
| -import Development.IDE.Core.PositionMapping (idDelta) |
38 |
| -import Development.IDE.Core.Rules (toIdeResult) |
39 |
| -import Development.IDE.Core.RuleTypes (DocAndTyThingMap (..)) |
40 |
| -import Development.IDE.Core.Shake (addPersistentRule, |
41 |
| - getVirtualFile, |
42 |
| - useWithStale_) |
43 |
| -import Development.IDE.GHC.Compat hiding (Warning) |
44 |
| -import Development.IDE.GHC.Compat.Util (mkFastString) |
45 |
| -import Ide.Logger (logWith) |
46 |
| -import Ide.Plugin.Error (PluginError (PluginInternalError), |
47 |
| - getNormalizedFilePathE, |
48 |
| - handleMaybe, |
49 |
| - handleMaybeM) |
| 19 | +import Control.Lens ((^.)) |
| 20 | +import Control.Monad.Except (ExceptT, liftEither, |
| 21 | + withExceptT) |
| 22 | +import Control.Monad.Trans (lift) |
| 23 | +import Control.Monad.Trans.Except (runExceptT) |
| 24 | +import Data.Aeson (ToJSON (toJSON)) |
| 25 | +import qualified Data.Map as Map |
| 26 | +import Development.IDE (Action, |
| 27 | + GetDocMap (GetDocMap), |
| 28 | + GetHieAst (GetHieAst), |
| 29 | + HieAstResult (HAR, hieAst, hieModule, refMap), |
| 30 | + IdeResult, IdeState, |
| 31 | + Priority (..), |
| 32 | + Recorder, Rules, |
| 33 | + WithPriority, |
| 34 | + cmapWithPrio, define, |
| 35 | + fromNormalizedFilePath, |
| 36 | + hieKind, logPriority, |
| 37 | + usePropertyAction, |
| 38 | + use_) |
| 39 | +import Development.IDE.Core.PluginUtils (runActionE, |
| 40 | + useWithStaleE) |
| 41 | +import Development.IDE.Core.PositionMapping (idDelta) |
| 42 | +import Development.IDE.Core.Rules (toIdeResult) |
| 43 | +import Development.IDE.Core.RuleTypes (DocAndTyThingMap (..)) |
| 44 | +import Development.IDE.Core.Shake (addPersistentRule, |
| 45 | + getVirtualFile, |
| 46 | + useWithStale_) |
| 47 | +import Development.IDE.GHC.Compat hiding (Warning) |
| 48 | +import Development.IDE.GHC.Compat.Util (mkFastString) |
| 49 | +import Ide.Logger (logWith) |
| 50 | +import Ide.Plugin.Error (PluginError (PluginInternalError), |
| 51 | + getNormalizedFilePathE, |
| 52 | + handleMaybe, |
| 53 | + handleMaybeM) |
50 | 54 | import Ide.Plugin.SemanticTokens.Mappings
|
51 | 55 | import Ide.Plugin.SemanticTokens.Query
|
| 56 | +import Ide.Plugin.SemanticTokens.SemanticConfig (mkSemanticConfigFunctions) |
52 | 57 | import Ide.Plugin.SemanticTokens.Types
|
53 | 58 | import Ide.Types
|
54 |
| -import qualified Language.LSP.Protocol.Lens as L |
55 |
| -import Language.LSP.Protocol.Message (Method (Method_TextDocumentSemanticTokensFull)) |
56 |
| -import Language.LSP.Protocol.Types (NormalizedFilePath, |
57 |
| - SemanticTokens, |
58 |
| - type (|?) (InL)) |
59 |
| -import Prelude hiding (span) |
| 59 | +import qualified Language.LSP.Protocol.Lens as L |
| 60 | +import Language.LSP.Protocol.Message (Method (Method_TextDocumentSemanticTokensFull)) |
| 61 | +import Language.LSP.Protocol.Types (NormalizedFilePath, |
| 62 | + SemanticTokenTypes, |
| 63 | + SemanticTokens, |
| 64 | + type (|?) (InL)) |
| 65 | +import Prelude hiding (span) |
60 | 66 |
|
61 | 67 |
|
| 68 | +$mkSemanticConfigFunctions |
| 69 | + |
62 | 70 | -----------------------
|
63 | 71 | ---- the api
|
64 | 72 | -----------------------
|
65 | 73 |
|
66 | 74 | computeSemanticTokens :: Recorder (WithPriority SemanticLog) -> PluginId -> IdeState -> NormalizedFilePath -> ExceptT PluginError Action SemanticTokens
|
67 | 75 | computeSemanticTokens recorder pid _ nfp = do
|
68 |
| - logWith recorder Debug (LogMsg "computeSemanticTokens start") |
69 |
| - config :: SemanticTokensConfig <- lift $ usePropertyAction #tokenMapping pid semanticConfigProperties |
70 |
| - logWith recorder Debug (LogMsg $ show $ toJSON config) |
| 76 | + config <- lift $ useSemanticConfigAction pid |
71 | 77 | logWith recorder Debug (LogConfig config)
|
72 | 78 | (RangeHsSemanticTokenTypes {rangeSemanticMap}, mapping) <- useWithStaleE GetSemanticTokens nfp
|
73 | 79 | withExceptT PluginInternalError $ liftEither $ rangeSemanticMapSemanticTokens config mapping rangeSemanticMap
|
|
0 commit comments