Skip to content

Commit fec01dd

Browse files
committed
Refactor - move GetFilesOfInterest type and use the appropriate define
1 parent 04ea534 commit fec01dd

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

ghcide/src/Development/IDE/Core/OfInterest.hs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ module Development.IDE.Core.OfInterest(
1414
) where
1515

1616
import Control.Concurrent.Strict
17-
import Control.DeepSeq
18-
import Control.Exception
1917
import Control.Monad
2018
import Control.Monad.IO.Class
2119
import Data.Binary
2220
import Data.HashMap.Strict (HashMap)
2321
import qualified Data.HashMap.Strict as HashMap
24-
import Data.Hashable
2522
import qualified Data.Text as T
26-
import Data.Typeable
2723
import Development.IDE.Graph
28-
import GHC.Generics
2924

3025
import Control.Monad.Trans.Class
3126
import Control.Monad.Trans.Maybe
@@ -44,24 +39,15 @@ import Development.IDE.Types.Options
4439
newtype OfInterestVar = OfInterestVar (Var (HashMap NormalizedFilePath FileOfInterestStatus))
4540
instance IsIdeGlobal OfInterestVar
4641

47-
type instance RuleResult GetFilesOfInterest = HashMap NormalizedFilePath FileOfInterestStatus
48-
49-
data GetFilesOfInterest = GetFilesOfInterest
50-
deriving (Eq, Show, Typeable, Generic)
51-
instance Hashable GetFilesOfInterest
52-
instance NFData GetFilesOfInterest
53-
instance Binary GetFilesOfInterest
54-
55-
5642
-- | The rule that initialises the files of interest state.
5743
ofInterestRules :: Rules ()
5844
ofInterestRules = do
5945
addIdeGlobal . OfInterestVar =<< liftIO (newVar HashMap.empty)
60-
defineEarlyCutoff $ RuleNoDiagnostics $ \GetFilesOfInterest _file -> assert (null $ fromNormalizedFilePath _file) $ do
46+
defineEarlyCutOffNoFile $ \GetFilesOfInterest -> do
6147
alwaysRerun
6248
filesOfInterest <- getFilesOfInterestUntracked
6349
let !cutoff = LBS.toStrict $ encode $ HashMap.toList filesOfInterest
64-
pure (Just cutoff, Just filesOfInterest)
50+
pure (cutoff, filesOfInterest)
6551

6652
-- | Get the files that are open in the IDE.
6753
getFilesOfInterest :: Action (HashMap NormalizedFilePath FileOfInterestStatus)

ghcide/src/Development/IDE/Core/RuleTypes.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import HscTypes (HomeModInfo,
4040
import qualified Data.Binary as B
4141
import Data.ByteString (ByteString)
4242
import qualified Data.ByteString.Lazy as LBS
43+
import Data.HashMap.Strict (HashMap)
4344
import Data.Text (Text)
4445
import Data.Time
4546
import Development.IDE.Import.FindImports (ArtifactsLocation)
@@ -353,6 +354,8 @@ type instance RuleResult GetModSummary = ModSummaryResult
353354
-- | Generate a ModSummary with the timestamps and preprocessed content elided, for more successful early cutoff
354355
type instance RuleResult GetModSummaryWithoutTimestamps = ModSummaryResult
355356

357+
type instance RuleResult GetFilesOfInterest = HashMap NormalizedFilePath FileOfInterestStatus
358+
356359
data GetParsedModule = GetParsedModule
357360
deriving (Eq, Show, Typeable, Generic)
358361
instance Hashable GetParsedModule
@@ -510,6 +513,12 @@ instance Hashable GhcSessionIO
510513
instance NFData GhcSessionIO
511514
instance Binary GhcSessionIO
512515

516+
data GetFilesOfInterest = GetFilesOfInterest
517+
deriving (Eq, Show, Typeable, Generic)
518+
instance Hashable GetFilesOfInterest
519+
instance NFData GetFilesOfInterest
520+
instance Binary GetFilesOfInterest
521+
513522
makeLensesWith
514523
(lensRules & lensField .~ mappingNamer (pure . (++ "L")))
515524
''Splices

0 commit comments

Comments
 (0)