-
Notifications
You must be signed in to change notification settings - Fork 97
Conversation
Awesome! One question - I usually don't turn off unused variables, just unused top-level bindings. It would be great to still get the grey color. Could we always turn these warnings on, but suppress them from making it to the diagnostics if we turned them on rather than the user? |
That sounds like a good idea, it shouldn't be more difficult than the |
It took a bit more than expected, mostly because some tests broke because of that. In fact, locally all the benchmarks fail for me, but I haven't been able to fix them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!
src/Development/IDE/Core/Compile.hs
Outdated
| not (wopt warning originalFlags) | ||
= if warning `elem` unnecessaryDeprecationWarningFlags | ||
then (Reason warning, (nfp, sh, fd{_severity = Just DsInfo})) | ||
else (Reason warning, (nfp, HideDiag, fd)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume HideDiag means they don't appear at all? Could you just look at _tags ahd only Hide the ones with no tags? (I've no idea here, somewhat guessing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a good idea: make those with tags "less important" but not hide them.
Implemented in the latest commit.
, Opt_WarnWarningsDeprecations | ||
] | ||
|
||
tagDiag :: (WarnReason, FileDiagnostic) -> (WarnReason, FileDiagnostic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we get a comment on what this does and why? (From the code, its clear, but nice to be able to eyeball it without reading the code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment to the file:
-- | Add a unnecessary/deprecated tag to the required diagnostics.
test/src/Development/IDE/Test.hs
Outdated
= expectDiagnostics_ . map (\(fp, dd) -> (fp, map (\(ds, c, t) -> (ds, c, t, Nothing)) dd)) | ||
|
||
expectDiagnostics_ :: [(FilePath, [(DiagnosticSeverity, Cursor, T.Text, Maybe DiagnosticTag)])] -> Session () | ||
expectDiagnostics_ expected = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ususally foo_
would be the version of foo
that does slightly less than foo
, e.g. doesn't return some info. Could we call expectDiagnostics_
something like expectedDiagnosticsTags
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it to expectDiagnosticsWithTags
.
test/exe/Main.hs
Outdated
@@ -3065,6 +3083,8 @@ ifaceErrorTest = testCase "iface-error-test-1" $ withoutStackEnv $ runWithExtraF | |||
-- - P is being typechecked with the last successful artifacts for A. | |||
expectDiagnostics [("P.hs", [(DsWarning,(4,0), "Top-level binding")]) | |||
,("P.hs", [(DsWarning,(6,0), "Top-level binding")]) | |||
,("P.hs", [(DsInfo,(4,0), "Defined but not used")]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The really important thing is that these diagnostics have the right tag associated with them. While they don't all need to be expectDiagnostics_
(or whatever it ends up being called), a few more being that with the tag assertion would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I've extended the checks in the latest commit.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
I see some test failure:
I did have to fix a merge conflict to get it going again. So certainly possible that's my fault. |
I've spent some time and fixed the test. Hopefully everything should be green in some minutes. |
Awesome work - this is a great feature. Thanks for all your hard to work to write it and adjust so much of the test suite. |
* Tag unused warning as such * Fix compilation for 8.4 * Always enable warning for unneeded elements + fix tests for them * Apply suggestions by @ndmitchell * Fix a diagnostics test after merge Co-authored-by: Neil Mitchell <[email protected]>
* Tag unused warning as such * Fix compilation for 8.4 * Always enable warning for unneeded elements + fix tests for them * Apply suggestions by @ndmitchell * Fix a diagnostics test after merge Co-authored-by: Neil Mitchell <[email protected]>
* Tag unused warning as such * Fix compilation for 8.4 * Always enable warning for unneeded elements + fix tests for them * Apply suggestions by @ndmitchell * Fix a diagnostics test after merge Co-authored-by: Neil Mitchell <[email protected]>
* Tag unused warning as such * Fix compilation for 8.4 * Always enable warning for unneeded elements + fix tests for them * Apply suggestions by @ndmitchell * Fix a diagnostics test after merge Co-authored-by: Neil Mitchell <[email protected]>
This patch uses the new "unnecessary" or "deprecated" tags for diagnostics to show unused variables/functions/... dimmed in the editor, as discussed in https://github.com/haskell/ghcide/issues/165#issuecomment-692532054