Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make hie-core outside an IDE work better #1895

Merged
merged 9 commits into from
Jun 26, 2019
Prev Previous commit
Next Next commit
Make the interactive mode say what it is doing a bit more
  • Loading branch information
ndmitchell committed Jun 26, 2019
commit 8057058bd18e927f7c400568693f072553b7b0a7
16 changes: 11 additions & 5 deletions compiler/hie-core/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,34 @@ main = do
-- then the language server will not work
hPutStrLn stderr "Starting hie-core"
Arguments{..} <- getArguments

-- lock to avoid overlapping output on stdout
lock <- newLock
let logger = makeOneLogger $ withLock lock . T.putStrLn

dir <- getCurrentDirectory
hPutStrLn stderr dir

cradle <- findCradle (dir <> "/")

let options = defaultIdeOptions $ liftIO $ newSession' cradle

if argLSP then do
t <- offsetTime
hPutStrLn stderr "Starting LSP server..."
runLanguageServer def def $ \event vfs -> do
t <- t
hPutStrLn stderr $ "Started LSP server in " ++ showDuration t
let options = defaultIdeOptions $ liftIO $ newSession' =<< findCradle (dir <> "/")
initialise (mainRule >> action kick) event logger options vfs
else do
putStrLn "[1/5] Finding hie-bios cradle"
cradle <- findCradle (dir <> "/")
print cradle

putStrLn "[2/5] Converting Cradle to GHC session"
env <- newSession' cradle

putStrLn "[3/3] Running sessions"
let files = map toNormalizedFilePath argFiles
vfs <- makeVFSHandle
ide <- initialise mainRule (showEvent lock) logger options vfs
ide <- initialise mainRule (showEvent lock) logger (defaultIdeOptions $ return env) vfs
setFilesOfInterest ide $ Set.fromList files
runAction ide kick
-- shake now writes an async message that it is completed with timing info,
Expand Down