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

Commit 67409e7

Browse files
committed
doc and tests
1 parent 1174915 commit 67409e7

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

hie-ghc-mod/Haskell/Ide/GhcModPlugin.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ checkCmd = CmdSync $ \_ctxs req -> do
8585

8686
-- ---------------------------------------------------------------------
8787

88+
-- | Runs the find command from the given directory, for the given symbol
8889
findCmd :: CommandFunc ModuleList
8990
findCmd = CmdSync $ \_ctxs req -> do
9091
case getParams (IdFile "dir" :& IdText "symbol" :& RNil) req of
9192
Left err -> return err
9293
Right (ParamFile dirName :& ParamText symbol :& RNil) -> do
9394
runGhcModCommand (T.pack (T.unpack dirName </> "dummy")) (\_->
9495
do
96+
-- adapted from ghc-mod find command, which launches the executable again
9597
tmpdir <- GM.cradleTempDir <$> GM.cradle
9698
sf <- takeWhile (`notElem` ['\r','\n']) <$> GM.dumpSymbol tmpdir
9799
db <- M.fromAscList . map conv . lines <$> liftIO (readFile sf)

hie-plugin-api/Haskell/Ide/Engine/PluginDescriptor.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,12 @@ contextMapping CtxFile = [fileParam]
234234
contextMapping CtxPoint = [fileParam,startPosParam]
235235
contextMapping CtxRegion = [fileParam,startPosParam,endPosParam]
236236
contextMapping CtxCabalTarget = [cabalParam]
237-
contextMapping CtxProject = [dirParam]
237+
contextMapping CtxProject = [dirParam] -- the root directory of the project
238238

239239
fileParam :: ParamDescription
240240
fileParam = RP "file" "a file name" PtFile
241241

242+
-- | A parameter for a directory
242243
dirParam :: ParamDescription
243244
dirParam = RP "dir" "a directory name" PtFile
244245

test/DispatcherSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ dispatcherSpec = do
105105
it "identifies CtxProject" $ do
106106
chan <- atomically newTChan
107107
chSync <- atomically newTChan
108-
let req = IdeRequest "cmd6" (Map.fromList [])
108+
let req = IdeRequest "cmd6" (Map.fromList [("dir", ParamFileP ".")])
109109
cr = CReq "test" 1 req chan
110110
r <- withStdoutLogging $ runIdeM (IdeState Map.empty) (doDispatch (testPlugins chSync) cr)
111111
r `shouldBe` Just (IdeResponseOk (H.fromList ["ok" .= ("result:ctxs=[CtxProject]"::String)]))

test/GhcModPluginSpec.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ ghcmodSpec = do
6969
-- ---------------------------------
7070

7171
it "runs the find command" $ do
72-
let req = IdeRequest "find" (Map.fromList [("symbol", ParamTextP "map")])
72+
let req = IdeRequest "find" (Map.fromList [("dir", ParamFileP "."),("symbol", ParamTextP "Show")])
7373
r <- dispatchRequest req
74-
r `shouldBe` Just (IdeResponseOk (H.fromList ["ok" .= ("Placholder:Need to debug this in ghc-mod, returns 'does not exist (No such file or directory)'"::String)]))
75-
pendingWith "need to debug in ghc-mod"
74+
r `shouldBe` Just (IdeResponseOk (H.fromList ["modules" .= ["GHC.Show"::String,"Prelude","Test.Hspec.Discover","Text.Show"]]))
75+
7676

7777
-- ---------------------------------
7878

0 commit comments

Comments
 (0)