@@ -35,7 +35,7 @@ import Development.IDE.LSP.LanguageServer
35
35
import Development.IDE.LSP.Protocol
36
36
import Development.IDE.Plugin
37
37
import Development.IDE.Plugin.HLS
38
- import Development.IDE.Session (loadSession , findCradle , defaultLoadingOptions , cacheDir )
38
+ import Development.IDE.Session (loadSession , findCradle , defaultLoadingOptions , setInitialDynFlags , getHieDbLoc , runWithDb )
39
39
import Development.IDE.Types.Diagnostics
40
40
import Development.IDE.Types.Location
41
41
import Development.IDE.Types.Logger as G
@@ -57,24 +57,6 @@ import qualified System.Log.Logger as L
57
57
import System.Time.Extra
58
58
import Development.Shake (action )
59
59
60
- import HieDb.Create
61
- import HieDb.Types
62
- import Database.SQLite.Simple
63
- import qualified Data.ByteString.Char8 as B
64
- import qualified Crypto.Hash.SHA1 as H
65
- import Control.Concurrent.Async
66
- import Control.Exception
67
- import System.Directory
68
- import Data.ByteString.Base16
69
-
70
- -- ---------------------------------------------------------------------
71
- -- ghcide partialhandlers
72
- import Development.IDE.Plugin.CodeAction as CodeAction
73
- import Development.IDE.Plugin.Completions as Completions
74
- import Development.IDE.LSP.HoverDefinition as HoverDefinition
75
-
76
- -- ---------------------------------------------------------------------
77
-
78
60
ghcIdePlugins :: T. Text -> IdePlugins IdeState -> (Plugin Config , [T. Text ])
79
61
ghcIdePlugins pid ps = (asGhcIdePlugin ps, allLspCmdIds' pid ps)
80
62
@@ -116,36 +98,12 @@ hlsLogger = G.Logger $ \pri txt ->
116
98
-- ---------------------------------------------------------------------
117
99
118
100
runLspMode :: LspArguments -> IdePlugins IdeState -> IO ()
119
- runLspMode lspArgs@ LspArguments {.. } idePlugins = do
120
-
121
- getHieDbLoc :: FilePath -> IO FilePath
122
- getHieDbLoc dir = do
123
- let db = dirHash++ " -" ++ takeBaseName dir++ " -" ++ VERSION_ghc <.> " hiedb"
124
- dirHash = B. unpack $ encode $ H. hash $ B. pack dir
125
- cDir <- IO. getXdgDirectory IO. XdgCache cacheDir
126
- createDirectoryIfMissing True cDir
127
- pure (cDir </> db)
128
-
129
- runLspMode :: LspArguments -> IdePlugins -> IO ()
130
101
runLspMode lspArgs idePlugins = do
131
102
dir <- IO. getCurrentDirectory
132
103
dbLoc <- getHieDbLoc dir
133
104
runWithDb dbLoc $ runLspMode' lspArgs idePlugins
134
105
135
- runWithDb :: FilePath -> (HieDb -> HieWriterChan -> IO () ) -> IO ()
136
- runWithDb fp k =
137
- withHieDb fp $ \ writedb -> do
138
- execute_ (getConn writedb) " PRAGMA journal_mode=WAL;"
139
- initConn writedb
140
- chan <- newChan
141
- race_ (writerThread writedb chan) (withHieDb fp (flip k chan))
142
- where
143
- writerThread db chan = forever $ do
144
- k <- readChan chan
145
- k db `catch` \ e@ SQLError {} -> do
146
- hPutStrLn stderr $ " Error in worker, ignoring: " ++ show e
147
-
148
- runLspMode' :: LspArguments -> IdePlugins -> HieDb -> HieWriterChan -> IO ()
106
+ runLspMode' :: LspArguments -> IdePlugins IdeState -> HieDb -> IndexQueue -> IO ()
149
107
runLspMode' lspArgs@ LspArguments {.. } idePlugins hiedb hiechan = do
150
108
LSP. setupLogger argsLogFile [" hls" , " hie-bios" ]
151
109
$ if argsDebugOn then L. DEBUG else L. INFO
@@ -159,6 +117,8 @@ runLspMode' lspArgs@LspArguments{..} idePlugins hiedb hiechan = do
159
117
160
118
dir <- IO. getCurrentDirectory
161
119
120
+ libdir <- setInitialDynFlags
121
+
162
122
pid <- T. pack . show <$> getProcessID
163
123
let
164
124
(plugins, commandIds) = ghcIdePlugins pid idePlugins
0 commit comments