@@ -95,7 +95,7 @@ import Text.Printf (printf)
95
95
data Command
96
96
= Lsp -- ^ Run the LSP server
97
97
| Check [FilePath ] -- ^ Typecheck some paths and print diagnostics. Exit code is the number of failures
98
- | Index FilePath -- ^ Index the whole project and print the path to the database
98
+ | Index [ FilePath ] -- ^ Index all the targets and print the path to the database
99
99
| Db FilePath HieDb. Options HieDb. Command -- ^ Run a command in the hiedb
100
100
101
101
data Arguments = Arguments
@@ -267,31 +267,38 @@ defaultMain Arguments{..} = do
267
267
measureMemory logger [keys] consoleObserver valuesRef
268
268
269
269
unless (null failed) (exitWith $ ExitFailure (length failed))
270
- Index dir -> do
271
- dbLoc <- getHieDbLoc dir
270
+ Index argFiles -> do
271
+ dbLoc <- getHieDbLoc " ."
272
+ files <- expandFiles (argFiles ++ [" ." | null argFiles])
272
273
runWithDb dbLoc $ \ hiedb hieChan -> do
273
274
vfs <- makeVFSHandle
274
- sessionLoader <- loadSessionWithOptions argsSessionLoadingOptions dir
275
+ sessionLoader <- loadSessionWithOptions argsSessionLoadingOptions " . "
275
276
let options = (argsIdeOptions argsDefaultHlsConfig sessionLoader)
276
277
{ optCheckParents = pure NeverCheck
277
278
, optCheckProject = pure False
278
279
}
279
280
ide <- initialise argsDefaultHlsConfig rules Nothing logger debouncer options vfs hiedb hieChan
280
281
registerIdeConfiguration (shakeExtras ide) $ IdeConfiguration mempty (hashed Nothing )
282
+ let fois = map toNormalizedFilePath' files
283
+ setFilesOfInterest ide $ HashMap. fromList $ map (,OnDisk ) fois
281
284
results <- runAction " Index" ide $ do
285
+ _ <- uses GetModIfaceFromDiskAndIndex fois
282
286
allKnownTargets <- toKnownFiles <$> useNoFile_ GetKnownTargets
283
- liftIO $ hPutStrLn stderr $ " Found " <> show (length allKnownTargets) <> " targets"
287
+ liftIO $ hPutStrLn stderr $ " Indexing " <> show (length allKnownTargets) <> " targets"
284
288
uses GetModIfaceFromDiskAndIndex $ toList allKnownTargets
285
- putStrLn dbLoc
286
- let nfailures = length $ filter isNothing results
287
- let pending = indexPending $ hiedbWriter $ shakeExtras ide
288
289
289
- hPutStrLn stderr " Waiting for indexing..."
290
+ hPutStrLn stderr " Writing index... "
291
+
292
+ let ! nfailures = length $ filter isNothing results
293
+ let ! pending = indexPending $ hiedbWriter $ shakeExtras ide
294
+
290
295
atomically $ do
291
296
n <- readTVar pending
292
297
unless (HashMap. size n == 0 ) retry
293
298
299
+ putStrLn dbLoc
294
300
unless (nfailures == 0 ) $ exitWith $ ExitFailure nfailures
301
+
295
302
Db dir opts cmd -> do
296
303
dbLoc <- getHieDbLoc dir
297
304
hPutStrLn stderr $ " Using hiedb at: " ++ dbLoc
0 commit comments