Skip to content

Commit 18633c7

Browse files
authored
Lock-less hls-graph (#2411)
* Fix incomplete pattern match warning in 8.8 * lock-less hls-graph
1 parent 083f542 commit 18633c7

File tree

16 files changed

+224
-384
lines changed

16 files changed

+224
-384
lines changed

ghcide/.hlint.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
- {name: GeneralizedNewtypeDeriving, within: []}
7878
- {name: LambdaCase, within: []}
7979
- {name: NamedFieldPuns, within: []}
80-
- {name: PackageImports, within: []}
8180
- {name: RecordWildCards, within: []}
8281
- {name: ScopedTypeVariables, within: []}
8382
- {name: StandaloneDeriving, within: []}

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,9 @@ uniqueCompl candidate unique =
681681
importedFrom (provenance -> ImportedFrom m) = m
682682
importedFrom (provenance -> DefinedIn m) = m
683683
importedFrom (provenance -> Local _) = "local"
684+
#if __GLASGOW_HASKELL__ < 810
685+
importedFrom _ = ""
686+
#endif
684687

685688
-- ---------------------------------------------------------------------
686689
-- helper functions for infix backticks

hls-graph/hls-graph.cabal

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ library
4545
Development.IDE.Graph.Internal.Options
4646
Development.IDE.Graph.Internal.Rules
4747
Development.IDE.Graph.Internal.Database
48-
Development.IDE.Graph.Internal.Ids
49-
Development.IDE.Graph.Internal.Intern
5048
Development.IDE.Graph.Internal.Paths
5149
Development.IDE.Graph.Internal.Profile
5250
Development.IDE.Graph.Internal.Types
@@ -66,11 +64,15 @@ library
6664
, exceptions
6765
, extra
6866
, filepath
67+
, focus
6968
, hashable
7069
, js-dgtable
7170
, js-flot
7271
, js-jquery
72+
, list-t
7373
, primitive
74+
, stm
75+
, stm-containers
7476
, time
7577
, transformers
7678
, unordered-containers

hls-graph/src/Development/IDE/Graph/Database.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ module Development.IDE.Graph.Database(
1212
shakeGetDirtySet,
1313
shakeGetCleanKeys
1414
,shakeGetBuildEdges) where
15+
import Control.Concurrent.STM (atomically,
16+
readTVarIO)
1517
import Data.Dynamic
16-
import Data.IORef (readIORef)
1718
import Data.Maybe
1819
import Development.IDE.Graph.Classes ()
1920
import Development.IDE.Graph.Internal.Action
2021
import Development.IDE.Graph.Internal.Database
21-
import qualified Development.IDE.Graph.Internal.Ids as Ids
2222
import Development.IDE.Graph.Internal.Options
2323
import Development.IDE.Graph.Internal.Profile (writeProfile)
2424
import Development.IDE.Graph.Internal.Rules
@@ -45,12 +45,12 @@ shakeRunDatabase = shakeRunDatabaseForKeys Nothing
4545
-- | Returns the set of dirty keys annotated with their age (in # of builds)
4646
shakeGetDirtySet :: ShakeDatabase -> IO [(Key, Int)]
4747
shakeGetDirtySet (ShakeDatabase _ _ db) =
48-
fmap snd <$> Development.IDE.Graph.Internal.Database.getDirtySet db
48+
Development.IDE.Graph.Internal.Database.getDirtySet db
4949

5050
-- | Returns the build number
5151
shakeGetBuildStep :: ShakeDatabase -> IO Int
5252
shakeGetBuildStep (ShakeDatabase _ _ db) = do
53-
Step s <- readIORef $ databaseStep db
53+
Step s <- readTVarIO $ databaseStep db
5454
return s
5555

5656
-- Only valid if we never pull on the results, which we don't
@@ -64,7 +64,7 @@ shakeRunDatabaseForKeys
6464
-> [Action a]
6565
-> IO ([a], [IO ()])
6666
shakeRunDatabaseForKeys keysChanged (ShakeDatabase lenAs1 as1 db) as2 = do
67-
incDatabase db keysChanged
67+
atomically $ incDatabase db keysChanged
6868
as <- fmap (drop lenAs1) $ runActions db $ map unvoid as1 ++ as2
6969
return (as, [])
7070

@@ -75,12 +75,12 @@ shakeProfileDatabase (ShakeDatabase _ _ s) file = writeProfile file s
7575
-- | Returns the clean keys in the database
7676
shakeGetCleanKeys :: ShakeDatabase -> IO [(Key, Result )]
7777
shakeGetCleanKeys (ShakeDatabase _ _ db) = do
78-
keys <- Ids.elems $ databaseValues db
78+
keys <- getDatabaseValues db
7979
return [ (k,res) | (k, Clean res) <- keys]
8080

8181
-- | Returns the total count of edges in the build graph
8282
shakeGetBuildEdges :: ShakeDatabase -> IO Int
8383
shakeGetBuildEdges (ShakeDatabase _ _ db) = do
84-
keys <- Ids.elems $ databaseValues db
84+
keys <- getDatabaseValues db
8585
let ress = mapMaybe (getResult . snd) keys
8686
return $ sum $ map (length . getResultDepsDefault [] . resultDeps) ress

hls-graph/src/Development/IDE/Graph/Internal/Action.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ runActions db xs = do
130130
getDirtySet :: Action [(Key, Int)]
131131
getDirtySet = do
132132
db <- getDatabase
133-
liftIO $ fmap snd <$> Development.IDE.Graph.Internal.Database.getDirtySet db
133+
liftIO $ Development.IDE.Graph.Internal.Database.getDirtySet db
134134

135135
getKeysAndVisitedAge :: Action [(Key, Int)]
136136
getKeysAndVisitedAge = do

0 commit comments

Comments
 (0)