1-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
5{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE OverloadedStrings #-}
7{-# LANGUAGE FlexibleInstances #-}
9-- | A Shake implementation of the compiler service, built
10-- using the "Shaker" abstraction layer for in-memory use.
12module Development.IDE.Core.OfInterest(
14 getFilesOfInterest, setFilesOfInterest, modifyFilesOfInterest,
17import Control.Concurrent.Extra
18import Control.Monad.Except
23import qualified Data.ByteString.UTF8 as BS
24import Control.Exception
25import Development.IDE.Types.Location
26import Development.IDE.Types.Logger
28import qualified Data.Set as Set
29import qualified Data.Text as T
30import Data.Tuple.Extra
31import Development.Shake hiding (Diagnostic, Env, newCache)
33import Development.IDE.Core.Shake
37newtype OfInterestVar = OfInterestVar (Var (Set NormalizedFilePath))
38instance IsIdeGlobal OfInterestVar
41type instance RuleResult GetFilesOfInterest = Set NormalizedFilePath
44data GetFilesOfInterest = GetFilesOfInterest
45 deriving (Eq, Show, Typeable, Generic)
46instance Hashable GetFilesOfInterest
47instance NFData GetFilesOfInterest
50ofInterestRules :: Rules ()
52 addIdeGlobal . OfInterestVar =<< liftIO (newVar Set.empty)
53 defineEarlyCutoff $ \GetFilesOfInterest _file -> assert (null $ fromNormalizedFilePath _file) $ do
55 filesOfInterest <- getFilesOfInterestUntracked
56 pure (Just $ BS.fromString $ show filesOfInterest, ([], Just filesOfInterest))
59getFilesOfInterest :: Action (Set NormalizedFilePath)
60getFilesOfInterest = useNoFile_ GetFilesOfInterest
64------------------------------------------------------------
67-- | Set the files-of-interest which will be built and kept-up-to-date.
68setFilesOfInterest :: IdeState -> Set NormalizedFilePath -> IO ()
69setFilesOfInterest state files = modifyFilesOfInterest state (const files)
71getFilesOfInterestUntracked :: Action (Set NormalizedFilePath)
72getFilesOfInterestUntracked = do
73 OfInterestVar var <- getIdeGlobalAction
76modifyFilesOfInterest :: IdeState -> (Set NormalizedFilePath -> Set NormalizedFilePath) -> IO ()
77modifyFilesOfInterest state f = do
78 OfInterestVar var <- getIdeGlobalState state
79 files <- modifyVar var $ pure . dupe . f
80 logDebug (ideLogger state) $ "Set files of interest to: " <> T.pack (show $ Set.toList files)
81 void $ shakeRun state []
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list