Skip to content

Commit 2f83b0b

Browse files
dylan-thinnesJaro Reinders
authored andcommitted
Improve comment on metadata fdStructuredMessage in FileDiagnostic
1 parent 03c8409 commit 2f83b0b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ghcide/src/Development/IDE/Types/Diagnostics.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ instance NFData ShowDiagnostic where
125125

126126
-- | A Maybe-like wrapper for a GhcMessage that doesn't try to compare, show, or
127127
-- force the GhcMessage inside, so that we can derive Show, Eq, Ord, NFData on
128-
-- FileDiagnostic
128+
-- FileDiagnostic. FileDiagnostic only uses this as metadata so we can safely
129+
-- ignore it in fields.
129130
data StructuredMessage
130131
= NoStructuredMessage
131132
| SomeStructuredMessage (MsgEnvelope GhcMessage)
@@ -156,10 +157,17 @@ instance NFData StructuredMessage where
156157
-- along with the related source location so that we can display the error
157158
-- on either the console or in the IDE at the right source location.
158159
--
160+
-- It also optionally keeps a structured diagnostic message GhcMessage in
161+
-- StructuredMessage.
162+
--
159163
data FileDiagnostic = FileDiagnostic
160164
{ fdFilePath :: NormalizedFilePath
161165
, fdShouldShowDiagnostic :: ShowDiagnostic
162166
, fdLspDiagnostic :: Diagnostic
167+
-- | The optional GhcMessage inside of this StructuredMessage is ignored for
168+
-- Eq, Ord, Show, and NFData instances. This is fine because this field
169+
-- should only ever be metadata and should never be used to distinguish
170+
-- between FileDiagnostics.
163171
, fdStructuredMessage :: StructuredMessage
164172
}
165173
deriving (Eq, Ord, Show, Generic)

0 commit comments

Comments
 (0)