ghcide-2.10.0.0: The core of an IDE
Safe HaskellSafe-Inferred
LanguageGHC2021

Development.IDE.GHC.Error

Synopsis

Producing Diagnostic values

diagFromGhcErrorMessages :: Text -> DynFlags -> Bag (MsgEnvelope GhcMessage) -> [FileDiagnostic] Source #

Compatibility function for creating '[FileDiagnostic]' from a Bag of GHC error messages. The function signature changes based on the GHC version. While this is not desirable, it avoids more CPP statements in code that implements actual logic.

diagFromErrMsg :: Text -> DynFlags -> MsgEnvelope GhcMessage -> [FileDiagnostic] Source #

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

diagFromString :: Text -> DiagnosticSeverity -> SrcSpan -> String -> Maybe (MsgEnvelope GhcMessage) -> [FileDiagnostic] Source #

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

diagFromStrings :: Text -> DiagnosticSeverity -> [(SrcSpan, String, Maybe (MsgEnvelope GhcMessage))] -> [FileDiagnostic] Source #

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

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

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

utilities working with spans

srcSpanToRange :: SrcSpan -> Maybe Range Source #

Convert a GHC SrcSpan to a DAML compiler Range

realSrcSpanToCodePointRange :: RealSrcSpan -> CodePointRange Source #

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

realSrcLocToCodePointPosition :: RealSrcLoc -> CodePointPosition Source #

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

srcSpanToFilename :: SrcSpan -> Maybe FilePath Source #

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

zeroSpan Source #

Arguments

:: FastString

file path of span

-> RealSrcSpan 

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

noSpan :: String -> SrcSpan Source #

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

utilities working with severities

toDSeverity :: Severity -> Maybe DiagnosticSeverity Source #

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