ycm-core / ycmd

A code-completion & code-comprehension server
https://ycm-core.github.io/ycmd/
GNU General Public License v3.0
1.69k stars 764 forks source link

Sort diagnostics according to severity for detailed diag responses #1728

Closed bstaletic closed 6 months ago

bstaletic commented 8 months ago

Users are more likely to be interested in errors than warnings in /detailed_diagnostic responses. That means we need to sort the diagnostics before finding the one nearest to the cursor.

For LSP completers, that's easy as the severity is numerical. For Omnisharp-roslyn and TSServer, the severity is a word and we can't just say sort( key = severity ).

Since LSP severity was convenient for comparison, I have opted for sorting C# and TS diags by the equivalent LSP severity.


This change is Reviewable

codecov[bot] commented 8 months ago

Codecov Report

Merging #1728 (5fb0927) into master (0ce532e) will increase coverage by 0.40%. The diff coverage is 66.66%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1728 +/- ## ========================================== + Coverage 95.05% 95.46% +0.40% ========================================== Files 51 83 +32 Lines 6711 8194 +1483 Branches 0 163 +163 ========================================== + Hits 6379 7822 +1443 + Misses 332 322 -10 - Partials 0 50 +50 ```
bstaletic commented 8 months ago

According to the coverage data, we're only ever dealing with errors in our tests, at least for C# and TS.

puremourning commented 8 months ago

Don't we just need some code which produces a warning and error on the same line.

I think clangd does this. maybe something like:

int x;
if ( x = 2 )
{
}

With -Wno-error -Werror=uninitialized

mergify[bot] commented 6 months ago

Thanks for sending a PR!