Skip to content

Commit 35ddb2a

Browse files
committed
projectRoot
1 parent 91f44f8 commit 35ddb2a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

ghcide/src/Development/IDE/Main.hs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ import Text.Printf (printf)
9898

9999
data Command
100100
= Check [FilePath] -- ^ Typecheck some paths and print diagnostics. Exit code is the number of failures
101-
| Db FilePath HieDb.Options HieDb.Command -- ^ Run a command in the hiedb
102-
| Index [FilePath] -- ^ Index all the targets and print the path to the database
101+
| Index {projectRoot :: FilePath, targetsToLoad :: [FilePath]}
102+
-- ^ Index all the targets and print the path to the database
103+
| Db {projectRoot :: FilePath, hieOptions :: HieDb.Options, hieCommand :: HieDb.Command}
104+
-- ^ Run a command in the hiedb
103105
| LSP -- ^ Run the LSP server
104106
deriving Show
105107

@@ -113,10 +115,10 @@ isLSP _ = False
113115

114116
commandP :: Parser Command
115117
commandP = hsubparser (command "typecheck" (info (Check <$> fileCmd) fileInfo)
116-
<> command "hiedb" (info (Db "." <$> HieDb.optParser "" True <*> HieDb.cmdParser <**> helper) hieInfo)
117-
<> command "index" (info (Index <$> fileCmd) indexInfo)
118-
<> command "lsp" (info (pure LSP <**> helper) lspInfo)
119-
)
118+
<> command "hiedb" (info (Db "." <$> HieDb.optParser "" True <*> HieDb.cmdParser <**> helper) hieInfo)
119+
<> command "index" (info (Index "." <$> fileCmd) indexInfo)
120+
<> command "lsp" (info (pure LSP <**> helper) lspInfo)
121+
)
120122
where
121123
fileCmd = many (argument str (metavar "FILES/DIRS..."))
122124
lspInfo = fullDesc <> progDesc "Start talking to an LSP client"
@@ -294,9 +296,9 @@ defaultMain Arguments{..} = do
294296
measureMemory logger [keys] consoleObserver valuesRef
295297

296298
unless (null failed) (exitWith $ ExitFailure (length failed))
297-
Index argFiles -> do
298-
dbLoc <- getHieDbLoc "."
299-
files <- expandFiles (argFiles ++ ["." | null argFiles])
299+
Index{..} -> do
300+
dbLoc <- getHieDbLoc projectRoot
301+
files <- expandFiles (targetsToLoad ++ [projectRoot | null targetsToLoad])
300302
runWithDb dbLoc $ \hiedb hieChan -> do
301303
vfs <- makeVFSHandle
302304
sessionLoader <- loadSessionWithOptions argsSessionLoadingOptions "."

0 commit comments

Comments
 (0)