@@ -48,7 +48,7 @@ tests = testGroup "diagnostics"
48
48
[ testWithDummyPluginEmpty " fix syntax error" $ do
49
49
let content = T. unlines [ " module Testing wher" ]
50
50
doc <- createDoc " Testing.hs" " haskell" content
51
- expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " parse error" )])]
51
+ expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " parse error" , Nothing )])]
52
52
let change = TextDocumentContentChangeEvent $ InL TextDocumentContentChangePartial
53
53
{ _range = Range (Position 0 15 ) (Position 0 19 )
54
54
, _rangeLength = Nothing
@@ -67,18 +67,18 @@ tests = testGroup "diagnostics"
67
67
, _text = " wher"
68
68
}
69
69
changeDoc doc [change]
70
- expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " parse error" )])]
70
+ expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " parse error" , Nothing )])]
71
71
, testWithDummyPluginEmpty " update syntax error" $ do
72
72
let content = T. unlines [ " module Testing(missing) where" ]
73
73
doc <- createDoc " Testing.hs" " haskell" content
74
- expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " Not in scope: 'missing'" )])]
74
+ expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " Not in scope: 'missing'" , Nothing )])]
75
75
let change = TextDocumentContentChangeEvent $ InL TextDocumentContentChangePartial
76
76
{ _range = Range (Position 0 15 ) (Position 0 16 )
77
77
, _rangeLength = Nothing
78
78
, _text = " l"
79
79
}
80
80
changeDoc doc [change]
81
- expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " Not in scope: 'lissing'" )])]
81
+ expectDiagnostics [(" Testing.hs" , [(DiagnosticSeverity_Error , (0 , 15 ), " Not in scope: 'lissing'" , Nothing )])]
82
82
, testWithDummyPluginEmpty " variable not in scope" $ do
83
83
let content = T. unlines
84
84
[ " module Testing where"
@@ -90,8 +90,8 @@ tests = testGroup "diagnostics"
90
90
_ <- createDoc " Testing.hs" " haskell" content
91
91
expectDiagnostics
92
92
[ ( " Testing.hs"
93
- , [ (DiagnosticSeverity_Error , (2 , 15 ), " Variable not in scope: ab" )
94
- , (DiagnosticSeverity_Error , (4 , 11 ), " Variable not in scope: cd" )
93
+ , [ (DiagnosticSeverity_Error , (2 , 15 ), " Variable not in scope: ab" , Nothing )
94
+ , (DiagnosticSeverity_Error , (4 , 11 ), " Variable not in scope: cd" , Nothing )
95
95
]
96
96
)
97
97
]
@@ -104,7 +104,7 @@ tests = testGroup "diagnostics"
104
104
_ <- createDoc " Testing.hs" " haskell" content
105
105
expectDiagnostics
106
106
[ ( " Testing.hs"
107
- , [(DiagnosticSeverity_Error , (2 , 14 ), " Couldn't match type '[Char]' with 'Int'" )]
107
+ , [(DiagnosticSeverity_Error , (2 , 14 ), " Couldn't match type '[Char]' with 'Int'" , Nothing )]
108
108
)
109
109
]
110
110
, testWithDummyPluginEmpty " typed hole" $ do
@@ -116,7 +116,7 @@ tests = testGroup "diagnostics"
116
116
_ <- createDoc " Testing.hs" " haskell" content
117
117
expectDiagnostics
118
118
[ ( " Testing.hs"
119
- , [(DiagnosticSeverity_Error , (2 , 8 ), " Found hole: _ :: Int -> String" )]
119
+ , [(DiagnosticSeverity_Error , (2 , 8 ), " Found hole: _ :: Int -> String" , Nothing )]
120
120
)
121
121
]
122
122
@@ -132,8 +132,8 @@ tests = testGroup "diagnostics"
132
132
, " b = True" ]
133
133
bMessage = " Couldn't match expected type 'Float' with actual type 'Bool'"
134
134
expectedDs aMessage =
135
- [ (" A.hs" , [(DiagnosticSeverity_Error , (2 ,4 ), aMessage)])
136
- , (" B.hs" , [(DiagnosticSeverity_Error , (3 ,4 ), bMessage)])]
135
+ [ (" A.hs" , [(DiagnosticSeverity_Error , (2 ,4 ), aMessage, Nothing )])
136
+ , (" B.hs" , [(DiagnosticSeverity_Error , (3 ,4 ), bMessage, Nothing )])]
137
137
deferralTest title binding msg = testWithDummyPluginEmpty title $ do
138
138
_ <- createDoc " A.hs" " haskell" $ sourceA binding
139
139
_ <- createDoc " B.hs" " haskell" sourceB
@@ -158,14 +158,14 @@ tests = testGroup "diagnostics"
158
158
, _text = " "
159
159
}
160
160
changeDoc docA [change]
161
- expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 0 ), " Could not find module" )])]
161
+ expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 0 ), " Could not find module" , Nothing )])]
162
162
, testWithDummyPluginEmpty " add missing module" $ do
163
163
let contentB = T. unlines
164
164
[ " module ModuleB where"
165
165
, " import ModuleA ()"
166
166
]
167
167
_ <- createDoc " ModuleB.hs" " haskell" contentB
168
- expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Could not find module" )])]
168
+ expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Could not find module" , Nothing )])]
169
169
let contentA = T. unlines [ " module ModuleA where" ]
170
170
_ <- createDoc " ModuleA.hs" " haskell" contentA
171
171
expectDiagnostics [(" ModuleB.hs" , [] )]
@@ -185,7 +185,7 @@ tests = testGroup "diagnostics"
185
185
, " import ModuleA ()"
186
186
]
187
187
_ <- createDoc (tmpDir </> " ModuleB.hs" ) " haskell" contentB
188
- expectDiagnostics [(tmpDir </> " ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Could not find module" )])]
188
+ expectDiagnostics [(tmpDir </> " ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Could not find module" , Nothing )])]
189
189
let contentA = T. unlines [ " module ModuleA where" ]
190
190
_ <- createDoc (tmpDir </> " ModuleA.hs" ) " haskell" contentA
191
191
expectDiagnostics [(tmpDir </> " ModuleB.hs" , [] )]
@@ -202,10 +202,10 @@ tests = testGroup "diagnostics"
202
202
_ <- createDoc " ModuleB.hs" " haskell" contentB
203
203
expectDiagnostics
204
204
[ ( " ModuleA.hs"
205
- , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" )]
205
+ , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" , Nothing )]
206
206
)
207
207
, ( " ModuleB.hs"
208
- , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" )]
208
+ , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" , Nothing )]
209
209
)
210
210
]
211
211
, let contentA = T. unlines [ " module ModuleA where" , " import ModuleB" ]
@@ -222,8 +222,8 @@ tests = testGroup "diagnostics"
222
222
]) $ do
223
223
_ <- createDoc " ModuleD.hs" " haskell" contentD
224
224
expectDiagnostics
225
- [ ( " ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" )])
226
- , ( " ModuleA.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" )])
225
+ [ ( " ModuleB.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" , Nothing )])
226
+ , ( " ModuleA.hs" , [(DiagnosticSeverity_Error , (1 , 7 ), " Cyclic module dependency between ModuleA, ModuleB" , Nothing )])
227
227
]
228
228
, testWithDummyPluginEmpty " cyclic module dependency with hs-boot" $ do
229
229
let contentA = T. unlines
@@ -243,7 +243,7 @@ tests = testGroup "diagnostics"
243
243
_ <- createDoc " ModuleA.hs" " haskell" contentA
244
244
_ <- createDoc " ModuleB.hs" " haskell" contentB
245
245
_ <- createDoc " ModuleB.hs-boot" " haskell" contentBboot
246
- expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" )])]
246
+ expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" , Nothing )])]
247
247
, testWithDummyPlugin " bidirectional module dependency with hs-boot"
248
248
(mkIdeTestFs [directCradle [" ModuleA" , " ModuleB" ]])
249
249
$ do
@@ -268,7 +268,7 @@ tests = testGroup "diagnostics"
268
268
_ <- createDoc " ModuleA.hs-boot" " haskell" contentAboot
269
269
_ <- createDoc " ModuleB.hs" " haskell" contentB
270
270
_ <- createDoc " ModuleB.hs-boot" " haskell" contentBboot
271
- expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" )])]
271
+ expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" , Nothing )])]
272
272
, testWithDummyPluginEmpty " correct reference used with hs-boot" $ do
273
273
let contentB = T. unlines
274
274
[ " module ModuleB where"
@@ -294,7 +294,7 @@ tests = testGroup "diagnostics"
294
294
_ <- createDoc " ModuleA.hs" " haskell" contentA
295
295
_ <- createDoc " ModuleA.hs-boot" " haskell" contentAboot
296
296
_ <- createDoc " ModuleC.hs" " haskell" contentC
297
- expectDiagnostics [(" ModuleC.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" )])]
297
+ expectDiagnostics [(" ModuleC.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" , Nothing )])]
298
298
, testWithDummyPluginEmpty " redundant import" $ do
299
299
let contentA = T. unlines [" module ModuleA where" ]
300
300
let contentB = T. unlines
@@ -306,7 +306,7 @@ tests = testGroup "diagnostics"
306
306
_ <- createDoc " ModuleB.hs" " haskell" contentB
307
307
expectDiagnosticsWithTags
308
308
[ ( " ModuleB.hs"
309
- , [(DiagnosticSeverity_Warning , (2 , 0 ), " The import of 'ModuleA' is redundant" , Just DiagnosticTag_Unnecessary )]
309
+ , [(DiagnosticSeverity_Warning , (2 , 0 ), " The import of 'ModuleA' is redundant" , Nothing , Just DiagnosticTag_Unnecessary )]
310
310
)
311
311
]
312
312
, testWithDummyPluginEmpty " redundant import even without warning" $ do
@@ -320,7 +320,7 @@ tests = testGroup "diagnostics"
320
320
]
321
321
_ <- createDoc " ModuleA.hs" " haskell" contentA
322
322
_ <- createDoc " ModuleB.hs" " haskell" contentB
323
- expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" )])]
323
+ expectDiagnostics [(" ModuleB.hs" , [(DiagnosticSeverity_Warning , (3 ,0 ), " Top-level binding" , Nothing )])]
324
324
, testWithDummyPluginEmpty " package imports" $ do
325
325
let thisDataListContent = T. unlines
326
326
[ " module Data.List where"
@@ -348,14 +348,14 @@ tests = testGroup "diagnostics"
348
348
else if ghcVersion >= GHC94 then
349
349
" Variable not in scope: map" -- See https://gitlab.haskell.org/ghc/ghc/-/issues/22130
350
350
else
351
- " Not in scope: \8216ThisList.map\8217" )
351
+ " Not in scope: \8216ThisList.map\8217" , Nothing )
352
352
,(DiagnosticSeverity_Error , (7 , 9 ),
353
353
if ghcVersion >= GHC96 then
354
354
" Variable not in scope: BaseList.x"
355
355
else if ghcVersion >= GHC94 then
356
356
" Variable not in scope: x" -- See https://gitlab.haskell.org/ghc/ghc/-/issues/22130
357
357
else
358
- " Not in scope: \8216BaseList.x\8217" )
358
+ " Not in scope: \8216BaseList.x\8217" , Nothing )
359
359
]
360
360
)
361
361
]
@@ -373,7 +373,7 @@ tests = testGroup "diagnostics"
373
373
-- where appropriate. The warning should use an unqualified name 'Ord', not
374
374
-- something like 'GHC.Classes.Ord'. The choice of redundant-constraints to
375
375
-- test this is fairly arbitrary.
376
- , [(DiagnosticSeverity_Warning , (2 , if ghcVersion >= GHC94 then 7 else 0 ), " Redundant constraint: Ord a" )
376
+ , [(DiagnosticSeverity_Warning , (2 , if ghcVersion >= GHC94 then 7 else 0 ), " Redundant constraint: Ord a" , Nothing )
377
377
]
378
378
)
379
379
]
@@ -439,7 +439,7 @@ tests = testGroup "diagnostics"
439
439
_ <- createDoc " Foo.hs" " haskell" fooContent
440
440
expectDiagnostics
441
441
[ ( " Foo.hs"
442
- , [(DiagnosticSeverity_Warning , (1 , 0 ), " Top-level binding with no type signature:" )
442
+ , [(DiagnosticSeverity_Warning , (1 , 0 ), " Top-level binding with no type signature:" , Nothing )
443
443
]
444
444
)
445
445
]
@@ -453,7 +453,7 @@ tests = testGroup "diagnostics"
453
453
_ <- createDoc " Foo.hs" " haskell" fooContent
454
454
expectDiagnostics
455
455
[ ( " Foo.hs"
456
- , [(DiagnosticSeverity_Warning , (3 , 0 ), " Defined but not used:" )
456
+ , [(DiagnosticSeverity_Warning , (3 , 0 ), " Defined but not used:" , Nothing )
457
457
]
458
458
)
459
459
]
@@ -469,13 +469,13 @@ tests = testGroup "diagnostics"
469
469
bdoc <- createDoc bPath " haskell" bSource
470
470
_pdoc <- createDoc pPath " haskell" pSource
471
471
expectDiagnostics
472
- [(" P.hs" , [(DiagnosticSeverity_Warning ,(4 ,0 ), " Top-level binding" )])] -- So that we know P has been loaded
472
+ [(" P.hs" , [(DiagnosticSeverity_Warning ,(4 ,0 ), " Top-level binding" , Nothing )])] -- So that we know P has been loaded
473
473
474
474
-- Change y from Int to B which introduces a type error in A (imported from P)
475
475
changeDoc bdoc [TextDocumentContentChangeEvent . InR . TextDocumentContentChangeWholeDocument $
476
476
T. unlines [" module B where" , " y :: Bool" , " y = undefined" ]]
477
477
expectDiagnostics
478
- [(" A.hs" , [(DiagnosticSeverity_Error , (5 , 4 ), " Couldn't match expected type 'Int' with actual type 'Bool'" )])
478
+ [(" A.hs" , [(DiagnosticSeverity_Error , (5 , 4 ), " Couldn't match expected type 'Int' with actual type 'Bool'" , Nothing )])
479
479
]
480
480
481
481
-- Open A and edit to fix the type error
@@ -485,8 +485,8 @@ tests = testGroup "diagnostics"
485
485
486
486
expectDiagnostics
487
487
[ ( " P.hs" ,
488
- [ (DiagnosticSeverity_Error , (4 , 6 ), " Couldn't match expected type 'Int' with actual type 'Bool'" ),
489
- (DiagnosticSeverity_Warning , (4 , 0 ), " Top-level binding" )
488
+ [ (DiagnosticSeverity_Error , (4 , 6 ), " Couldn't match expected type 'Int' with actual type 'Bool'" , Nothing ),
489
+ (DiagnosticSeverity_Warning , (4 , 0 ), " Top-level binding" , Nothing )
490
490
]
491
491
),
492
492
(" A.hs" , [] )
@@ -496,14 +496,14 @@ tests = testGroup "diagnostics"
496
496
, testWithDummyPluginEmpty " deduplicate missing module diagnostics" $ do
497
497
let fooContent = T. unlines [ " module Foo() where" , " import MissingModule" ]
498
498
doc <- createDoc " Foo.hs" " haskell" fooContent
499
- expectDiagnostics [(" Foo.hs" , [(DiagnosticSeverity_Error , (1 ,7 ), " Could not find module 'MissingModule'" )])]
499
+ expectDiagnostics [(" Foo.hs" , [(DiagnosticSeverity_Error , (1 ,7 ), " Could not find module 'MissingModule'" , Nothing )])]
500
500
501
501
changeDoc doc [TextDocumentContentChangeEvent . InR . TextDocumentContentChangeWholeDocument $ " module Foo() where" ]
502
502
expectDiagnostics []
503
503
504
504
changeDoc doc [TextDocumentContentChangeEvent . InR . TextDocumentContentChangeWholeDocument $ T. unlines
505
505
[ " module Foo() where" , " import MissingModule" ] ]
506
- expectDiagnostics [(" Foo.hs" , [(DiagnosticSeverity_Error , (1 ,7 ), " Could not find module 'MissingModule'" )])]
506
+ expectDiagnostics [(" Foo.hs" , [(DiagnosticSeverity_Error , (1 ,7 ), " Could not find module 'MissingModule'" , Nothing )])]
507
507
508
508
, testGroup " Cancellation"
509
509
[ cancellationTestGroup " edit header" editHeader yesSession noParse noTc
@@ -564,7 +564,7 @@ cancellationTemplate (edit, undoEdit) mbKey = testCase (maybe "-" fst mbKey) $ r
564
564
]
565
565
566
566
-- for the example above we expect one warning
567
- let missingSigDiags = [(DiagnosticSeverity_Warning , (3 , 0 ), " Top-level binding" ) ]
567
+ let missingSigDiags = [(DiagnosticSeverity_Warning , (3 , 0 ), " Top-level binding" , Nothing ) ]
568
568
typeCheck doc >> expectCurrentDiagnostics doc missingSigDiags
569
569
570
570
-- Now we edit the document and wait for the given key (if any)
0 commit comments