1-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
4{-# LANGUAGE TypeFamilies #-}
5{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE FlexibleInstances #-}
8-- | A Shake implementation of the compiler service, built
9-- using the "Shaker" abstraction layer for in-memory use.
11module Development.IDE.Core.Service(
13 IdeState, initialise, shutdown,
14 runAction, runActions,
15 runActionSync, runActionsSync,
16 getFilesOfInterest, setFilesOfInterest, modifyFilesOfInterest,
18 getDiagnostics, unsafeClearDiagnostics,
22import Control.Concurrent.Extra
23import Control.Monad.Except
24import Development.IDE.Types.Options (IdeOptions(..))
25import Development.IDE.Core.FileStore
26import Development.IDE.Core.OfInterest
27import Development.IDE.Types.Logger
28import Development.Shake hiding (Diagnostic, Env, newCache)
29import qualified Language.Haskell.LSP.Messages as LSP
31import Development.IDE.Core.Shake
35newtype GlobalIdeOptions = GlobalIdeOptions IdeOptions
36instance IsIdeGlobal GlobalIdeOptions
38------------------------------------------------------------
41-- | Initialise the Compiler Service.
43 -> (LSP.FromServerMessage -> IO ())
48initialise mainRule toDiags logger options vfs =
52 (setProfiling options $
53 shakeOptions { shakeThreads = optThreads options
54 , shakeFiles = "/dev/null"
56 addIdeGlobal $ GlobalIdeOptions options
61writeProfile :: IdeState -> FilePath -> IO ()
62writeProfile = shakeProfile
64setProfiling :: IdeOptions -> ShakeOptions -> ShakeOptions
65setProfiling opts shakeOpts =
66 maybe shakeOpts (\p -> shakeOpts { shakeReport = [p], shakeTimings = True }) (optShakeProfiling opts)
68-- | Shutdown the Compiler Service.
69shutdown :: IdeState -> IO ()
72-- | Run a single action using the supplied service. See `runActions`
74runAction :: IdeState -> Action a -> IO a
75runAction service action = head <$> runActions service [action]
77-- | Run a list of actions in parallel using the supplied service.
78-- This will return as soon as the results of the actions are
79-- available. There might still be other rules running at this point,
80-- e.g., the ofInterestRule.
81runActions :: IdeState -> [Action a] -> IO [a]
84 _ <- shakeRun x acts (signalBarrier var)
87-- | This is a synchronous variant of `runAction`. See
88-- `runActionsSync` of more details.
89runActionSync :: IdeState -> Action a -> IO a
90runActionSync s a = head <$> runActionsSync s [a]
92-- | `runActionsSync` is similar to `runActions` but it will
93-- wait for all rules (so in particular the `ofInterestRule`) to
94-- finish running. This is mainly useful in tests, where you want
95-- to wait for all rules to fire so you can check diagnostics.
96runActionsSync :: IdeState -> [Action a] -> IO [a]
97runActionsSync s acts = join $ shakeRun s acts (const $ pure ())
99getIdeOptions :: Action IdeOptions
101 GlobalIdeOptions x <- getIdeGlobalAction
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