Skip to content

Commit edd67c0

Browse files
committed
Document indexHieFile
1 parent 0651bab commit edd67c0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

+26
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,32 @@ spliceExpresions Splices{..} =
473473
, DL.fromList $ map fst awSplices
474474
]
475475

476+
-- | In addition to indexing the `.hie` file, this function is reponsible for
477+
-- maintaining the IndexQueue state and notfiying the user about indexing
478+
-- progress.
479+
--
480+
-- We maintain a record of all pending index operations in theh 'indexPending'
481+
-- TVar When 'indexHieFile' is called, it must check to ensure that the file
482+
-- hasn't already be queued up for indexing. If it has, then we can just skip it
483+
--
484+
-- Otherwise, we record the current file as pending and write an indexing
485+
-- operation to the queue
486+
--
487+
-- When the indexing operation is picked up and executed by the worker thread,
488+
-- the first thing it does is ensure that a newer index for the same file
489+
-- hasn't been scheduled by looking at 'indexPending' If a newer index has been
490+
-- scheduled, we can safely skip this one
491+
--
492+
-- Otherwise, we start or continue a progress reporting session, telling it
493+
-- about progress so far and the current file we are attempting to index. Then
494+
-- we can go ahead and call in to hiedb to actually do the indexing operation
495+
--
496+
-- Once this completes, we have to update the IndexQueue state First, we
497+
-- must remove the just indexed file from 'indexPending' Then we check if
498+
-- 'indexPending' is now empty. In that case, we end the progress session and
499+
-- report the total number of file indexed. We also set the 'indexCompleted'
500+
-- TVar to 0 in order to set it up for a fresh indexing session. Otherwise, we
501+
-- can just increment the 'indexCompleted' TVar and exit.
476502
indexHieFile :: ShakeExtras -> ModSummary -> NormalizedFilePath -> Fingerprint -> Compat.HieFile -> IO ()
477503
indexHieFile se mod_summary srcPath hash hf = atomically $ do
478504
pending <- readTVar indexPending

0 commit comments

Comments
 (0)