Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Development.IDE.Core.PluginUtils
Synopsis
- runActionE :: MonadIO m => String -> IdeState -> ExceptT e Action a -> ExceptT e m a
- runActionMT :: MonadIO m => String -> IdeState -> MaybeT Action a -> MaybeT m a
- useE :: IdeRule k v => k -> NormalizedFilePath -> ExceptT PluginError Action v
- useMT :: IdeRule k v => k -> NormalizedFilePath -> MaybeT Action v
- usesE :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> ExceptT PluginError Action (f v)
- usesMT :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> MaybeT Action (f v)
- useWithStaleE :: IdeRule k v => k -> NormalizedFilePath -> ExceptT PluginError Action (v, PositionMapping)
- useWithStaleMT :: IdeRule k v => k -> NormalizedFilePath -> MaybeT Action (v, PositionMapping)
- runIdeActionE :: MonadIO m => String -> ShakeExtras -> ExceptT e IdeAction a -> ExceptT e m a
- runIdeActionMT :: MonadIO m => String -> ShakeExtras -> MaybeT IdeAction a -> MaybeT m a
- useWithStaleFastE :: IdeRule k v => k -> NormalizedFilePath -> ExceptT PluginError IdeAction (v, PositionMapping)
- useWithStaleFastMT :: IdeRule k v => k -> NormalizedFilePath -> MaybeT IdeAction (v, PositionMapping)
- uriToFilePathE :: Monad m => Uri -> ExceptT PluginError m FilePath
- toCurrentPositionE :: Monad m => PositionMapping -> Position -> ExceptT PluginError m Position
- toCurrentPositionMT :: Monad m => PositionMapping -> Position -> MaybeT m Position
- fromCurrentPositionE :: Monad m => PositionMapping -> Position -> ExceptT PluginError m Position
- fromCurrentPositionMT :: Monad m => PositionMapping -> Position -> MaybeT m Position
- toCurrentRangeE :: Monad m => PositionMapping -> Range -> ExceptT PluginError m Range
- toCurrentRangeMT :: Monad m => PositionMapping -> Range -> MaybeT m Range
- fromCurrentRangeE :: Monad m => PositionMapping -> Range -> ExceptT PluginError m Range
- fromCurrentRangeMT :: Monad m => PositionMapping -> Range -> MaybeT m Range
- activeDiagnosticsInRange :: MonadIO m => ShakeExtras -> NormalizedFilePath -> Range -> m (Maybe [FileDiagnostic])
- activeDiagnosticsInRangeMT :: MonadIO m => ShakeExtras -> NormalizedFilePath -> Range -> MaybeT m [FileDiagnostic]
- mkFormattingHandlers :: FormattingHandler IdeState -> PluginHandlers IdeState
Wrapped Action functions
runActionE :: MonadIO m => String -> IdeState -> ExceptT e Action a -> ExceptT e m a Source #
ExceptT version of runAction
, takes a ExceptT Action
runActionMT :: MonadIO m => String -> IdeState -> MaybeT Action a -> MaybeT m a Source #
MaybeT version of runAction
, takes a MaybeT Action
useE :: IdeRule k v => k -> NormalizedFilePath -> ExceptT PluginError Action v Source #
ExceptT version of use
that throws a PluginRuleFailed upon failure
usesE :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> ExceptT PluginError Action (f v) Source #
ExceptT version of uses
that throws a PluginRuleFailed upon failure
usesMT :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> MaybeT Action (f v) Source #
MaybeT version of uses
useWithStaleE :: IdeRule k v => k -> NormalizedFilePath -> ExceptT PluginError Action (v, PositionMapping) Source #
ExceptT version of useWithStale
that throws a PluginRuleFailed upon
failure
useWithStaleMT :: IdeRule k v => k -> NormalizedFilePath -> MaybeT Action (v, PositionMapping) Source #
MaybeT version of useWithStale
Wrapped IdeAction functions
runIdeActionE :: MonadIO m => String -> ShakeExtras -> ExceptT e IdeAction a -> ExceptT e m a Source #
ExceptT version of runIdeAction
, takes a ExceptT IdeAction
runIdeActionMT :: MonadIO m => String -> ShakeExtras -> MaybeT IdeAction a -> MaybeT m a Source #
MaybeT version of runIdeAction
, takes a MaybeT IdeAction
useWithStaleFastE :: IdeRule k v => k -> NormalizedFilePath -> ExceptT PluginError IdeAction (v, PositionMapping) Source #
ExceptT version of useWithStaleFast
that throws a PluginRuleFailed upon
failure
useWithStaleFastMT :: IdeRule k v => k -> NormalizedFilePath -> MaybeT IdeAction (v, PositionMapping) Source #
MaybeT version of useWithStaleFast
uriToFilePathE :: Monad m => Uri -> ExceptT PluginError m FilePath Source #
ExceptT version of uriToFilePath
that throws a PluginInvalidParams upon
failure
Wrapped PositionMapping functions
toCurrentPositionE :: Monad m => PositionMapping -> Position -> ExceptT PluginError m Position Source #
ExceptT version of toCurrentPosition
that throws a PluginInvalidUserState
upon failure
toCurrentPositionMT :: Monad m => PositionMapping -> Position -> MaybeT m Position Source #
MaybeT version of toCurrentPosition
fromCurrentPositionE :: Monad m => PositionMapping -> Position -> ExceptT PluginError m Position Source #
ExceptT version of fromCurrentPosition
that throws a
PluginInvalidUserState upon failure
fromCurrentPositionMT :: Monad m => PositionMapping -> Position -> MaybeT m Position Source #
MaybeT version of fromCurrentPosition
toCurrentRangeE :: Monad m => PositionMapping -> Range -> ExceptT PluginError m Range Source #
ExceptT version of toCurrentRange
that throws a PluginInvalidUserState
upon failure
toCurrentRangeMT :: Monad m => PositionMapping -> Range -> MaybeT m Range Source #
MaybeT version of toCurrentRange
fromCurrentRangeE :: Monad m => PositionMapping -> Range -> ExceptT PluginError m Range Source #
ExceptT version of fromCurrentRange
that throws a PluginInvalidUserState
upon failure
fromCurrentRangeMT :: Monad m => PositionMapping -> Range -> MaybeT m Range Source #
MaybeT version of fromCurrentRange
Diagnostics
activeDiagnosticsInRange :: MonadIO m => ShakeExtras -> NormalizedFilePath -> Range -> m (Maybe [FileDiagnostic]) Source #
Just like activeDiagnosticsInRangeMT
. See the docs of activeDiagnosticsInRangeMT
for details.
activeDiagnosticsInRangeMT :: MonadIO m => ShakeExtras -> NormalizedFilePath -> Range -> MaybeT m [FileDiagnostic] Source #
computes the
activeDiagnosticsInRangeMT
shakeExtras nfp rangeFileDiagnostic
's that HLS produced and overlap with the given range
.
This function is to be used whenever we need an authoritative source of truth for which diagnostics are shown to the user. These diagnostics can be used to provide various IDE features, for example CodeActions, CodeLenses, or refactorings.
However, why do we need this when computing CodeAction
s? A CodeActionParam
has the CodeActionContext
which already contains the diagnostics!
But according to the LSP docs, the server shouldn't rely that these Diagnostic
are actually up-to-date and accurately reflect the state of the document.
From the LSP docs: > An array of diagnostics known on the client side overlapping the range > provided to the `textDocument/codeAction` request. They are provided so > that the server knows which errors are currently presented to the user > for the given range. There is no guarantee that these accurately reflect > the error state of the resource. The primary parameter > to compute code actions is the provided range.
Thus, even when the client sends us the context, we should compute the diagnostics on the server side.