summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Diagnostics.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2018-08-03 20:43:28 +0000
committerAlex Lorenz <arphaman@gmail.com>2018-08-03 20:43:28 +0000
commitb411cf327528a561b94f247aab7f1a520e1685ed (patch)
tree8ee69400fb03771d0c671e2011bb3190374c2358 /clang-tools-extra/clangd/Diagnostics.cpp
parentbfd9cfdeeb20c0c48c71447140ca0cdc55b7b5dd (diff)
downloadbcm5719-llvm-b411cf327528a561b94f247aab7f1a520e1685ed.tar.gz
bcm5719-llvm-b411cf327528a561b94f247aab7f1a520e1685ed.zip
[clangd] capitalize diagnostic messages
The diagnostic messages that are sent to the client from Clangd are now always capitalized. Differential Revision: https://reviews.llvm.org/D50154 llvm-svn: 338919
Diffstat (limited to 'clang-tools-extra/clangd/Diagnostics.cpp')
-rw-r--r--clang-tools-extra/clangd/Diagnostics.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp
index 73ac475efef..5a61567f2dc 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -145,6 +145,13 @@ void printDiag(llvm::raw_string_ostream &OS, const DiagBase &D) {
OS << diagLeveltoString(D.Severity) << ": " << D.Message;
}
+/// Capitalizes the first word in the diagnostic's message.
+std::string capitalize(std::string Message) {
+ if (!Message.empty())
+ Message[0] = llvm::toUpper(Message[0]);
+ return Message;
+}
+
/// Returns a message sent to LSP for the main diagnostic in \p D.
/// The message includes all the notes with their corresponding locations.
/// However, notes with fix-its are excluded as those usually only contain a
@@ -166,7 +173,7 @@ std::string mainMessage(const Diag &D) {
printDiag(OS, Note);
}
OS.flush();
- return Result;
+ return capitalize(std::move(Result));
}
/// Returns a message sent to LSP for the note of the main diagnostic.
@@ -179,7 +186,7 @@ std::string noteMessage(const Diag &Main, const DiagBase &Note) {
OS << "\n\n";
printDiag(OS, Main);
OS.flush();
- return Result;
+ return capitalize(std::move(Result));
}
} // namespace
OpenPOWER on IntegriCloud