Change the IDE demo to use runLanguageServer (#1655)

This commit is contained in:
Neil Mitchell 2019-06-13 18:21:27 +02:00 committed by GitHub
parent 795f7b20bb
commit 9a3fa3fe8b

View File

@ -39,13 +39,9 @@ main = do
-- lock to avoid overlapping output on stdout -- lock to avoid overlapping output on stdout
lock <- newLock lock <- newLock
let logger = makeOneHandle $ withLock lock . T.putStrLn
vfs <- makeVFSHandle let options = IdeOptions
ide <- initialise
mainRule
(showEvent lock)
(makeOneHandle $ withLock lock . T.putStrLn)
IdeOptions
{optPreprocessor = (,) [] {optPreprocessor = (,) []
,optWriteIface = False ,optWriteIface = False
,optGhcSession = liftIO $ newSession ghcOptions ,optGhcSession = liftIO $ newSession ghcOptions
@ -54,7 +50,13 @@ main = do
,optThreads = 0 ,optThreads = 0
,optShakeProfiling = Nothing -- Just "output.html" ,optShakeProfiling = Nothing -- Just "output.html"
} }
vfs
if null files then
runLanguageServer logger $ \event vfs ->
initialise mainRule event logger options vfs
else do
vfs <- makeVFSHandle
ide <- initialise mainRule (showEvent lock) logger options vfs
setFilesOfInterest ide $ Set.fromList files setFilesOfInterest ide $ Set.fromList files
_ <- runAction ide $ uses_ TypeCheck files _ <- runAction ide $ uses_ TypeCheck files
-- shake now writes an async message that it is completed with timing info, -- shake now writes an async message that it is completed with timing info,
@ -63,6 +65,10 @@ main = do
putStrLn "Done" putStrLn "Done"
runLanguageServer :: a
runLanguageServer = undefined
-- | Print an LSP event. -- | Print an LSP event.
showEvent :: Lock -> FromServerMessage -> IO () showEvent :: Lock -> FromServerMessage -> IO ()
showEvent _ (EventFileDiagnostics _ []) = return () showEvent _ (EventFileDiagnostics _ []) = return ()