Safe Haskell | None |
---|---|
Language | Haskell2010 |
A Shake implementation of the compiler service.
There are two primary locations where data lives, and both of these contain much the same data:
- The Shake database (inside
shakeDb
) stores a map of shake keys to shake values. In our case, these are all of typeQ
toA
. During a single run all the values in the Shake database are consistent so are used in conjunction with each other, e.g. inuses
. - The
Values
type stores a map of keys to values. These values are always stored as real Haskell values, whereas Shake serialises allA
values between runs. To deserialise a Shake value, we just consult Values.
Synopsis
- data IdeState
- shakeExtras :: IdeState -> ShakeExtras
- data ShakeExtras = ShakeExtras {
- eventer :: FromServerMessage -> IO ()
- debouncer :: Debouncer NormalizedUri
- logger :: Logger
- globals :: Var (HashMap TypeRep Dynamic)
- state :: Var Values
- diagnostics :: Var DiagnosticStore
- hiddenDiagnostics :: Var DiagnosticStore
- publishedDiagnostics :: Var (HashMap NormalizedUri [Diagnostic])
- positionMapping :: Var (HashMap NormalizedUri (Map TextDocumentVersion (PositionDelta, PositionMapping)))
- inProgress :: Var (HashMap NormalizedFilePath Int)
- progressUpdate :: ProgressEvent -> IO ()
- ideTesting :: IdeTesting
- session :: MVar ShakeSession
- withProgress :: WithProgressFunc
- withIndefiniteProgress :: WithIndefiniteProgressFunc
- restartShakeSession :: [DelayedAction ()] -> IO ()
- ideNc :: IORef NameCache
- knownTargetsVar :: Var (Hashed KnownTargets)
- exportsMap :: Var ExportsMap
- actionQueue :: ActionQueue
- clientCapabilities :: ClientCapabilities
- getShakeExtras :: Action ShakeExtras
- getShakeExtrasRules :: Rules ShakeExtras
- type KnownTargets = HashMap Target [NormalizedFilePath]
- data Target
- toKnownFiles :: KnownTargets -> HashSet NormalizedFilePath
- type IdeRule k v = (RuleResult k ~ v, ShakeValue k, Show v, Typeable v, NFData v)
- type IdeResult v = ([FileDiagnostic], Maybe v)
- data GetModificationTime where
- GetModificationTime_ { }
- pattern GetModificationTime :: GetModificationTime
- shakeOpen :: IO LspId -> (FromServerMessage -> IO ()) -> WithProgressFunc -> WithIndefiniteProgressFunc -> ClientCapabilities -> Logger -> Debouncer NormalizedUri -> Maybe FilePath -> IdeReportProgress -> IdeTesting -> ShakeOptions -> Rules () -> IO IdeState
- shakeShut :: IdeState -> IO ()
- shakeRestart :: IdeState -> [DelayedAction ()] -> IO ()
- shakeEnqueue :: ShakeExtras -> DelayedAction a -> IO (IO a)
- shakeProfile :: IdeState -> FilePath -> IO ()
- use :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe v)
- useNoFile :: IdeRule k v => k -> Action (Maybe v)
- uses :: IdeRule k v => k -> [NormalizedFilePath] -> Action [Maybe v]
- useWithStaleFast :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (Maybe (v, PositionMapping))
- useWithStaleFast' :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (FastResult v)
- delayedAction :: DelayedAction a -> IdeAction (IO a)
- data FastResult a = FastResult {}
- use_ :: IdeRule k v => k -> NormalizedFilePath -> Action v
- useNoFile_ :: IdeRule k v => k -> Action v
- uses_ :: IdeRule k v => k -> [NormalizedFilePath] -> Action [v]
- useWithStale :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe (v, PositionMapping))
- usesWithStale :: IdeRule k v => k -> [NormalizedFilePath] -> Action [Maybe (v, PositionMapping)]
- useWithStale_ :: IdeRule k v => k -> NormalizedFilePath -> Action (v, PositionMapping)
- usesWithStale_ :: IdeRule k v => k -> [NormalizedFilePath] -> Action [(v, PositionMapping)]
- define :: IdeRule k v => (k -> NormalizedFilePath -> Action (IdeResult v)) -> Rules ()
- defineEarlyCutoff :: IdeRule k v => (k -> NormalizedFilePath -> Action (Maybe ByteString, IdeResult v)) -> Rules ()
- defineOnDisk :: (ShakeValue k, RuleResult k ~ ()) => (k -> NormalizedFilePath -> OnDiskRule) -> Rules ()
- needOnDisk :: (ShakeValue k, RuleResult k ~ ()) => k -> NormalizedFilePath -> Action ()
- needOnDisks :: (ShakeValue k, RuleResult k ~ ()) => k -> [NormalizedFilePath] -> Action ()
- getDiagnostics :: IdeState -> IO [FileDiagnostic]
- getHiddenDiagnostics :: IdeState -> IO [FileDiagnostic]
- class Typeable a => IsIdeGlobal a
- addIdeGlobal :: IsIdeGlobal a => a -> Rules ()
- addIdeGlobalExtras :: IsIdeGlobal a => ShakeExtras -> a -> IO ()
- getIdeGlobalState :: forall a. IsIdeGlobal a => IdeState -> IO a
- getIdeGlobalAction :: forall a. IsIdeGlobal a => Action a
- getIdeGlobalExtras :: forall a. IsIdeGlobal a => ShakeExtras -> IO a
- getIdeOptions :: Action IdeOptions
- getIdeOptionsIO :: ShakeExtras -> IO IdeOptions
- newtype GlobalIdeOptions = GlobalIdeOptions IdeOptions
- garbageCollect :: (NormalizedFilePath -> Bool) -> Action ()
- knownTargets :: Action (Hashed KnownTargets)
- setPriority :: Priority -> Action ()
- sendEvent :: FromServerMessage -> Action ()
- ideLogger :: IdeState -> Logger
- actionLogger :: Action Logger
- data FileVersion
- = VFSVersion !Int
- | ModificationTime !Int64 !Int64
- newtype Priority = Priority Double
- updatePositionMapping :: IdeState -> VersionedTextDocumentIdentifier -> List TextDocumentContentChangeEvent -> IO ()
- deleteValue :: (Typeable k, Hashable k, Eq k, Show k) => IdeState -> k -> NormalizedFilePath -> IO ()
- data OnDiskRule = OnDiskRule {}
- type WithProgressFunc = forall a. Text -> ProgressCancellable -> ((Progress -> IO ()) -> IO a) -> IO a
- type WithIndefiniteProgressFunc = forall a. Text -> ProgressCancellable -> IO a -> IO a
- data ProgressEvent
- data DelayedAction a
- mkDelayedAction :: String -> Priority -> Action a -> DelayedAction a
- newtype IdeAction a = IdeAction {}
- runIdeAction :: String -> ShakeExtras -> IdeAction a -> IO a
- mkUpdater :: MaybeT IdeAction NameCacheUpdater
- newtype Q k = Q (k, NormalizedFilePath)
Documentation
A Shake database plus persistent store. Can be thought of as storing
mappings from (FilePath, k)
to RuleResult k
.
shakeExtras :: IdeState -> ShakeExtras Source #
data ShakeExtras Source #
ShakeExtras | |
|
Instances
MonadReader ShakeExtras IdeAction Source # | |
Defined in Development.IDE.Core.Shake ask :: IdeAction ShakeExtras # local :: (ShakeExtras -> ShakeExtras) -> IdeAction a -> IdeAction a # reader :: (ShakeExtras -> a) -> IdeAction a # |
type KnownTargets = HashMap Target [NormalizedFilePath] Source #
A mapping of module name to known files
Instances
Eq Target Source # | |
Show Target Source # | |
Generic Target Source # | |
Hashable Target Source # | |
Defined in Development.IDE.Types.KnownTargets | |
NFData Target Source # | |
Defined in Development.IDE.Types.KnownTargets | |
type Rep Target Source # | |
Defined in Development.IDE.Types.KnownTargets type Rep Target = D1 ('MetaData "Target" "Development.IDE.Types.KnownTargets" "ghcide-0.7.3.0-7Jt80mSDLDuL0bAoNcQUR5" 'False) (C1 ('MetaCons "TargetModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleName)) :+: C1 ('MetaCons "TargetFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NormalizedFilePath))) |
type IdeRule k v = (RuleResult k ~ v, ShakeValue k, Show v, Typeable v, NFData v) Source #
type IdeResult v = ([FileDiagnostic], Maybe v) Source #
The result of an IDE operation. Warnings and errors are in the Diagnostic, and a value is in the Maybe. For operations that throw an error you expect a non-empty list of diagnostics, at least one of which is an error, and a Nothing. For operations that succeed you expect perhaps some warnings and a Just. For operations that depend on other failing operations you may get empty diagnostics and a Nothing, to indicate this phase throws no fresh errors but still failed.
A rule on a file should only return diagnostics for that given file. It should not propagate diagnostic errors through multiple phases.
data GetModificationTime Source #
GetModificationTime_ | |
|
pattern GetModificationTime :: GetModificationTime |
Instances
:: IO LspId | |
-> (FromServerMessage -> IO ()) | diagnostic handler |
-> WithProgressFunc | |
-> WithIndefiniteProgressFunc | |
-> ClientCapabilities | |
-> Logger | |
-> Debouncer NormalizedUri | |
-> Maybe FilePath | |
-> IdeReportProgress | |
-> IdeTesting | |
-> ShakeOptions | |
-> Rules () | |
-> IO IdeState |
shakeRestart :: IdeState -> [DelayedAction ()] -> IO () Source #
Restart the current ShakeSession
with the given system actions.
Any actions running in the current session will be aborted,
but actions added via shakeEnqueue
will be requeued.
shakeEnqueue :: ShakeExtras -> DelayedAction a -> IO (IO a) Source #
Enqueue an action in the existing ShakeSession
.
Returns a computation to block until the action is run, propagating exceptions.
Assumes a ShakeSession
is available.
Appropriate for user actions other than edits.
use :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe v) Source #
Request a Rule result if available
useWithStaleFast :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (Maybe (v, PositionMapping)) Source #
Lookup value in the database and return with the stale value immediately Will queue an action to refresh the value. Might block the first time the rule runs, but never blocks after that.
useWithStaleFast' :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (FastResult v) Source #
Same as useWithStaleFast but lets you wait for an up to date result
delayedAction :: DelayedAction a -> IdeAction (IO a) Source #
These actions are run asynchronously after the current action is finished running. For example, to trigger a key build after a rule has already finished as is the case with useWithStaleFast
useNoFile_ :: IdeRule k v => k -> Action v Source #
useWithStale :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe (v, PositionMapping)) Source #
Request a Rule result, it not available return the last computed result, if any, which may be stale
usesWithStale :: IdeRule k v => k -> [NormalizedFilePath] -> Action [Maybe (v, PositionMapping)] Source #
Return the last computed result which might be stale.
useWithStale_ :: IdeRule k v => k -> NormalizedFilePath -> Action (v, PositionMapping) Source #
Request a Rule result, it not available return the last computed result which may be stale. Errors out if none available.
usesWithStale_ :: IdeRule k v => k -> [NormalizedFilePath] -> Action [(v, PositionMapping)] Source #
Plural version of useWithStale_
define :: IdeRule k v => (k -> NormalizedFilePath -> Action (IdeResult v)) -> Rules () Source #
Define a new Rule without early cutoff
defineEarlyCutoff :: IdeRule k v => (k -> NormalizedFilePath -> Action (Maybe ByteString, IdeResult v)) -> Rules () Source #
Define a new Rule with early cutoff
defineOnDisk :: (ShakeValue k, RuleResult k ~ ()) => (k -> NormalizedFilePath -> OnDiskRule) -> Rules () Source #
needOnDisk :: (ShakeValue k, RuleResult k ~ ()) => k -> NormalizedFilePath -> Action () Source #
needOnDisks :: (ShakeValue k, RuleResult k ~ ()) => k -> [NormalizedFilePath] -> Action () Source #
getDiagnostics :: IdeState -> IO [FileDiagnostic] Source #
getHiddenDiagnostics :: IdeState -> IO [FileDiagnostic] Source #
class Typeable a => IsIdeGlobal a Source #
Instances
IsIdeGlobal GlobalIdeOptions Source # | |
Defined in Development.IDE.Core.Shake | |
IsIdeGlobal VFSHandle Source # | |
Defined in Development.IDE.Core.FileStore | |
IsIdeGlobal CompiledLinkables Source # | |
Defined in Development.IDE.Core.Rules |
addIdeGlobal :: IsIdeGlobal a => a -> Rules () Source #
addIdeGlobalExtras :: IsIdeGlobal a => ShakeExtras -> a -> IO () Source #
getIdeGlobalState :: forall a. IsIdeGlobal a => IdeState -> IO a Source #
getIdeGlobalAction :: forall a. IsIdeGlobal a => Action a Source #
getIdeGlobalExtras :: forall a. IsIdeGlobal a => ShakeExtras -> IO a Source #
newtype GlobalIdeOptions Source #
Instances
IsIdeGlobal GlobalIdeOptions Source # | |
Defined in Development.IDE.Core.Shake |
garbageCollect :: (NormalizedFilePath -> Bool) -> Action () Source #
Clear the results for all files that do not match the given predicate.
knownTargets :: Action (Hashed KnownTargets) Source #
Get all the files in the project
setPriority :: Priority -> Action () Source #
sendEvent :: FromServerMessage -> Action () Source #
data FileVersion Source #
Instances
updatePositionMapping :: IdeState -> VersionedTextDocumentIdentifier -> List TextDocumentContentChangeEvent -> IO () Source #
deleteValue :: (Typeable k, Hashable k, Eq k, Show k) => IdeState -> k -> NormalizedFilePath -> IO () Source #
Delete the value stored for a given ide build key
data OnDiskRule Source #
type WithProgressFunc = forall a. Text -> ProgressCancellable -> ((Progress -> IO ()) -> IO a) -> IO a Source #
type WithIndefiniteProgressFunc = forall a. Text -> ProgressCancellable -> IO a -> IO a Source #
data DelayedAction a Source #
Instances
Functor DelayedAction Source # | |
Defined in Development.IDE.Types.Action fmap :: (a -> b) -> DelayedAction a -> DelayedAction b # (<$) :: a -> DelayedAction b -> DelayedAction a # | |
Eq (DelayedAction a) Source # | |
Defined in Development.IDE.Types.Action (==) :: DelayedAction a -> DelayedAction a -> Bool # (/=) :: DelayedAction a -> DelayedAction a -> Bool # | |
Show (DelayedAction a) Source # | |
Defined in Development.IDE.Types.Action showsPrec :: Int -> DelayedAction a -> ShowS # show :: DelayedAction a -> String # showList :: [DelayedAction a] -> ShowS # | |
Hashable (DelayedAction a) Source # | |
Defined in Development.IDE.Types.Action hashWithSalt :: Int -> DelayedAction a -> Int # hash :: DelayedAction a -> Int # |
mkDelayedAction :: String -> Priority -> Action a -> DelayedAction a Source #
Instances
Monad IdeAction Source # | |
Functor IdeAction Source # | |
Applicative IdeAction Source # | |
MonadIO IdeAction Source # | |
Defined in Development.IDE.Core.Shake | |
MonadReader ShakeExtras IdeAction Source # | |
Defined in Development.IDE.Core.Shake ask :: IdeAction ShakeExtras # local :: (ShakeExtras -> ShakeExtras) -> IdeAction a -> IdeAction a # reader :: (ShakeExtras -> a) -> IdeAction a # |
runIdeAction :: String -> ShakeExtras -> IdeAction a -> IO a Source #
IdeActions are used when we want to return a result immediately, even if it is stale Useful for UI actions like hover, completion where we don't want to block.
Q (k, NormalizedFilePath) |
Instances
Eq k => Eq (Q k) Source # | |
Show k => Show (Q k) Source # | |
Hashable k => Hashable (Q k) Source # | |
Defined in Development.IDE.Types.Shake | |
Binary k => Binary (Q k) Source # | |
NFData k => NFData (Q k) Source # | |
Defined in Development.IDE.Types.Shake | |
type RuleResult (Q k) Source # | |
Defined in Development.IDE.Types.Shake |