-
-
Notifications
You must be signed in to change notification settings - Fork 401
Description
,exportsMap :: Var ExportsMap |
is a mutable table of names exported by modules in the local project that is used to drive import quick fixes.
The current implementation populates the table by
-
Typechecking all the project modules at startup:
haskell-language-server/ghcide/session-loader/Development/IDE/Session.hs
Lines 400 to 410 in 861c8bf
-- Typecheck all files in the project on startup checkProject <- getCheckProject unless (null cs || not checkProject) $ do cfps' <- liftIO $ filterM (IO.doesFileExist . fromNormalizedFilePath) (concatMap targetLocations cs) void $ shakeEnqueue extras $ mkDelayedAction "InitialLoad" Debug $ void $ do mmt <- uses GetModificationTime cfps' let cs_exist = catMaybes (zipWith (<$) cfps' mmt) modIfaces <- uses GetModIface cs_exist -- update exports map extras <- getShakeExtras let !exportsMap' = createExportsMap $ mapMaybe (fmap hirModIface) modIfaces -
Refreshing on every kick:
haskell-language-server/ghcide/src/Development/IDE/Core/OfInterest.hs
Lines 111 to 120 in 2ee2943
ifaces <- if checkProject then return Nothing else runMaybeT $ do | |
deps <- MaybeT $ sequence <$> uses GetDependencies files | |
hiResults <- lift $ uses GetModIface (nubOrd $ foldMap transitiveModuleDeps deps) | |
return $ map hirModIface $ catMaybes hiResults | |
ShakeExtras{exportsMap} <- getShakeExtras | |
let mguts = catMaybes results | |
!exportsMap' = createExportsMapMg mguts | |
!exportsMap'' = maybe mempty createExportsMap ifaces | |
void $ liftIO $ modifyVar' exportsMap $ (exportsMap'' <>) . (exportsMap' <>) |
1 could be replaced by a hiedb query, assuming that the hiedb is fully uptodate. This may not be always the case for a new project, but it will work fine on a project that has previously been loaded and type checked.
2 does a lot of work when checkProject
is disabled, by scanning all the transitive dependencies. If we switch 1 to use hiedb we can also make it unconditional and then eliminate the transitive scan from 2.