ghcide-2.7.0.0: The core of an IDE

Safe Haskell | None
Language | GHC2021

Development.IDE.GHC.Error

Contents

- Producing Diagnostic values
- utilities working with spans
- utilities working with severities

Synopsis

- diagFromErrMsgs :: Text -> DynFlags -> Bag (MsgEnvelope DecoratedSDoc) -> [FileDiagnostic]
- diagFromErrMsg :: Text -> DynFlags -> MsgEnvelope DecoratedSDoc -> [FileDiagnostic]
- diagFromString :: Text -> DiagnosticSeverity -> SrcSpan -> String -> [FileDiagnostic]
- diagFromStrings :: Text -> DiagnosticSeverity -> [(SrcSpan, String)] -> [FileDiagnostic]
- diagFromGhcException :: Text -> DynFlags -> GhcException -> [FileDiagnostic]
- catchSrcErrors :: DynFlags -> Text -> IO a -> IO (Either [FileDiagnostic] a)
- srcSpanToLocation :: SrcSpan -> Maybe Location
- srcSpanToRange :: SrcSpan -> Maybe Range
- realSrcSpanToRange :: RealSrcSpan -> Range
- realSrcLocToPosition :: RealSrcLoc -> Position
- realSrcSpanToLocation :: RealSrcSpan -> Location
- realSrcSpanToCodePointRange :: RealSrcSpan -> CodePointRange
- realSrcLocToCodePointPosition :: RealSrcLoc -> CodePointPosition
- srcSpanToFilename :: SrcSpan -> Maybe FilePath
- rangeToSrcSpan :: NormalizedFilePath -> Range -> SrcSpan
- rangeToRealSrcSpan :: NormalizedFilePath -> Range -> RealSrcSpan
- positionToRealSrcLoc :: NormalizedFilePath -> Position -> RealSrcLoc
- zeroSpan :: FastString -> RealSrcSpan
- realSpan :: SrcSpan -> Maybe RealSrcSpan
- isInsideSrcSpan :: Position -> SrcSpan -> Bool
- spanContainsRange :: SrcSpan -> Range -> Maybe Bool
- noSpan :: String -> SrcSpan
- toDSeverity :: Severity -> Maybe DiagnosticSeverity

# Producing Diagnostic values

diagFromErrMsgs :: Text -> DynFlags -> Bag (MsgEnvelope DecoratedSDoc) -> [FileDiagnostic] #

diagFromErrMsg :: Text -> DynFlags -> MsgEnvelope DecoratedSDoc -> [FileDiagnostic] #

Produce a GHC-style error from a source span and a message.

diagFromString :: Text -> DiagnosticSeverity -> SrcSpan -> String -> [FileDiagnostic] #

Produce a GHC-style error from a source span and a message.

diagFromStrings :: Text -> DiagnosticSeverity -> [(SrcSpan, String)] -> [FileDiagnostic] #

Produce a bag of GHC-style errors (`ErrorMessages`) from the given (optional) locations and message strings.

diagFromGhcException :: Text -> DynFlags -> GhcException -> [FileDiagnostic] #

catchSrcErrors :: DynFlags -> Text -> IO a -> IO (Either [FileDiagnostic] a) #

Catch the errors thrown by GHC (SourceErrors and compiler-internal exceptions like Panic or InstallationError), and turn them into diagnostics

# utilities working with spans

srcSpanToLocation :: SrcSpan -> Maybe Location #

srcSpanToRange :: SrcSpan -> Maybe Range #

Convert a GHC SrcSpan to a DAML compiler Range

realSrcSpanToRange :: RealSrcSpan -> Range #

realSrcLocToPosition :: RealSrcLoc -> Position #

realSrcSpanToLocation :: RealSrcSpan -> Location #

realSrcSpanToCodePointRange :: RealSrcSpan -> CodePointRange #

Convert a GHC SrcSpan to CodePointRange see Note [Unicode support]

realSrcLocToCodePointPosition :: RealSrcLoc -> CodePointPosition #

Convert a GHC RealSrcLoc to CodePointPosition see Note [Unicode support]

srcSpanToFilename :: SrcSpan -> Maybe FilePath #

Extract a file name from a GHC SrcSpan (use message for unhelpful ones) FIXME This may not be an _absolute_ file name, needs fixing.

rangeToSrcSpan :: NormalizedFilePath -> Range -> SrcSpan #

rangeToRealSrcSpan :: NormalizedFilePath -> Range -> RealSrcSpan #

positionToRealSrcLoc :: NormalizedFilePath -> Position -> RealSrcLoc #

zeroSpan #

Arguments

:: FastString | file path of span
-> RealSrcSpan |

creates a span with zero length in the filename of the argument passed

realSpan :: SrcSpan -> Maybe RealSrcSpan #

isInsideSrcSpan :: Position -> SrcSpan -> Bool #

spanContainsRange :: SrcSpan -> Range -> Maybe Bool #

noSpan :: String -> SrcSpan #

Produces an "unhelpful" source span with the given string.

# utilities working with severities

toDSeverity :: Severity -> Maybe DiagnosticSeverity #

Convert a GHC severity to a DAML compiler Severity. Severities below Warning level are dropped (returning Nothing).