Skip to content

Commit 92f4bd4

Browse files
authored
Remove unused config (#3107)
1 parent e55004a commit 92f4bd4

File tree

5 files changed

+33
-68
lines changed

5 files changed

+33
-68
lines changed

plugins/hls-class-plugin/src/Ide/Plugin/Class.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ descriptor recorder plId = (defaultPluginDescriptor plId)
1313
, pluginRules = rules recorder
1414
, pluginHandlers = mkPluginHandler STextDocumentCodeAction (codeAction recorder)
1515
<> mkPluginHandler STextDocumentCodeLens codeLens
16-
, pluginConfigDescriptor =
17-
defaultConfigDescriptor { configCustomConfig = mkCustomConfig properties }
1816
}
1917

2018
commands :: PluginId -> [PluginCommand IdeState]

plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeLens.hs

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,39 @@ import Language.LSP.Types
2323
import qualified Language.LSP.Types.Lens as J
2424

2525
codeLens :: PluginMethodHandler IdeState TextDocumentCodeLens
26-
codeLens state plId CodeLensParams{..} = do
27-
enabled <- enableTypeLens <$> getCompletionsConfig plId
28-
if not enabled then pure $ pure $ List [] else pluginResponse $ do
29-
nfp <- getNormalizedFilePath plId uri
30-
tmr <- handleMaybeM "Unable to typecheck"
31-
$ liftIO
32-
$ runAction "classplugin.TypeCheck" state
33-
$ use TypeCheck nfp
34-
35-
-- All instance binds
36-
InstanceBindTypeSigsResult allBinds <-
37-
handleMaybeM "Unable to get InstanceBindTypeSigsResult"
38-
$ liftIO
39-
$ runAction "classplugin.GetInstanceBindTypeSigs" state
40-
$ use GetInstanceBindTypeSigs nfp
41-
42-
pragmaInsertion <- insertPragmaIfNotPresent state nfp InstanceSigs
43-
44-
let (hsGroup, _, _, _) = tmrRenamed tmr
45-
tycls = hs_tyclds hsGroup
46-
-- declared instance methods without signatures
47-
bindInfos = [ bind
48-
| instds <- map group_instds tycls -- class instance decls
49-
, instd <- instds
50-
, inst <- maybeToList $ getClsInstD (unLoc instd)
51-
, bind <- getBindSpanWithoutSig inst
52-
]
53-
targetSigs = matchBind bindInfos allBinds
54-
makeLens (range, title) =
55-
generateLens plId range title
56-
$ workspaceEdit pragmaInsertion
57-
$ makeEdit range title
58-
codeLens = makeLens <$> mapMaybe getRangeWithSig targetSigs
59-
60-
pure $ List codeLens
26+
codeLens state plId CodeLensParams{..} = pluginResponse $ do
27+
nfp <- getNormalizedFilePath plId uri
28+
tmr <- handleMaybeM "Unable to typecheck"
29+
$ liftIO
30+
$ runAction "classplugin.TypeCheck" state
31+
$ use TypeCheck nfp
32+
33+
-- All instance binds
34+
InstanceBindTypeSigsResult allBinds <-
35+
handleMaybeM "Unable to get InstanceBindTypeSigsResult"
36+
$ liftIO
37+
$ runAction "classplugin.GetInstanceBindTypeSigs" state
38+
$ use GetInstanceBindTypeSigs nfp
39+
40+
pragmaInsertion <- insertPragmaIfNotPresent state nfp InstanceSigs
41+
42+
let (hsGroup, _, _, _) = tmrRenamed tmr
43+
tycls = hs_tyclds hsGroup
44+
-- declared instance methods without signatures
45+
bindInfos = [ bind
46+
| instds <- map group_instds tycls -- class instance decls
47+
, instd <- instds
48+
, inst <- maybeToList $ getClsInstD (unLoc instd)
49+
, bind <- getBindSpanWithoutSig inst
50+
]
51+
targetSigs = matchBind bindInfos allBinds
52+
makeLens (range, title) =
53+
generateLens plId range title
54+
$ workspaceEdit pragmaInsertion
55+
$ makeEdit range title
56+
codeLens = makeLens <$> mapMaybe getRangeWithSig targetSigs
57+
58+
pure $ List codeLens
6159
where
6260
uri = _textDocument ^. J.uri
6361

plugins/hls-class-plugin/src/Ide/Plugin/Class/ExactPrint.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
module Ide.Plugin.Class.ExactPrint where
77

8-
import Control.Lens (Identity)
98
import Control.Monad.Trans.Maybe
109
import qualified Data.Text as T
1110
import Development.IDE.GHC.Compat

plugins/hls-class-plugin/src/Ide/Plugin/Class/Types.hs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE DeriveGeneric #-}
33
{-# LANGUAGE FlexibleContexts #-}
44
{-# LANGUAGE LambdaCase #-}
5-
{-# LANGUAGE OverloadedLabels #-}
65
{-# LANGUAGE TypeFamilies #-}
76
{-# LANGUAGE ViewPatterns #-}
87

@@ -20,11 +19,7 @@ import Development.IDE.GHC.Compat hiding ((<+>))
2019
import Development.IDE.Graph.Classes
2120
import GHC.Generics
2221
import Ide.Plugin.Class.Utils
23-
import Ide.Plugin.Config
24-
import Ide.Plugin.Properties
25-
import Ide.PluginUtils
2622
import Ide.Types
27-
import Language.LSP.Server
2823

2924
typeLensCommandId :: CommandId
3025
typeLensCommandId = "classplugin.typelens"
@@ -112,19 +107,3 @@ rules recorder = do
112107
(prettyBindingNameString (printOutputable name) <> " :: " <> T.pack (showDoc ty))
113108
Nothing
114109
instanceBindType _ _ = pure Nothing
115-
116-
properties :: Properties
117-
'[ 'PropertyKey "typelensOn" 'TBoolean]
118-
properties = emptyProperties
119-
& defineBooleanProperty #typelensOn
120-
"Enable type lens on instance methods"
121-
True
122-
123-
getCompletionsConfig :: (MonadLsp Config m) => PluginId -> m ClassConfig
124-
getCompletionsConfig plId =
125-
ClassConfig
126-
<$> usePropertyLsp #typelensOn plId properties
127-
128-
newtype ClassConfig = ClassConfig
129-
{ enableTypeLens :: Bool
130-
}

plugins/hls-class-plugin/test/Main.hs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ codeLensTests recorder = testGroup
9292
[ "(==) :: B -> B -> Bool"
9393
, "(==) :: A -> A -> Bool"
9494
]
95-
, testCase "Should no lens if disabled" $ do
96-
runSessionWithServer (classPlugin recorder) testDataDir $ do
97-
sendConfigurationChanged
98-
$ toJSON
99-
$ def { Plugin.plugins = [("class", def { plcConfig = "typelensOn" .= False })] }
100-
doc <- openDoc "CodeLensSimple.hs" "haskell"
101-
lens <- getCodeLenses doc
102-
let titles = map (^. J.title) $ mapMaybe (^. J.command) lens
103-
liftIO $ titles @?= []
10495
, goldenCodeLens recorder "Apply code lens" "CodeLensSimple" 1
10596
, goldenCodeLens recorder "Apply code lens for local class" "LocalClassDefine" 0
10697
, goldenCodeLens recorder "Apply code lens on the same line" "Inline" 0

0 commit comments

Comments
 (0)