Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ library
filepath,
fingertree,
Glob,
haddock-library >= 1.8,
haddock-library >= 1.7,
hashable,
haskell-lsp-types == 0.22.*,
haskell-lsp == 0.22.*,
Expand Down Expand Up @@ -91,7 +91,8 @@ library
cryptohash-sha1 >=0.11.100 && <0.12,
hie-bios >= 0.7.1 && < 0.8.0,
implicit-hie-cradle >= 0.2.0.1 && < 0.3,
base16-bytestring >=0.1.1 && <0.2
base16-bytestring >=0.1.1 && <0.2,
haddock-api >= 2.22.0
if os(windows)
build-depends:
Win32
Expand Down Expand Up @@ -316,6 +317,7 @@ test-suite ghcide-tests
ghcide,
ghc-typelits-knownnat,
haddock-library,
haddock-api,
haskell-lsp,
haskell-lsp-types,
network-uri,
Expand Down
4 changes: 2 additions & 2 deletions src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ getDocMapRule =
let tdeps = transitiveModuleDeps deps
parsedDeps <- uses_ GetParsedModule tdeps
#endif

dkMap <- liftIO $ mkDocMap hsc parsedDeps rf tc
ShakeExtras{haddockLinkEnvs} <- getShakeExtras
dkMap <- liftIO $ mkDocMap hsc parsedDeps rf tc haddockLinkEnvs
return ([],Just dkMap)

-- Typechecks a module.
Expand Down
14 changes: 13 additions & 1 deletion src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ module Development.IDE.Core.Shake(
DelayedAction, mkDelayedAction,
IdeAction(..), runIdeAction,
mkUpdater,
LinkEnvsCache,
-- Exposed for testing.
Q(..),
Q(..),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trimming whitespace needed

Copy link
Member

@jneira jneira Oct 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the project has a .editorconfig that enforces that, do you have installed the needed plugin in your editor to honour it?
It saves a lot of time fixing those little things automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the hint

) where

import Development.Shake hiding (ShakeValue, doesFileExist, Info)
Expand Down Expand Up @@ -126,6 +127,8 @@ import UniqSupply
import PrelInfo
import Data.Int (Int64)
import qualified Data.HashSet as HSet
import Name (Name)
import Module (Module)

-- information we stash inside the shakeExtra field
data ShakeExtras = ShakeExtras
Expand Down Expand Up @@ -164,8 +167,16 @@ data ShakeExtras = ShakeExtras
,exportsMap :: Var ExportsMap
-- | A work queue for actions added via 'runInShakeSession'
,actionQueue :: ActionQueue
-- | A mapping of haddock interface files' link environments
,haddockLinkEnvs :: LinkEnvsCache
}

-- | Global cache of parsed haddock link envs (link env is a mapping of name to haddock module/file)
type LinkEnvsCache = Var (HashMap FilePath (Maybe LinkEnv))

-- copied and pasted LinkEnv definition from haddock-api to eliminate dependency on it in GHC lib
type LinkEnv = Map Name Module

-- | A mapping of module name to known files
type KnownTargets = HashMap Target [NormalizedFilePath]

Expand Down Expand Up @@ -433,6 +444,7 @@ shakeOpen getLspId eventer withProgress withIndefiniteProgress logger debouncer
exportsMap <- newVar mempty

actionQueue <- newQueue
haddockLinkEnvs <- newVar HMap.empty

pure (ShakeExtras{..}, cancel progressAsync)
(shakeDbM, shakeClose) <-
Expand Down
3 changes: 2 additions & 1 deletion src/Development/IDE/Plugin/Completions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ produceCompletions = do
res <- liftIO $ tcRnImportDecls env imps
case res of
(_, Just rdrEnv) -> do
cdata <- liftIO $ cacheDataProducer env (ms_mod ms) rdrEnv imps parsedDeps
ShakeExtras{haddockLinkEnvs} <- getShakeExtras
cdata <- liftIO $ cacheDataProducer env (ms_mod ms) rdrEnv imps parsedDeps haddockLinkEnvs
return ([], Just cdata)
(_diag, _) ->
return ([], Nothing)
Expand Down
12 changes: 9 additions & 3 deletions src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,14 @@ mkPragmaCompl label insertText =
Nothing Nothing Nothing Nothing Nothing (Just insertText) (Just Snippet)
Nothing Nothing Nothing Nothing Nothing

cacheDataProducer :: HscEnv -> Module -> GlobalRdrEnv -> [LImportDecl GhcPs] -> [ParsedModule] -> IO CachedCompletions
cacheDataProducer packageState curMod rdrEnv limports deps = do
cacheDataProducer :: HscEnv
-> Module
-> GlobalRdrEnv
-> [LImportDecl GhcPs]
-> [ParsedModule]
-> LinkEnvsCache
-> IO CachedCompletions
cacheDataProducer packageState curMod rdrEnv limports deps le = do
let dflags = hsc_dflags packageState
curModName = moduleName curMod

Expand Down Expand Up @@ -276,7 +282,7 @@ cacheDataProducer packageState curMod rdrEnv limports deps = do

toCompItem :: Module -> ModuleName -> Name -> IO CompItem
toCompItem m mn n = do
docs <- getDocumentationTryGhc packageState curMod deps n
docs <- getDocumentationTryGhc packageState curMod deps n le
ty <- catchSrcErrors (hsc_dflags packageState) "completion" $ do
name' <- lookupName packageState m n
return $ name' >>= safeTyThingType
Expand Down
Loading