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

Commit 2abdfab

Browse files
committed
Getting rid of lint and info GhcMod plugin commands
1 parent 151a845 commit 2abdfab

File tree

5 files changed

+28
-38
lines changed

5 files changed

+28
-38
lines changed

src/Haskell/Ide/Engine/Plugin/GhcMod.hs

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ module Haskell.Ide.Engine.Plugin.GhcMod
2121
, extractMissingSignature
2222
, extractRenamableTerms
2323
, extractUnusedTerm
24-
, infoCmd'
25-
-- , lintCmd'
2624
, newTypeCmd
2725
, symbolProvider
2826
) where
@@ -37,10 +35,7 @@ import Data.Monoid ((<>))
3735
import qualified Data.Text as T
3836
import Name
3937
import GHC.Generics
40-
-- import qualified GhcMod as GM ( lint, info )
41-
import qualified GhcMod as GM ( info )
42-
-- import qualified GhcModCore as GM ( defaultLintOpts, Expression(..), pretty, defaultLintOpts, Expression(..), GhcPs )
43-
import qualified GhcModCore as GM ( Expression(..), pretty, Expression(..), GhcPs )
38+
import qualified GhcModCore as GM ( pretty, GhcPs )
4439
import Haskell.Ide.Engine.Ghc
4540
import Haskell.Ide.Engine.MonadTypes hiding (defaultOptions)
4641
import Haskell.Ide.Engine.PluginUtils
@@ -66,10 +61,14 @@ ghcmodDescriptor plId = PluginDescriptor
6661
<> "in editors. It strives to offer most of the features one has come to expect "
6762
<> "from modern IDEs in any editor."
6863
, pluginCommands =
69-
[ PluginCommand "check" "check a file for GHC warnings and errors" checkCmd
70-
-- , PluginCommand "lint" "Check files using `hlint'" lintCmd
71-
, PluginCommand "info" "Look up an identifier in the context of FILE (like ghci's `:info')" infoCmd
64+
[
65+
-- This one is used in the dispatcher tests, and is a wrapper around what we are already using anyway
66+
PluginCommand "check" "check a file for GHC warnings and errors" checkCmd
67+
68+
-- PluginCommand "info" "Look up an identifier in the context of FILE (like ghci's `:info')" infoCmd
7269
, PluginCommand "type" "Get the type of the expression under (LINE,COL)" typeCmd
70+
71+
-- This one is registered in the vscode plugin, for some reason
7372
, PluginCommand "casesplit" "Generate a pattern match for a binding under (LINE,COL)" Hie.splitCaseCmd
7473
]
7574
, pluginCodeActionProvider = Just codeActionProvider
@@ -86,17 +85,6 @@ checkCmd = CmdSync setTypecheckedModule
8685

8786
-- ---------------------------------------------------------------------
8887

89-
-- lintCmd :: CommandFunc Uri T.Text
90-
-- lintCmd = CmdSync lintCmd'
91-
92-
-- -- TODO:AZ why are we not calling hlint directly?
93-
-- lintCmd' :: Uri -> IdeGhcM (IdeResult T.Text)
94-
-- lintCmd' uri =
95-
-- pluginGetFile "lint: " uri $ \file ->
96-
-- fmap T.pack <$> Hie.runGhcModCommand (GM.lint GM.defaultLintOpts file)
97-
98-
-- ---------------------------------------------------------------------
99-
10088
customOptions :: Options
10189
customOptions = defaultOptions { fieldLabelModifier = camelTo2 '_' . drop 2}
10290

@@ -110,14 +98,14 @@ instance FromJSON InfoParams where
11098
instance ToJSON InfoParams where
11199
toJSON = genericToJSON customOptions
112100

113-
infoCmd :: CommandFunc InfoParams T.Text
114-
infoCmd = CmdSync $ \(IP uri expr) ->
115-
infoCmd' uri expr
101+
-- infoCmd :: CommandFunc InfoParams T.Text
102+
-- infoCmd = CmdSync $ \(IP uri expr) ->
103+
-- infoCmd' uri expr
116104

117-
infoCmd' :: Uri -> T.Text -> IdeGhcM (IdeResult T.Text)
118-
infoCmd' uri expr =
119-
pluginGetFile "info: " uri $ \file ->
120-
fmap T.pack <$> Hie.runGhcModCommand (GM.info file (GM.Expression (T.unpack expr)))
105+
-- infoCmd' :: Uri -> T.Text -> IdeGhcM (IdeResult T.Text)
106+
-- infoCmd' uri expr =
107+
-- pluginGetFile "info: " uri $ \file ->
108+
-- fmap T.pack <$> Hie.runGhcModCommand (GM.info file (GM.Expression (T.unpack expr)))
121109

122110
-- ---------------------------------------------------------------------
123111
data TypeParams =
@@ -135,6 +123,7 @@ typeCmd :: CommandFunc TypeParams [(Range,T.Text)]
135123
typeCmd = CmdSync $ \(TP _bool uri pos) ->
136124
liftToGhc $ newTypeCmd pos uri
137125

126+
-- AZ: currently only used in tests, but
138127
newTypeCmd :: Position -> Uri -> IdeM (IdeResult [(Range, T.Text)])
139128
newTypeCmd newPos uri =
140129
pluginGetFile "newTypeCmd: " uri $ \fp ->

submodules/cabal-helper

test/dispatcher/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ funcSpec = describe "functional dispatch" $ do
166166
-- And now we get the deferred response (once the module is loaded)
167167
("req1",Right res) <- atomically $ readTChan logChan
168168
let Just ds = fromDynJSON res :: Maybe [DocumentSymbol]
169-
DocumentSymbol mainName _ mainKind _ mainRange _ _ = head ds
169+
DocumentSymbol mainName _ mainKind _ mainRange _ _ = head ds
170170
mainName `shouldBe` "main"
171171
mainKind `shouldBe` SkFunction
172172
mainRange `shouldBe` Range (Position 2 0) (Position 2 23)

test/unit/GhcModPluginSpec.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ ghcmodSpec =
7373

7474
-- ---------------------------------
7575

76-
it "runs the info command" $ withCurrentDirectory "./test/testdata" $ do
77-
fp <- makeAbsolute "HaReRename.hs"
78-
let uri = filePathToUri fp
79-
act = infoCmd' uri "main"
80-
arg = IP uri "main"
81-
res = IdeResultOk "main :: IO () \t-- Defined at HaReRename.hs:2:1\n"
82-
-- ghc-mod tries to load the test file in the context of the hie project if we do not cd first.
83-
testCommand testPlugins act "ghcmod" "info" arg res
76+
-- it "runs the info command" $ withCurrentDirectory "./test/testdata" $ do
77+
-- fp <- makeAbsolute "HaReRename.hs"
78+
-- let uri = filePathToUri fp
79+
-- act = infoCmd' uri "main"
80+
-- arg = IP uri "main"
81+
-- res = IdeResultOk "main :: IO () \t-- Defined at HaReRename.hs:2:1\n"
82+
-- -- ghc-mod tries to load the test file in the context of the hie project if we do not cd first.
83+
-- testCommand testPlugins act "ghcmod" "info" arg res
8484

8585
-- ----------------------------------------------------------------------------
8686

@@ -97,6 +97,7 @@ ghcmodSpec =
9797
]
9898

9999
testCommand testPlugins act "ghcmod" "type" arg res
100+
100101
it "runs the type command, find function type" $ withCurrentDirectory "./test/testdata" $ do
101102
fp <- makeAbsolute "HaReRename.hs"
102103
let uri = filePathToUri fp

0 commit comments

Comments
 (0)