on master help sign in
Add --ide flag (#1668)

* Add --ide flag to the Demo * Fix things in the .cabal file * Add tracing messages to Demo.hs

commit952959293ff6f9149faea036bef884219387635f authorNeil Mitchell <35463327+neil-da@users.noreply.github.com> dateFri 14 Jun 2019, 14:26 (7 years ago) parent28946c2
2 files changed+17−6
haskell-ide-core.cabal+8 test/Demo.hs+9−6
haskell-ide-core.cabal+8
@@ -22,10 +22,12 @@ library
2222 default-language: Haskell2010
2323 build-depends:
2424 aeson,
25+ async,
2526 base == 4.*,
2627 binary,
2728 bytestring,
2829 containers,
30+ data-default,
2931 deepseq,
3032 directory,
3133 either,
@@ -38,6 +40,7 @@ library
3840 haskell-lsp,
3941 haskell-lsp-types,
4042 mtl,
43+ network-uri,
4144 pretty,
4245 rope-utf16-splay,
4346 safe-exceptions,
@@ -87,6 +90,11 @@ library
8790 Development.IDE.State.FileStore
8891 Development.IDE.State.Rules
8992 Development.IDE.Compat
93+ Development.IDE.LSP.LanguageServer
94+ Development.IDE.LSP.Definition
95+ Development.IDE.LSP.Hover
96+ Development.IDE.LSP.Protocol
97+ Development.IDE.LSP.Server
9098 Development.IDE.Types.Options
9199 Development.IDE.State.RuleTypes
92100 Development.IDE.State.Service
test/Demo.hs+9−6
@@ -36,7 +36,7 @@ import GHC.Paths
3636
3737main :: IO ()
3838main = do
39− (ghcOptions, map toNormalizedFilePath -> files) <- getCmdLine
39+ (ghcOptions, map toNormalizedFilePath -> files, isIde) <- getCmdLine
4040
4141 -- lock to avoid overlapping output on stdout
4242 lock <- newLock
@@ -52,8 +52,10 @@ main = do
5252 ,optShakeProfiling = Nothing -- Just "output.html"
5353 }
5454
55− if null files then
56− runLanguageServer logger $ \event vfs ->
55+ if isIde then do
56+ putStrLn "Starting IDE server"
57+ runLanguageServer logger $ \event vfs -> do
58+ putStrLn "Server started"
5759 initialise mainRule event logger options vfs
5860 else do
5961 vfs <- makeVFSHandle
@@ -92,16 +94,17 @@ newSession flags = runGhc (Just libdir) $ do
9294
9395
9496-- | Convert the command line into GHC options and files to load.
95−getCmdLine :: IO ([String], [FilePath])
97+getCmdLine :: IO ([String], [FilePath], Bool)
9698getCmdLine = do
9799 args <- getArgs
98− args <- return $ if null args then [".ghci"] else args
100+ let isIde = "--ide" `elem` args
101+ args <- return $ delete "--ide" $ if null args then [".ghci"] else args
99102 let (flags, files) = partition ("-" `isPrefixOf`) args
100103 let (ghci, hs) = partition ((==) ".ghci" . takeExtension) files
101104 (flags, files) <- both concat . unzip . ((flags,hs):) <$> mapM readGhci ghci
102105 when (null files) $
103106 fail "Expected some files to load, but didn't find any"
104− return (flags, files)
107+ return (flags, files, isIde)
105108
106109readGhci :: FilePath -> IO ([String], [FilePath])
107110readGhci file = do