Skip to content

[READY] Print diagnostic code field #1239

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 1 commit into from
Jun 26, 2019

Conversation

kadircet
Copy link
Contributor

@kadircet kadircet commented Apr 26, 2019

Clangd started populating diagnostic's code field with relevant information with https://reviews.llvm.org/D60822 and https://reviews.llvm.org/D58291.

This patch aims to surface that information to ycmd users, as vscode does.


This change is Reviewable

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: 1 of 2 LGTMs obtained

Copy link
Collaborator

@micbou micbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Looks good but I think it would be better to extend our diagnostic API with a code field and do the formatting on the client side.

Reviewed 2 of 2 files at r1.
Reviewable status: 1 of 2 LGTMs obtained

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@micbou Does that really matter?

Reviewable status: 1 of 2 LGTMs obtained

Copy link
Contributor Author

@kadircet kadircet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think clients would benefit more in that case. Because I would expect all of them to simply append this to diag text. In addition to that it would also require clients to be modified as well, which makes things a little bit more complicated.

Reviewable status: 1 of 2 LGTMs obtained

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree that just putting it in the text is fine. We have filtering etc. that applies only to the text.

However, it's not obvious to me why we're only doing this for non-floating-point errors. Wouldn't it be simpler to just always include it?

Reviewable status: 1 of 2 LGTMs obtained

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @kadircet)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

      float( code )
    except ValueError:
      # We are only interested in non-number codes.

why is that?

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 LGTMs obtained (waiting on @puremourning)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

why is that?

IIRC, this is supposed to be presented to users, something like appending [-Wwarning-name] to a diagnostic. If the name is some sort of number, because the server (stupidly) exposes internal IDs, we would end up appending [123]. I can hear the confusion of the users going "WAT?".

In short, using numbers just adds verbosity, but doesn't provide any useful information.

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, bstaletic (Boris Staletic) wrote…

IIRC, this is supposed to be presented to users, something like appending [-Wwarning-name] to a diagnostic. If the name is some sort of number, because the server (stupidly) exposes internal IDs, we would end up appending [123]. I can hear the confusion of the users going "WAT?".

In short, using numbers just adds verbosity, but doesn't provide any useful information.

unless the particular compiler/language uses numbers to represent error codes. I've seen plenty of those. Anyway i suppose we could revisit that if necessary.

Checking the specification, the type of 'message' is 'number | string', so this check rather than being "convertible" to string, should be "is-a" string, i.e. isinstance( code, str )

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 LGTMs obtained (waiting on @kadircet)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

unless the particular compiler/language uses numbers to represent error codes. I've seen plenty of those. Anyway i suppose we could revisit that if necessary.

Checking the specification, the type of 'message' is 'number | string', so this check rather than being "convertible" to string, should be "is-a" string, i.e. isinstance( code, str )

I also believe @kadircet said JDT sends something like {"code": "123"}, thus sending numbers as strings.

Copy link
Contributor Author

@kadircet kadircet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 LGTMs obtained (waiting on @puremourning)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, bstaletic (Boris Staletic) wrote…

I also believe @kadircet said JDT sends something like {"code": "123"}, thus sending numbers as strings.

yes, IIRC there were breakages inside jdt.ls tests, since they were representing numbers with strings.

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic and @kadircet)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, kadircet (kadir çetinkaya) wrote…

yes, IIRC there were breakages inside jdt.ls tests, since they were representing numbers with strings.

Are we sure that the numbers are not useful/meaningful to java developers ? Would users not want to use those numbers for filtering ?

Copy link
Contributor Author

@kadircet kadircet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they looked arbitrary with 8+ digits, I am not sure anyone has that good memory :D
I just thought it might annoy users to see those digits, but it is totally ok for me to surface them as well

Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic and @kadircet)

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK well let's go with this and we can expand later if there's a request to.

:lgtm:

Reviewable status: :shipit: complete! 2 of 2 LGTMs obtained (waiting on @bstaletic and @kadircet)

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 2 of 2 LGTMs obtained (waiting on @bstaletic and @kadircet)

@puremourning
Copy link
Member

@kadircet can you rebase and push the PR ? It still has the old CI system on the commit checks !

@codecov
Copy link

codecov bot commented Jun 21, 2019

Codecov Report

Merging #1239 into master will increase coverage by 0.04%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1239      +/-   ##
==========================================
+ Coverage   97.14%   97.18%   +0.04%     
==========================================
  Files          95       96       +1     
  Lines        7343     7243     -100     
  Branches      153        0     -153     
