This is an archive of the discontinued LLVM Phabricator instance.

[clangd] capitalize diagnostic messages
ClosedPublic

Authored by arphaman on Aug 1 2018, 12:36 PM.

Details

Summary

This patch adds support for diagnostic message capitalization to Clangd. The diagnostic messages are now always capitalized.

Diff Detail

Event Timeline

arphaman created this revision.Aug 1 2018, 12:36 PM
ioeric added a comment.Aug 2 2018, 3:00 AM

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?

ioeric added a comment.Aug 2 2018, 4:52 AM

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 :)

simark added a comment.Aug 2 2018, 5:19 AM

That's fine with me. I'll try it and time will tell if I like it or not :).

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

simark added a comment.Aug 2 2018, 6:51 AM

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

Agreed.

Seems we have consensus here.
Let's remove the option and just always capitalize the messages.

arphaman updated this revision to Diff 159036.Aug 3 2018, 10:19 AM

Always capitalize the diagnostic's message.

ioeric added inline comments.Aug 3 2018, 10:33 AM
test/clangd/capitalize-diagnostics.test
1

This new test doesn't seem to be needed anymore?

arphaman updated this revision to Diff 159059.Aug 3 2018, 11:18 AM
arphaman marked an inline comment as done.

Remove test and update unit test.

test/clangd/capitalize-diagnostics.test
1

Right, the note message is exercised by the unit test, which I didn't update. Updated it now.

ioeric accepted this revision.Aug 3 2018, 11:25 AM

lgtm

clangd/Diagnostics.cpp
149

nit: this doesn't have to be diagnostic text, so I'd probably call this capitalize().

This revision is now accepted and ready to land.Aug 3 2018, 11:25 AM

nit: The patch description needs to be updated.

arphaman retitled this revision from [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided to [clangd] capitalize diagnostic messages.Aug 3 2018, 12:38 PM
arphaman edited the summary of this revision. (Show Details)
arphaman marked an inline comment as done.Aug 3 2018, 1:43 PM
This revision was automatically updated to reflect the committed changes.

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)

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

What's the motivation for clangd to differ from clang here?

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: