summaryrefslogtreecommitdiff
path: root/clang-tools-extra/clangd/ConfigCompile.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2022-01-06 02:01:13 +0100
committerSam McCall <sam.mccall@gmail.com>2022-01-10 10:26:48 +0100
commit22a34e01066004c9bd8d7ad418df90b8fbcb3749 (patch)
tree940b73f0bc8ba2eb69230842575fa65f4061e998 /clang-tools-extra/clangd/ConfigCompile.cpp
parentad1b8772cf6b16c1162bb8ff425679f5ff046ae9 (diff)
downloadllvm-22a34e01066004c9bd8d7ad418df90b8fbcb3749.tar.gz
[clangd] Support configuration of inlay hints.maain
The idea is that the feature will always be advertised at the LSP level, but depending on config we'll return partial or no responses. We try to avoid doing the analysis for hints we're not going to return. Examples of syntax: ``` InlayHints: Enabled: No --- InlayHints: ParameterNames: No --- InlayHints: ParameterNames: Yes DeducedTypes: Yes ``` Differential Revision: https://reviews.llvm.org/D116713
Diffstat (limited to 'clang-tools-extra/clangd/ConfigCompile.cpp')
-rw-r--r--clang-tools-extra/clangd/ConfigCompile.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp
index 18afdeb3cb5c..a606b98a2dba 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -197,6 +197,7 @@ struct FragmentCompiler {
compile(std::move(F.Diagnostics));
compile(std::move(F.Completion));
compile(std::move(F.Hover));
+ compile(std::move(F.InlayHints));
}
void compile(Fragment::IfBlock &&F) {
@@ -526,6 +527,22 @@ struct FragmentCompiler {
}
}
+ void compile(Fragment::InlayHintsBlock &&F) {
+ if (F.Enabled)
+ Out.Apply.push_back([Value(**F.Enabled)](const Params &, Config &C) {
+ C.InlayHints.Enabled = Value;
+ });
+ if (F.ParameterNames)
+ Out.Apply.push_back(
+ [Value(**F.ParameterNames)](const Params &, Config &C) {
+ C.InlayHints.Parameters = Value;
+ });
+ if (F.DeducedTypes)
+ Out.Apply.push_back([Value(**F.DeducedTypes)](const Params &, Config &C) {
+ C.InlayHints.DeducedTypes = Value;
+ });
+ }
+
constexpr static llvm::SourceMgr::DiagKind Error = llvm::SourceMgr::DK_Error;
constexpr static llvm::SourceMgr::DiagKind Warning =
llvm::SourceMgr::DK_Warning;