[clangd] Implement end-definition-comment inlay hints
authordaiyousei-qz <qyzheng2@outlook.com>
Sat, 15 Jul 2023 23:15:44 +0000 (01:15 +0200)
committerSam McCall <sam.mccall@gmail.com>
Sat, 15 Jul 2023 23:19:02 +0000 (01:19 +0200)
commit9e6a342fdac8978ef6d3e373cbbc7425e3dfe0f8
treea0e7695de2f5cfdc8bf708a44844e92c4307472a
parenta07a6f6c74a03405eccdcd3832acb2187d8b9c21
[clangd] Implement end-definition-comment inlay hints

This patch implements a new inlay hint feature proposed in https://github.com/clangd/clangd/issues/1634. It introduces a new inlay hint kind BlockEnd which shows a comment-like hint after a definition brace pair, including function/type/namespace. For example,
```
void foo() {
} ^
```
In the code shown above, a hint should be displayed at ^ labelling `// foo`. Such hint only shows when there's no trailing character after the position except whitespaces and optionally ';'.

Also, new configurations are introduced in the inlay hints block
```
InlayHints:
    BlockEnd: Yes # toggling the feature
```

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D150635
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/unittests/InlayHintTests.cpp