-
Notifications
You must be signed in to change notification settings - Fork 783
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
simplify the code for diagnostics severity adjustment #17896
base: main
Are you sure you want to change the base?
Conversation
|
Can somebody add the "no release notes" label? |
There you go, Martin :) Thanks for splitting the refactoring into a separate PR, that's always helpful. |
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.
Thank you, nice bit of cleanup.
A couple of nits, but other than that this is ready to go.
|
||
// We use the first line of the file as a fallbackRange for reporting unexpected errors. | ||
// Not ideal, but it's hard to see what else to do. | ||
let fallbackRange = rangeN mainInputFileName 1 | ||
let diagnostic = FSharpDiagnostic.CreateFromExceptionAndAdjustEof (diagnostic, severity, fallbackRange, fileInfo, suggestNames, flatErrors, symbolEnv) | ||
let diagnostic = FSharpDiagnostic.CreateFromExceptionAndAdjustEof (diagnostic, sev, fallbackRange, fileInfo, suggestNames, flatErrors, symbolEnv) |
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.
It was originally severity, we have always had problems with abbreviations in this codebase, in general avoid them, especially if they were originally unabbreviated.
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 didn't want to shadow the original severity. I'll make it adjustedSeverity
.
List.contains n options.WarnOn && not (List.contains n options.WarnOff) | ||
|
||
| FSharpDiagnosticSeverity.Hidden -> false | ||
member x.AdjustedSeverity(options, severity) = |
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.
Should it be AdjustSeverity?
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.
member x.AdjustSeverity
(,) sounds like changing the state of object x
, while it is just a pure function.
(Honestly, it shouldn't be a member at all. The whole type extensions doesn't look right. I might tackle that separately. )
Unless there are big objections, I will leave the name for now.
Description
This PR simplifies the code for adjusting diagnostics severity, without change to the functionality.
It will be needed for "scoped nowarn", where the adjustment logic becomes even more complex, but makes sense also in itself.