Skip to content

Support structured diagnostics 2 #4433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 76 commits into from
Jan 4, 2025
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
bd1404f
Change FileDiagnostic type synonym to a datatype
dylan-thinnes Jun 8, 2024
e684905
Make `ideErrorWithSource` produce FileDiagnostic by adding filepath arg
dylan-thinnes Jun 8, 2024
9d4cad1
Supply structured error wherever we easily can - TODOs for hard parts
dylan-thinnes Jun 9, 2024
e6a0b09
Fix UnitTests for new FileDiagnostic struct
dylan-thinnes Jun 9, 2024
d87c246
Remove explicit uses of FileDiagnostic, add codes to LSP diagnostics
dylan-thinnes Jun 9, 2024
cc2188c
Add field for expected error codes in ghcide tests
dylan-thinnes Jun 10, 2024
d2cbe55
Expect GHC-83865 for "type error" test - basic test
dylan-thinnes Jun 10, 2024
6e1eab7
Return structured warnings in TcModuleResult by copying from Driver
dylan-thinnes Jun 10, 2024
dcf9397
Store FileDiagnostic instead of LSP Diagnostic in Shake store
dylan-thinnes Jun 16, 2024
7bda67b
Add expected error codes for diagnostics that have them
dylan-thinnes Jun 16, 2024
6d1f0d7
Dispatch TODOs, amend remaining TODOs as future work
dylan-thinnes Jun 16, 2024
c92afae
Add scary comments all over copied code in Compat.Driver
dylan-thinnes Jun 16, 2024
b2fb63d
Update all remaining diagnostics that could use an expected error code
dylan-thinnes Jun 16, 2024
c6bc82d
Add _code to pretty printing for FileDiagnostic
dylan-thinnes Jun 16, 2024
9f5391b
Use case instead of `maybe` for StructuredMessage match
dylan-thinnes Jun 16, 2024
dd2229a
Use CPP to prevent setting _code before structured errors
dylan-thinnes Jun 16, 2024
094974d
Swap modifier for lenses, document StructuredMessage type
dylan-thinnes Jun 16, 2024
e948f2a
Add link to Issue & MR to Compat.Driver
dylan-thinnes Jun 16, 2024
79fd77e
Drop attachReason logic from withWarnings, technically incorrect
dylan-thinnes Jun 16, 2024
869edd6
Revert "Drop attachReason logic", needed by pragmas-plugin
dylan-thinnes Jun 16, 2024
1b2dd28
Fix plugins where necessary for new diagnostic structure
dylan-thinnes Jun 16, 2024
03c8409
Fix build issues with other tests from `expectDiagnostics`
dylan-thinnes Jun 16, 2024
2f83b0b
Improve comment on metadata fdStructuredMessage in FileDiagnostic
dylan-thinnes Jun 17, 2024
1cb1325
Add note to withWarnings explaining the current state of things
dylan-thinnes Jun 20, 2024
9337f25
Attach reasons into data field of LSP Diagnostic instead of code field
dylan-thinnes Jun 20, 2024
a857b9e
Fix up mistakes from merge, TODO fix merge issues for 9.3.0
dylan-thinnes Jun 20, 2024
14d6697
Set CodeDescription from HaskellErrorIndex when available
dylan-thinnes Jun 24, 2024
acbf1cb
Remove debugging print, fix expectation for preprocessor tests
dylan-thinnes Jun 27, 2024
413d1b8
Fix CPP for using Show instance on DiagnosticCode
dylan-thinnes Jun 27, 2024
926b6c4
Remove diagFromErrMsgs for GHC version < 9.6.1 using CPP
dylan-thinnes Jun 28, 2024
342b9fb
CPP fix
dylan-thinnes Jun 28, 2024
aaf5736
More stylish-haskell, more CPP fix
dylan-thinnes Jun 28, 2024
7215d80
Fix all stylish-haskell errors triggering
dylan-thinnes Jun 28, 2024
1a7856b
Fix more CPP
dylan-thinnes Jun 29, 2024
0a2174d
Only override the LSP diagnostic code when not already set
dylan-thinnes Jun 29, 2024
619098e
Fixes for stylish-haskell
dylan-thinnes Jun 29, 2024
361dd5b
Qualify s, t for FuzzySearch
dylan-thinnes Jun 29, 2024
1ec3db3
Ignore use of unsafePerformIO in FuzzySearch
dylan-thinnes Jun 29, 2024
ef5518f
Properly split GHC.Types.Error import in Diagnostics for stylish-haskell
dylan-thinnes Jun 30, 2024
45e77c7
Force type signature of annotation on FuzzySearch.dictionary
dylan-thinnes Jun 30, 2024
6ca2a19
DRY up definition of closure_errs
dylan-thinnes Jul 2, 2024
165e6b0
Remove unused imports
Oct 17, 2024
1047d55
Post-rebase fixes
Oct 17, 2024
a64120f
stylish-haskell formatting
Oct 17, 2024
1fed0f9
Fix issue with GHC 9.4
Oct 22, 2024
73bba51
Please stylish-haskell
Oct 22, 2024
6c9860c
Ignore error codes when testing GHC 9.4
Oct 22, 2024
c44a43d
Workaround darwin GHC bug in hls-hlint-plugin
Oct 23, 2024
1f835da
Put the workaround in the right place
Oct 23, 2024
1bc221c
Revert "Set CodeDescription from HaskellErrorIndex when available"
Oct 24, 2024
16551d1
Resolve fendor's feedback
Oct 24, 2024
5a6216b
Apply stylish-haskell formatting
Oct 24, 2024
4465f49
Apply more stylish-haskell formatting
Oct 24, 2024
79341ed
Merge branch 'master' into support-structured-diagnostics
soulomoon Oct 25, 2024
82367ec
Resolve some of soulomoon's feedback
Oct 25, 2024
ada484e
Fix small issues
Oct 25, 2024
6c05e23
Remove unused imports
Oct 26, 2024
0776c65
Remove StructuredDiagnostic
Oct 28, 2024
65300ef
Revert "Remove StructuredDiagnostic"
fendor Nov 21, 2024
649e2ba
Remove the unused parameter from 'ideErrorText'
fendor Nov 21, 2024
4c9e7a3
Add documentation to diagnostic helpers
fendor Nov 21, 2024
af34f06
Add action to query active diagnostics for a given Range
fendor Nov 30, 2024
92c8b4f
Use lens for updating Diagnostic
fendor Nov 30, 2024
d3b7fe6
Add GHC Structured Error compatibility module
fendor Nov 30, 2024
164dfe5
Remove unused imports
fendor Nov 30, 2024
31d1cee
Don't suggest -Wno-deferred-out-of-scope-variables (#4441)
jeukshi Nov 3, 2024
49b0ce1
Build HLS with GHC 9.8.3 (#4444)
fendor Nov 4, 2024
1feb07d
ci(mergify): upgrade configuration to current format (#4454)
mergify[bot] Nov 24, 2024
3ce3cfb
More tests and better docs for cabal-add (#4455)
VenInf Nov 25, 2024
54576e1
Fix compatibility with GHC 9.4 and rename function
fendor Dec 1, 2024
abd1a39
Use GHC Note syntax and reference Note in docs
fendor Dec 23, 2024
ada6ed6
Add doc comment for 'tmrWarnings'
fendor Dec 23, 2024
1398a0b
Push CPP statements to compatibility module
fendor Dec 23, 2024
95f65d9
Merge remote-tracking branch 'upstream/master' into support-structure…
fendor Dec 23, 2024
371896a
Fix formatting in Development.IDE.GHC.Compat.Error
fendor Dec 23, 2024
803067a
Merge branch 'master' into support-structured-diagnostics
fendor Dec 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix build issues with other tests from expectDiagnostics
dylan-thinnes authored and Jaro Reinders committed Oct 23, 2024

Verified

This commit was signed with the committer’s verified signature.
commit 03c840901d33ceea28a12329b0c20e154138a21e
2 changes: 1 addition & 1 deletion ghcide-bench/src/Experiments.hs
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ experiments =
flip allM docs $ \DocumentPositions{..} -> do
bottom <- pred . length . T.lines <$> documentContents doc
diags <- getCurrentDiagnostics doc
case requireDiagnostic diags (DiagnosticSeverity_Error, (fromIntegral bottom, 8), "Found hole", Nothing) of
case requireDiagnostic diags (DiagnosticSeverity_Error, (fromIntegral bottom, 8), "Found hole", Just "88464", Nothing) of
Nothing -> pure True
Just _err -> pure False
),
34 changes: 17 additions & 17 deletions plugins/hls-refactor-plugin/test/Main.hs
Original file line number Diff line number Diff line change
@@ -1996,7 +1996,7 @@ suggestImportDisambiguationTests = testGroup "suggest import disambiguation acti
compareHideFunctionTo = compareTwo "HideFunction.hs"
withTarget file locs k = runWithExtraFiles "hiding" $ \dir -> do
doc <- openDoc file "haskell"
void $ expectDiagnostics [(file, [(DiagnosticSeverity_Error, loc, "Ambiguous occurrence") | loc <- locs])]
void $ expectDiagnostics [(file, [(DiagnosticSeverity_Error, loc, "Ambiguous occurrence", Nothing) | loc <- locs])] -- TODO: Give this a proper error
actions <- getAllCodeActions doc
k dir doc actions
withHideFunction = withTarget ("HideFunction" <.> "hs")
@@ -2455,7 +2455,7 @@ deleteUnusedDefinitionTests = testGroup "delete unused definition action"
where
testFor sourceLines pos@(l,c) expectedTitle expectedLines = do
docId <- createDoc "A.hs" "haskell" $ T.unlines sourceLines
expectDiagnostics [ ("A.hs", [(DiagnosticSeverity_Warning, pos, "not used")]) ]
expectDiagnostics [ ("A.hs", [(DiagnosticSeverity_Warning, pos, "not used", Nothing)]) ]
action <- pickActionWithTitle expectedTitle =<< getCodeActions docId (R l c l c)
executeCodeAction action
contentAfterAction <- documentContents docId
@@ -2471,8 +2471,8 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
, "f = 1"
]
(if ghcVersion >= GHC94
then [ (DiagnosticSeverity_Warning, (3, 4), "Defaulting the type variable") ]
else [ (DiagnosticSeverity_Warning, (3, 4), "Defaulting the following constraint") ])
then [ (DiagnosticSeverity_Warning, (3, 4), "Defaulting the type variable", Nothing) ]
else [ (DiagnosticSeverity_Warning, (3, 4), "Defaulting the following constraint", Nothing) ])
"Add type annotation ‘Integer’ to ‘1’"
[ "{-# OPTIONS_GHC -Wtype-defaults #-}"
, "module A (f) where"
@@ -2490,8 +2490,8 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
, " in x"
]
(if ghcVersion >= GHC94
then [ (DiagnosticSeverity_Warning, (4, 12), "Defaulting the type variable") ]
else [ (DiagnosticSeverity_Warning, (4, 12), "Defaulting the following constraint") ])
then [ (DiagnosticSeverity_Warning, (4, 12), "Defaulting the type variable", Nothing) ]
else [ (DiagnosticSeverity_Warning, (4, 12), "Defaulting the following constraint", Nothing) ])
"Add type annotation ‘Integer’ to ‘3’"
[ "{-# OPTIONS_GHC -Wtype-defaults #-}"
, "module A where"
@@ -2510,8 +2510,8 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
, " in x"
]
(if ghcVersion >= GHC94
then [ (DiagnosticSeverity_Warning, (4, 20), "Defaulting the type variable") ]
else [ (DiagnosticSeverity_Warning, (4, 20), "Defaulting the following constraint") ])
then [ (DiagnosticSeverity_Warning, (4, 20), "Defaulting the type variable", Nothing) ]
else [ (DiagnosticSeverity_Warning, (4, 20), "Defaulting the following constraint", Nothing) ])
"Add type annotation ‘Integer’ to ‘5’"
[ "{-# OPTIONS_GHC -Wtype-defaults #-}"
, "module A where"
@@ -2532,12 +2532,12 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
]
(if ghcVersion >= GHC94
then
[ (DiagnosticSeverity_Warning, (6, 8), "Defaulting the type variable")
, (DiagnosticSeverity_Warning, (6, 16), "Defaulting the type variable")
[ (DiagnosticSeverity_Warning, (6, 8), "Defaulting the type variable", Nothing)
, (DiagnosticSeverity_Warning, (6, 16), "Defaulting the type variable", Nothing)
]
else
[ (DiagnosticSeverity_Warning, (6, 8), "Defaulting the following constraint")
, (DiagnosticSeverity_Warning, (6, 16), "Defaulting the following constraint")
[ (DiagnosticSeverity_Warning, (6, 8), "Defaulting the following constraint", Nothing)
, (DiagnosticSeverity_Warning, (6, 16), "Defaulting the following constraint", Nothing)
])
"Add type annotation ‘String’ to ‘\"debug\""
[ "{-# OPTIONS_GHC -Wtype-defaults #-}"
@@ -2559,8 +2559,8 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
, "f a = traceShow \"debug\" a"
]
(if ghcVersion >= GHC94
then [ (DiagnosticSeverity_Warning, (6, 6), "Defaulting the type variable") ]
else [ (DiagnosticSeverity_Warning, (6, 6), "Defaulting the following constraint") ])
then [ (DiagnosticSeverity_Warning, (6, 6), "Defaulting the type variable", Nothing) ]
else [ (DiagnosticSeverity_Warning, (6, 6), "Defaulting the following constraint", Nothing) ])
"Add type annotation ‘String’ to ‘\"debug\""
[ "{-# OPTIONS_GHC -Wtype-defaults #-}"
, "{-# LANGUAGE OverloadedStrings #-}"
@@ -2581,8 +2581,8 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
, "f = seq (\"debug\" :: [Char]) (seq (\"debug\" :: [Char]) (traceShow \"debug\"))"
]
(if ghcVersion >= GHC94
then [ (DiagnosticSeverity_Warning, (6, 54), "Defaulting the type variable") ]
else [ (DiagnosticSeverity_Warning, (6, 54), "Defaulting the following constraint") ])
then [ (DiagnosticSeverity_Warning, (6, 54), "Defaulting the type variable", Nothing) ]
else [ (DiagnosticSeverity_Warning, (6, 54), "Defaulting the following constraint", Nothing) ])
"Add type annotation ‘String’ to ‘\"debug\""
[ "{-# OPTIONS_GHC -Wtype-defaults #-}"
, "{-# LANGUAGE OverloadedStrings #-}"
@@ -2597,7 +2597,7 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
testFor sourceLines diag expectedTitle expectedLines = do
docId <- createDoc "A.hs" "haskell" $ T.unlines sourceLines
expectDiagnostics [ ("A.hs", diag) ]
let cursors = map snd3 diag
let cursors = map (\(_, snd, _, _) -> snd) diag
(ls, cs) = minimum cursors
(le, ce) = maximum cursors

6 changes: 3 additions & 3 deletions test/functional/Config.hs
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ genericConfigTests = testGroup "generic plugin config"
expectDiagnostics standardDiagnostics
]
where
standardDiagnostics = [("Foo.hs", [(DiagnosticSeverity_Warning, (1,0), "Top-level binding")])]
testPluginDiagnostics = [("Foo.hs", [(DiagnosticSeverity_Error, (0,0), "testplugin")])]
standardDiagnostics = [("Foo.hs", [(DiagnosticSeverity_Warning, (1,0), "Top-level binding", Nothing)])]
testPluginDiagnostics = [("Foo.hs", [(DiagnosticSeverity_Error, (0,0), "testplugin", Nothing)])]

runConfigSession subdir session = do
failIfSessionTimeout $
@@ -90,7 +90,7 @@ genericConfigTests = testGroup "generic plugin config"
files <- getFilesOfInterestUntracked
void $ uses_ GetTestDiagnostics $ HM.keys files
define mempty $ \GetTestDiagnostics file -> do
let diags = [ideErrorText file "testplugin"]
let diags = [ideErrorText Nothing file "testplugin"]
return (diags,Nothing)
}
-- A config that disables the plugin initially