==========================================
- Hits         7133     7039      -94     
- Misses        169      204      +35     
+ Partials       41        0      -41

1 similar comment
@codecov
Copy link

codecov bot commented Jun 21, 2019

Codecov Report

Merging #1239 into master will increase coverage by 0.04%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1239      +/-   ##
==========================================
+ Coverage   97.14%   97.18%   +0.04%     
==========================================
  Files          95       96       +1     
  Lines        7343     7243     -100     
  Branches      153        0     -153     
==========================================
- Hits         7133     7039      -94     
- Misses        169      204      +35     
+ Partials       41        0      -41

@puremourning
Copy link
Member

Tests are failing on RLS

@kadircet
Copy link
Contributor Author

yup just saw. I believe rust was not merged when I've written the patch?

They appear to be reporting codes like 'E0609', I have no idea whether they are meaningful or not. Anyone knows if these are worth keeping ?

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theli-ua Can you make sense of diagnostic code E0609?

Reviewed 2 of 2 files at r2.
Reviewable status: 0 of 2 LGTMs obtained (and 2 stale) (waiting on @puremourning)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

Are we sure that the numbers are not useful/meaningful to java developers ? Would users not want to use those numbers for filtering ?

Filtering! That might be a good reason to just flat out pass anything, even [123].

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 LGTMs obtained (and 2 stale) (waiting on @bstaletic and @kadircet)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, bstaletic (Boris Staletic) wrote…

Filtering! That might be a good reason to just flat out pass anything, even [123].

Yeah.. that was my point :)

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 LGTMs obtained (and 2 stale) (waiting on @puremourning)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

Yeah.. that was my point :)

@kadircet Is there any problem with just always adding the code to the diagnostic? It would make it much easier for users to filter diagnostics if they need to and it would fix the tests.

@codecov-io
Copy link

codecov-io commented Jun 26, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@f16d443). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #1239   +/-   ##
=========================================
  Coverage          ?   97.18%           
=========================================
  Files             ?       96           
  Lines             ?     7243           
  Branches          ?        0           
=========================================
  Hits              ?     7039           
  Misses            ?      204           
  Partials          ?        0

Copy link
Contributor Author

@kadircet kadircet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 LGTMs obtained (and 2 stale) (waiting on @bstaletic and @puremourning)


ycmd/completers/language_server/language_server_completer.py, line 2181 at r1 (raw file):

Previously, bstaletic (Boris Staletic) wrote…

@kadircet Is there any problem with just always adding the code to the diagnostic? It would make it much easier for users to filter diagnostics if they need to and it would fix the tests.

Done

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tests fail, a rebase will be necessary, but otherwise :lgtm_strong:

Reviewed 3 of 3 files at r3.
Reviewable status: 1 of 2 LGTMs obtained (and 1 stale) (waiting on @puremourning)

Copy link
Collaborator

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 LGTMs obtained (and 1 stale) (waiting on @kadircet and @puremourning)


ycmd/completers/language_server/language_server_completer.py, line 2244 at r3 (raw file):

  try:
    code = diag[ 'code' ]
    diag_text += " [" + code + "]"

code needs to be str( code )

Copy link
Contributor Author

@kadircet kadircet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 LGTMs obtained (and 1 stale) (waiting on @bstaletic and @puremourning)


ycmd/completers/language_server/language_server_completer.py, line 2244 at r3 (raw file):

Previously, bstaletic (Boris Staletic) wrote…

code needs to be str( code )

Done.

@kadircet kadircet changed the title Print diagnostic code field if it is non-number [READY] Print diagnostic code field Jun 26, 2019
@puremourning
Copy link
Member

Latest master should be more flake-free. So maybe one more rebase ?

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 3 files at r3, 3 of 3 files at r4.
Reviewable status: :shipit: complete! 2 of 2 LGTMs obtained (waiting on @bstaletic)

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r5.
Reviewable status: :shipit: complete! 2 of 2 LGTMs obtained (waiting on @bstaletic)

@mergify mergify bot merged commit 6eef083 into ycm-core:master Jun 26, 2019
@mergify
Copy link
Contributor

mergify bot commented Jun 26, 2019

Thanks for sending a PR!

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Jun 26, 2019

Thanks for sending a PR!

