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

Conversation

@lukel97
Copy link
Collaborator

@lukel97 lukel97 commented Aug 28, 2018

  • codeActionProviders can no longer defer
  • Add ifCachedModule/ifCachedModuleAndData counterparts to withCachedModule[AndData]
  • Remove getCachedModule/isCached to simplify/normalise how cached modules are accessed
  • Remove isStale in CachedModule since it wasn't used

@lukel97 lukel97 requested review from Gurkenglas, alanz and wz1000 August 28, 2018 16:45
@lukel97
Copy link
Collaborator Author

lukel97 commented Aug 28, 2018

@alanz @infinisil do you still see the hang with this branch? I suspect it could be caused by HaRe's code actions, especially around here:

-- | Generates a map of function definitions and types
-- i.e. top-level bindings and their `where` clauses
genDefMap :: TypecheckedModule -> DefMap
genDefMap tm = mconcat $ map (go . GHC.unLoc) decls
where
-- go :: GHC.HsDecl GHC.GhcPs -> DefMap
-- Type signatures
go (GHC.SigD (GHC.TypeSig lns _)) =
foldl IM.union mempty $ fmap go' lns
where go' (GHC.L (GHC.RealSrcSpan r) n) = IM.singleton (rspToInt r) n
go' _ = mempty
-- Definitions
go (GHC.ValD (GHC.FunBind (GHC.L (GHC.RealSrcSpan r) n) GHC.MG { GHC.mg_alts = llms } _ _ _)) =
IM.insert (rspToInt r) n wheres
where
wheres = mconcat $ fmap (gomatch . GHC.unLoc) (GHC.unLoc llms)
gomatch GHC.Match { GHC.m_grhss = GHC.GRHSs { GHC.grhssLocalBinds = lbs } } =
golbs (GHC.unLoc lbs)
golbs (GHC.HsValBinds (GHC.ValBindsIn lhsbs lsigs)) =
foldl (\acc x -> IM.union acc (go $ GHC.ValD $ GHC.unLoc x)) mempty lhsbs
`mappend` foldl IM.union mempty (fmap (go . GHC.SigD . GHC.unLoc) lsigs)
golbs _ = mempty
go _ = mempty
decls = GHC.hsmodDecls $ GHC.unLoc $ GHC.pm_parsed_source $ GHC.tm_parsed_module tm

Maybe it's getting stuck in a recursive loop?

@lukel97
Copy link
Collaborator Author

lukel97 commented Aug 28, 2018

Should code actions also return instantly? In LanguageClient-neovim the request is triggered by the user rather than automatically when moving the cursor like in vscode, which would make sense for it to be a slow-running deferred request.

@lukel97 lukel97 added the type: refactor Refactor and tidy up internals. label Aug 28, 2018
@alanz
Copy link
Collaborator

alanz commented Aug 28, 2018

Should code actions also return instantly?

In vscode, and emacs-lsp, it is sent as part of the cursor movement, much like a hover request.

So speedy calculation is important.

@alanz
Copy link
Collaborator

alanz commented Aug 30, 2018

This is behaving well for me so far, will likely merge tomorrow.

@alanz alanz merged commit ed080e7 into haskell:master Aug 31, 2018
@alanz alanz added this to the prehistory milestone Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

type: refactor Refactor and tidy up internals.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants