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

Development.IDE.Types.Diagnostics

Synopsis

Documentation

data Diagnostic #

Constructors

Diagnostic 

Fields

Instances

Instances details
FromJSON Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

ToJSON Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

Generic Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

Associated Types

type Rep Diagnostic :: Type -> Type #

Show Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

NFData Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

Methods

rnf :: Diagnostic -> () #

Eq Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

Ord Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

Hashable Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

Pretty Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

Methods

pretty :: Diagnostic -> Doc ann #

prettyList :: [Diagnostic] -> Doc ann #

HasMessage Diagnostic Text 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

HasRange Diagnostic Range 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

HasCode Diagnostic (Maybe (Int32 |? Text)) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

code :: Lens' Diagnostic (Maybe (Int32 |? Text))

HasCodeDescription Diagnostic (Maybe CodeDescription) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

codeDescription :: Lens' Diagnostic (Maybe CodeDescription)

HasData_ Diagnostic (Maybe Value) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

HasDiagnostics CodeAction (Maybe [Diagnostic]) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

diagnostics :: Lens' CodeAction (Maybe [Diagnostic])

HasDiagnostics CodeActionContext [Diagnostic] 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

diagnostics :: Lens' CodeActionContext [Diagnostic]

HasDiagnostics PublishDiagnosticsParams [Diagnostic] 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

diagnostics :: Lens' PublishDiagnosticsParams [Diagnostic]

HasItems FullDocumentDiagnosticReport [Diagnostic] 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

items :: Lens' FullDocumentDiagnosticReport [Diagnostic]

HasItems RelatedFullDocumentDiagnosticReport [Diagnostic] 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

items :: Lens' RelatedFullDocumentDiagnosticReport [Diagnostic]

HasItems WorkspaceFullDocumentDiagnosticReport [Diagnostic] 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

items :: Lens' WorkspaceFullDocumentDiagnosticReport [Diagnostic]

HasRelatedInformation Diagnostic (Maybe [DiagnosticRelatedInformation]) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

relatedInformation :: Lens' Diagnostic (Maybe [DiagnosticRelatedInformation])

HasSeverity Diagnostic (Maybe DiagnosticSeverity) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

HasSource Diagnostic (Maybe Text) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

HasTags Diagnostic (Maybe [DiagnosticTag]) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

Methods

tags :: Lens' Diagnostic (Maybe [DiagnosticTag])

type Rep Diagnostic 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.Diagnostic

type Rep Diagnostic = D1 ('MetaData "Diagnostic" "Language.LSP.Protocol.Internal.Types.Diagnostic" "lsp-types-2.3.0.1-7yeNaKZocsu5j5qdGpaZ2Z" 'False) (C1 ('MetaCons "Diagnostic" 'PrefixI 'True) (((S1 ('MetaSel ('Just "_range") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Range) :*: S1 ('MetaSel ('Just "_severity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe DiagnosticSeverity))) :*: (S1 ('MetaSel ('Just "_code") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (Int32 |? Text))) :*: S1 ('MetaSel ('Just "_codeDescription") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe CodeDescription)))) :*: ((S1 ('MetaSel ('Just "_source") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "_message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "_tags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [DiagnosticTag])) :*: (S1 ('MetaSel ('Just "_relatedInformation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [DiagnosticRelatedInformation])) :*: S1 ('MetaSel ('Just "_data_") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Value)))))))

data ShowDiagnostic Source #

Defines whether a particular diagnostic should be reported back to the user.

One important use case is "missing signature" code lenses, for which we need to enable the corresponding warning during type checking. However, we do not want to show the warning unless the programmer asks for it (#261).

Constructors

ShowDiag

Report back to the user

HideDiag

Hide from user

data FileDiagnostic Source #

Human readable diagnostics for a specific file.

This type packages a pretty printed, human readable error message along with the related source location so that we can display the error on either the console or in the IDE at the right source location.

It also optionally keeps a structured diagnostic message GhcMessage in StructuredMessage.

Constructors

FileDiagnostic 

Fields

Instances

Instances details
Generic FileDiagnostic Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

Associated Types

type Rep FileDiagnostic :: Type -> Type #

Show FileDiagnostic Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

NFData FileDiagnostic Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

Methods

rnf :: FileDiagnostic -> () #

Eq FileDiagnostic Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

Ord FileDiagnostic Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

type Rep FileDiagnostic Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

type Rep FileDiagnostic = D1 ('MetaData "FileDiagnostic" "Development.IDE.Types.Diagnostics" "ghcide-2.10.0.0-TcdlWCKhdK6PhUsYLCqmz" 'False) (C1 ('MetaCons "FileDiagnostic" 'PrefixI 'True) ((S1 ('MetaSel ('Just "fdFilePath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NormalizedFilePath) :*: S1 ('MetaSel ('Just "fdShouldShowDiagnostic") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShowDiagnostic)) :*: (S1 ('MetaSel ('Just "fdLspDiagnostic") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Diagnostic) :*: S1 ('MetaSel ('Just "fdStructuredMessage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StructuredMessage))))

data StructuredMessage Source #

A Maybe-like wrapper for a GhcMessage that doesn't try to compare, show, or force the GhcMessage inside, so that we can derive Show, Eq, Ord, NFData on FileDiagnostic. FileDiagnostic only uses this as metadata so we can safely ignore it in fields.

Instead of pattern matching on these constructors directly, consider ReifiedPrism from the lens package. This allows to conveniently pattern match deeply into the 'MsgEnvelope GhcMessage' constructor. The module Error implements additional ReifiedLenss and ReifiedPrisms, allowing you to avoid importing GHC modules directly.

For example, to pattern match on a TcRnMessage you can use the lens:

  message ^? _SomeStructuredMessage . msgEnvelopeErrorL . _TcRnMessage

This produces a value of type `Maybe TcRnMessage`.

Further, consider utility functions such as stripTcRnMessageContext, which strip context from error messages which may be more convenient in certain situations.

Instances

Instances details
Generic StructuredMessage Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

Associated Types

type Rep StructuredMessage :: Type -> Type #

Show StructuredMessage Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

NFData StructuredMessage Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

Methods

rnf :: StructuredMessage -> () #

Eq StructuredMessage Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

Ord StructuredMessage Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

type Rep StructuredMessage Source # 
Instance details

Defined in Development.IDE.Types.Diagnostics

type Rep StructuredMessage = D1 ('MetaData "StructuredMessage" "Development.IDE.Types.Diagnostics" "ghcide-2.10.0.0-TcdlWCKhdK6PhUsYLCqmz" 'False) (C1 ('MetaCons "NoStructuredMessage" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SomeStructuredMessage" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MsgEnvelope GhcMessage))))

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 DiagnosticSeverity #

Instances

Instances details
FromJSON DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

ToJSON DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

Generic DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

Associated Types

type Rep DiagnosticSeverity :: Type -> Type #

Show DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

NFData DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

Methods

rnf :: DiagnosticSeverity -> () #

Eq DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

Ord DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

Hashable DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

LspEnum DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

Associated Types

type EnumBaseType DiagnosticSeverity

Pretty DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

HasSeverity Diagnostic (Maybe DiagnosticSeverity) 
Instance details

Defined in Language.LSP.Protocol.Types.Lens

type Rep DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

type Rep DiagnosticSeverity = D1 ('MetaData "DiagnosticSeverity" "Language.LSP.Protocol.Internal.Types.DiagnosticSeverity" "lsp-types-2.3.0.1-7yeNaKZocsu5j5qdGpaZ2Z" 'False) ((C1 ('MetaCons "DiagnosticSeverity_Error" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DiagnosticSeverity_Warning" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DiagnosticSeverity_Information" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DiagnosticSeverity_Hint" 'PrefixI 'False) (U1 :: Type -> Type)))
type EnumBaseType DiagnosticSeverity 
Instance details

Defined in Language.LSP.Protocol.Internal.Types.DiagnosticSeverity

type EnumBaseType DiagnosticSeverity = UInt

ideErrorText :: NormalizedFilePath -> Text -> FileDiagnostic Source #

Produce a FileDiagnostic for the given NormalizedFilePath with an error message.

ideErrorFromLspDiag :: Diagnostic -> NormalizedFilePath -> Maybe (MsgEnvelope GhcMessage) -> FileDiagnostic Source #

Create a FileDiagnostic from an existing Diagnostic for a specific NormalizedFilePath. The optional 'MsgEnvelope GhcMessage' is the original error message that was used for creating the Diagnostic. It is included here, to allow downstream consumers, such as HLS plugins, to provide LSP features based on the structured error messages. Additionally, if available, we insert the ghc error code into the Diagnostic. These error codes are used in https://errors.haskell.org/ to provide documentation and explanations for error messages.

type IdeResultNoDiagnosticsEarlyCutoff v = (Maybe ByteString, Maybe v) Source #

an IdeResult with a fingerprint