This patch adds support for diagnostic message capitalization to Clangd. The diagnostic messages are now always capitalized.
Details
Diff Detail
- Repository
- rCTE Clang Tools Extra
Event Timeline
Is it possible for clangd to always capitalize diagnostics if -capitialize-diagnostic-text is found in the compile comand?
Maybe we could simply always capitalize the messages? Any cons to capitalizing error messages?
@simark, @malaperle, @ioeric, @hokein, WDYT?
Oh sorry, I thought -capitialize-diagnostic-text was an existing clang flag, in which case we should respect it. I don't think there is any con that I could think of, as long as it looks nice in clients :)
Capitalizing sounds nice. +1 to just do it without an option.
My favorite essay on this is
http://neugierig.org/software/blog/2018/07/options.html
Seems we have consensus here.
Let's remove the option and just always capitalize the messages.
test/clangd/capitalize-diagnostics.test | ||
---|---|---|
2 | This new test doesn't seem to be needed anymore? |
Remove test and update unit test.
test/clangd/capitalize-diagnostics.test | ||
---|---|---|
2 | Right, the note message is exercised by the unit test, which I didn't update. Updated it now. |
lgtm
clangd/Diagnostics.cpp | ||
---|---|---|
149 | nit: this doesn't have to be diagnostic text, so I'd probably call this capitalize(). |
What's the motivation for clangd to differ from clang here? (& if the first
letter is going to be capitalized, should there be a period at the end? But
also the phrasing of most/all diagnostic text isn't in the form of complete
sentences, so this might not make sense)
It's mostly for the presentation purposes, to match the needs of our client. I first implemented it as an opt-in feature, but the consensus was to capitalize the messages all the time.
I don't think it would make sense to insert the period at the end, because, as you said, not all diagnostics are complete sentences
The presentation of diagnostics to the users is different between clang and clangd:
- clang diagnostics are always prefixed with the file, location and severity of the diagnostic, e.g. main.cpp:1:2: error: expected '}'
- In LSP clients (VSCode in particular), the diagnostic message is the first thing the user sees and it looks a little nicer (subjectively) if the first letter is capitalized.
See the screenshots from VSCode on how diagnostics are presented:
nit: this doesn't have to be diagnostic text, so I'd probably call this capitalize().