Skip to content

Commit a86a6aa

Browse files
committed
Update HLS
1 parent edd67c0 commit a86a6aa

File tree

2 files changed

+6
-47
lines changed

2 files changed

+6
-47
lines changed

plugins/tactics/src/Ide/Plugin/Tactic.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ judgementForHole state nfp range = do
252252
let dflags = ms_hspp_opts modsum
253253

254254
case asts of
255-
(HAR _ hf _ kind) -> do
255+
(HAR _ hf _ _ kind) -> do
256256
(rss, goal) <- liftMaybe $ join $ listToMaybe $ M.elems $ flip M.mapWithKey (getAsts hf) $ \fs ast ->
257257
case selectSmallestContaining (rangeToRealSrcSpan (FastString.unpackFS fs) range') ast of
258258
Nothing -> Nothing
@@ -276,8 +276,7 @@ judgementForHole state nfp range = do
276276
cls_hy = contextMethodHypothesis ctx
277277
case kind of
278278
HieFromDisk hf' ->
279-
-- TODO FIXME XXX.
280-
fail undefined
279+
fail "Need a fresh hie file"
281280
HieFresh ->
282281
pure ( resulting_range
283282
, mkFirstJudgement

src/Ide/Main.hs

+4-44
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Development.IDE.LSP.LanguageServer
3535
import Development.IDE.LSP.Protocol
3636
import Development.IDE.Plugin
3737
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)
3939
import Development.IDE.Types.Diagnostics
4040
import Development.IDE.Types.Location
4141
import Development.IDE.Types.Logger as G
@@ -57,24 +57,6 @@ import qualified System.Log.Logger as L
5757
import System.Time.Extra
5858
import Development.Shake (action)
5959

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-
7860
ghcIdePlugins :: T.Text -> IdePlugins IdeState -> (Plugin Config, [T.Text])
7961
ghcIdePlugins pid ps = (asGhcIdePlugin ps, allLspCmdIds' pid ps)
8062

@@ -116,36 +98,12 @@ hlsLogger = G.Logger $ \pri txt ->
11698
-- ---------------------------------------------------------------------
11799

118100
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 ()
130101
runLspMode lspArgs idePlugins = do
131102
dir <- IO.getCurrentDirectory
132103
dbLoc <- getHieDbLoc dir
133104
runWithDb dbLoc $ runLspMode' lspArgs idePlugins
134105

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 ()
149107
runLspMode' lspArgs@LspArguments{..} idePlugins hiedb hiechan = do
150108
LSP.setupLogger argsLogFile ["hls", "hie-bios"]
151109
$ if argsDebugOn then L.DEBUG else L.INFO
@@ -159,6 +117,8 @@ runLspMode' lspArgs@LspArguments{..} idePlugins hiedb hiechan = do
159117

160118
dir <- IO.getCurrentDirectory
161119

120+
libdir <- setInitialDynFlags
121+
162122
pid <- T.pack . show <$> getProcessID
163123
let
164124
(plugins, commandIds) = ghcIdePlugins pid idePlugins

0 commit comments

Comments
 (0)