@kadircet kadircet deleted the clangd_diag_code branch June 27, 2019 08:38
bstaletic added a commit to bstaletic/YouCompleteMe that referenced this pull request Jul 3, 2019
ycm-core/ycmd#1275 Remap python GoTo* commands
ycm-core/ycmd#1274 Migrate to Omnisharp-Roslyn
ycm-core/ycmd#1239 Error ID in diagnostic messages
ycm-core/ycmd#1267 Clangd extra conf support
ycm-core/ycmd#1266 JDT update to 0.40.0
ycm-core/ycmd#1245 Generic (pluggable) LSP completer support
ycm-core/ycmd#1263 Support JDT extensions
ycm-core/ycmd#1261 Typescript update
ycm-core/ycmd#1264 [vimspector](/puremourning/vimspector) configuration
ycm-core/ycmd#1262 Multi-user installation
ycm-core/ycmd#1243 Migrate to GOPLS
ycm-core/ycmd#1249 Support MSVC 16 (VS2019)
ycm-core/ycmd#1224 Migrate to RLS
bstaletic added a commit to bstaletic/YouCompleteMe that referenced this pull request Jul 4, 2019
ycm-core/ycmd#1275 Remap python GoTo* commands
ycm-core/ycmd#1274 Migrate to Omnisharp-Roslyn
ycm-core/ycmd#1239 Error ID in diagnostic messages
ycm-core/ycmd#1267 Clangd extra conf support
ycm-core/ycmd#1266 JDT update to 0.40.0
ycm-core/ycmd#1245 Generic (pluggable) LSP completer support
ycm-core/ycmd#1263 Support JDT extensions
ycm-core/ycmd#1261 Typescript update
ycm-core/ycmd#1264 [vimspector](/puremourning/vimspector) configuration
ycm-core/ycmd#1262 Multi-user installation
ycm-core/ycmd#1243 Migrate to GOPLS
ycm-core/ycmd#1249 Support MSVC 16 (VS2019)
ycm-core/ycmd#1224 Migrate to RLS
bstaletic added a commit to bstaletic/YouCompleteMe that referenced this pull request Jul 4, 2019
ycm-core/ycmd#1275 Remap python GoTo* commands
ycm-core/ycmd#1274 Migrate to Omnisharp-Roslyn
ycm-core/ycmd#1239 Error ID in diagnostic messages
ycm-core/ycmd#1267 Clangd extra conf support
ycm-core/ycmd#1266 JDT update to 0.40.0
ycm-core/ycmd#1245 Generic (pluggable) LSP completer support
ycm-core/ycmd#1263 Support JDT extensions
ycm-core/ycmd#1261 Typescript update
ycm-core/ycmd#1264 [vimspector](/puremourning/vimspector) configuration
ycm-core/ycmd#1262 Multi-user installation
ycm-core/ycmd#1243 Migrate to GOPLS
ycm-core/ycmd#1249 Support MSVC 16 (VS2019)
ycm-core/ycmd#1224 Migrate to RLS
bstaletic added a commit to bstaletic/YouCompleteMe that referenced this pull request Jul 4, 2019
ycm-core/ycmd#1275 Remap python GoTo* commands
ycm-core/ycmd#1274 Migrate to Omnisharp-Roslyn
ycm-core/ycmd#1239 Error ID in diagnostic messages
ycm-core/ycmd#1267 Clangd extra conf support
ycm-core/ycmd#1266 JDT update to 0.40.0
ycm-core/ycmd#1245 Generic (pluggable) LSP completer support
ycm-core/ycmd#1263 Support JDT extensions
ycm-core/ycmd#1261 Typescript update
ycm-core/ycmd#1264 [vimspector](/puremourning/vimspector) configuration
ycm-core/ycmd#1262 Multi-user installation
ycm-core/ycmd#1243 Migrate to GOPLS
ycm-core/ycmd#1249 Support MSVC 16 (VS2019)
ycm-core/ycmd#1224 Migrate to RLS
bstaletic added a commit to bstaletic/YouCompleteMe that referenced this pull request Jul 5, 2019
ycm-core/ycmd#1275 Remap python GoTo* commands
ycm-core/ycmd#1274 Migrate to Omnisharp-Roslyn
ycm-core/ycmd#1239 Error ID in diagnostic messages
ycm-core/ycmd#1267 Clangd extra conf support
ycm-core/ycmd#1266 JDT update to 0.40.0
ycm-core/ycmd#1245 Generic (pluggable) LSP completer support
ycm-core/ycmd#1263 Support JDT extensions
ycm-core/ycmd#1261 Typescript update
ycm-core/ycmd#1264 [vimspector](/puremourning/vimspector) configuration
ycm-core/ycmd#1262 Multi-user installation
ycm-core/ycmd#1243 Migrate to GOPLS
ycm-core/ycmd#1249 Support MSVC 16 (VS2019)
ycm-core/ycmd#1224 Migrate to RLS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants