ghcide-0.3.0: The core of an IDE

Safe HaskellNone
LanguageHaskell2010

Development.IDE.Core.Shake

Description

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 type Q to A. During a single run all the values in the Shake database are consistent so are used in conjunction with each other, e.g. in uses.
  • The Values type stores a map of keys to values. These values are always stored as real Haskell values, whereas Shake serialises all A values between runs. To deserialise a Shake value, we just consult Values.
Synopsis

Documentation

data IdeState Source #

A Shake database plus persistent store. Can be thought of as storing mappings from (FilePath, k) to RuleResult k.

data ShakeExtras Source #

Constructors

ShakeExtras 

Fields

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 #

Constructors

GetModificationTime_ 

Fields

Bundled Patterns

pattern GetModificationTime :: GetModificationTime 
Instances
Eq GetModificationTime Source # 
Instance details

Defined in Development.IDE.Core.Shake

Show GetModificationTime Source # 
Instance details

Defined in Development.IDE.Core.Shake

Generic GetModificationTime Source # 
Instance details

Defined in Development.IDE.Core.Shake

Associated Types

type Rep GetModificationTime :: Type -> Type #

Hashable GetModificationTime Source # 
Instance details

Defined in Development.IDE.Core.Shake

Binary GetModificationTime Source # 
Instance details

Defined in Development.IDE.Core.Shake

NFData GetModificationTime Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

rnf :: GetModificationTime -> () #

type Rep GetModificationTime Source # 
Instance details

Defined in Development.IDE.Core.Shake

type Rep GetModificationTime = D1 (MetaData "GetModificationTime" "Development.IDE.Core.Shake" "ghcide-0.3.0-Dfp4umcHt6s1wVYFQXPyfq" False) (C1 (MetaCons "GetModificationTime_" PrefixI True) (S1 (MetaSel (Just "missingFileDiagnostics") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))
type RuleResult GetModificationTime Source #

Get the modification time of a file.

Instance details

Defined in Development.IDE.Core.Shake

shakeOpen Source #

Open a IdeState, should be shut using shakeShut.

shakeRestart :: IdeState -> [DelayedAction a] -> IO () Source #

Restart the current ShakeSession with the given system actions. Any computation running in the current session will be aborted, but user actions (added via shakeEnqueue) will be requeued. Progress is reported only on the system actions.

shakeEnqueue :: IdeState -> 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.

useNoFile :: IdeRule k v => k -> Action (Maybe v) Source #

uses :: IdeRule k v => k -> [NormalizedFilePath] -> Action [Maybe v] Source #

Return up2date results. Stale results will be ignored.

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

data FastResult a Source #

A (maybe) stale result now, and an up to date one later

Constructors

FastResult 

Fields

useNoFile_ :: IdeRule k v => k -> Action v Source #

uses_ :: IdeRule k v => k -> [NormalizedFilePath] -> Action [v] Source #

usesWithStale :: IdeRule k v => k -> [NormalizedFilePath] -> Action [Maybe (v, PositionMapping)] Source #

Return the last computed result which might be stale.

unsafeClearDiagnostics :: IdeState -> IO () Source #

FIXME: This function is temporary! Only required because the files of interest doesn't work

garbageCollect :: (NormalizedFilePath -> Bool) -> Action () Source #

Clear the results for all files that do not match the given predicate.

data FileVersion Source #

Constructors

VFSVersion !Int 
ModificationTime 

Fields

  • !Int64

    Large unit (platform dependent, do not make assumptions)

  • !Int64

    Small unit (platform dependent, do not make assumptions)

Instances
Show FileVersion Source # 
Instance details

Defined in Development.IDE.Core.Shake

Generic FileVersion Source # 
Instance details

Defined in Development.IDE.Core.Shake

Associated Types

type Rep FileVersion :: Type -> Type #

NFData FileVersion Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

rnf :: FileVersion -> () #

type Rep FileVersion Source # 
Instance details

Defined in Development.IDE.Core.Shake

newtype Priority Source #

Constructors

Priority Double 

deleteValue :: (Typeable k, Hashable k, Eq k, Show k) => IdeState -> k -> NormalizedFilePath -> IO () Source #

Delete the value stored for a given ide build key

type WithProgressFunc = forall a. Text -> ProgressCancellable -> ((Progress -> IO ()) -> IO a) -> IO a Source #

data DelayedAction a Source #

Instances
Show (DelayedAction a) Source # 
Instance details

Defined in Development.IDE.Core.Shake

newtype IdeAction a Source #

Constructors

IdeAction 
Instances
Monad IdeAction Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

(>>=) :: IdeAction a -> (a -> IdeAction b) -> IdeAction b #

(>>) :: IdeAction a -> IdeAction b -> IdeAction b #

return :: a -> IdeAction a #

fail :: String -> IdeAction a #

Functor IdeAction Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

fmap :: (a -> b) -> IdeAction a -> IdeAction b #

(<$) :: a -> IdeAction b -> IdeAction a #

Applicative IdeAction Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

pure :: a -> IdeAction a #

(<*>) :: IdeAction (a -> b) -> IdeAction a -> IdeAction b #

liftA2 :: (a -> b -> c) -> IdeAction a -> IdeAction b -> IdeAction c #

(*>) :: IdeAction a -> IdeAction b -> IdeAction b #

(<*) :: IdeAction a -> IdeAction b -> IdeAction a #

MonadIO IdeAction Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

liftIO :: IO a -> IdeAction a #

MonadReader ShakeExtras IdeAction Source # 
Instance details

Defined in Development.IDE.Core.Shake

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.

newtype Q k Source #

Constructors

Q (k, NormalizedFilePath) 
Instances
Eq k => Eq (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

(==) :: Q k -> Q k -> Bool #

(/=) :: Q k -> Q k -> Bool #

Show k => Show (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

showsPrec :: Int -> Q k -> ShowS #

show :: Q k -> String #

showList :: [Q k] -> ShowS #

Generic (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

Associated Types

type Rep (Q k) :: Type -> Type #

Methods

from :: Q k -> Rep (Q k) x #

to :: Rep (Q k) x -> Q k #

Hashable k => Hashable (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

hashWithSalt :: Int -> Q k -> Int #

hash :: Q k -> Int #

Binary k => Binary (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

put :: Q k -> Put #

get :: Get (Q k) #

putList :: [Q k] -> Put #

NFData k => NFData (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

Methods

rnf :: Q k -> () #

type Rep (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

type Rep (Q k) = D1 (MetaData "Q" "Development.IDE.Core.Shake" "ghcide-0.3.0-Dfp4umcHt6s1wVYFQXPyfq" True) (C1 (MetaCons "Q" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (k, NormalizedFilePath))))
type RuleResult (Q k) Source # 
Instance details

Defined in Development.IDE.Core.Shake

type RuleResult (Q k)