-
Notifications
You must be signed in to change notification settings - Fork 824
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
Hidden DiagnosticSeverity? #325
Comments
FWIW, |
I stand corrected! 👍 |
This is the idea of the hint severity which for example we in VS Code don't render in the UI as squiggles. Would that work for you. |
@dbaemer, IIRC, that still causes the diagnostic to appear in the VS Code Problems list. When we used "hint" and that happened, we received a lot of complaints. |
@DustinCampbell that is correct. Reason was that hint are often inserted for code actions and people want to trigger them from the problems view. So when exactly would you put a hidden severity on something. They aren't trustable anyways so when the server executes a specific functions diagnostics must be recomputed. |
Hidden diagnostics are used within Roslyn to improve the user experience by indicating spans where a code action should appear but the diagnostic squiggle appears elsewhere. Here are a couple of examples where we've used hidden diagnostics:
interface IB
{
void M1();
}
interface IC
{
void M2();
}
class A : IB, IC
{
} In the code above, we want the user to be able to use a code action to implement an interface from the name of |
@jrieken have you heard of such a request in your land as well ? @DustinCampbell So you basically use them as markers for code action trigger (showing for example the light bulb). What kind of diagnostic severities does Roslyn support. |
Roslyn supports the following severities with the given behavior in Visual Studio.
In addition, Roslyn can provide additional presentation, such as fading code, which is orthogonal to the severities above. |
Kind of... I know that Roslyn uses that trick and it would work for us because we forward diagnostics to the code action provider. Tho, it does feel a little weird and complicated for just sending information from one part of the system to another... Especially given our open approach, so a |
@jrieken : I'm not sure I understand that last bit. What is the "open approach"? Note that, in Roslyn, a |
FWIW, I agree that hidden diagnostics are weird in general. Really, their trigger points for particular code actions. IMO, this should have been handled differently in Roslyn. |
In VS Code you register your project for a language but not more fine grained. They call have access to the same set of diagnostics. Basically those that intersect the range being asked for... |
Yup! it's not that really that big of a deal, but "hidden" diagnostics are even weirder in VS Code. It's like seeing private implementation bits. Is there some other mechanism we would map to in LSP to achieve a similar user experience to what I described above? |
Two things:
|
Perhaps I'm misunderstanding, but Roslyn code actions are driven off of diagnostics, so they couldn't be completely disconnected. In VS, I believe we force diagnostics to recompute when Roslyn is queried for code actions. So, everything is up-to-date before we even return anything. Of course, the same arguments about diagnostic not being trustworthy applies to code actions as well doesn't it? Just because a code action has been returned, there's no guarantee that running it is valid. |
This is true and given all the async behavior it can't be fully guaranteed to be correct except we always include ALL open document version is edit requests. However to make the window as small as possible I implement that in the following way in my servers:
This still leaves room that editing another file would have invalidated a code action. However that approach doesn't apply invalid edits to an open document. |
That seems reasonable. You shouldn't trust diagnostics 😄 and having a validation step before a code action is applied is the right thing IMO. We do something similar in Roslyn. Because we have an immutable snapshot model for what is effectively the entire workspace, we can version the contents of the entire workspace, not just each document. So, when a code action is applied, Roslyn checks to see if the workspace has the same version that the code action was created for and fails if the version has changed. |
Summary: This adds support for language servers to return "hint"-level diagnostics. These are intended to be hidden in the editor under most circumstances, and used to drive refactorings: microsoft/language-server-protocol#325 Reviewed By: kcaze Differential Revision: D13123342 fbshipit-source-id: 1491f9a4bdadba2a3ef064bbf2aa70145b01d7f7
Roslyn has a hidden diagnostic severity that's used to fade out text when they can be optional removed. Things like unused usings, or when
this.
is not required.It would be great to have a way to say a diagnostic is hidden for LSP servers.
The text was updated successfully, but these errors were encountered: