diff options
Diffstat (limited to 'clang-tools-extra/clangd/ConfigYAML.cpp')
-rw-r--r-- | clang-tools-extra/clangd/ConfigYAML.cpp | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYAML.cpp index 0487c3281576..04c0c633a3bb 100644 --- a/clang-tools-extra/clangd/ConfigYAML.cpp +++ b/clang-tools-extra/clangd/ConfigYAML.cpp @@ -66,6 +66,7 @@ public: Dict.handle("Diagnostics", [&](Node &N) { parse(F.Diagnostics, N); }); Dict.handle("Completion", [&](Node &N) { parse(F.Completion, N); }); Dict.handle("Hover", [&](Node &N) { parse(F.Hover, N); }); + Dict.handle("InlayHints", [&](Node &N) { parse(F.InlayHints, N); }); Dict.parse(N); return !(N.failed() || HadError); } @@ -199,12 +200,8 @@ private: void parse(Fragment::CompletionBlock &F, Node &N) { DictParser Dict("Completion", this); Dict.handle("AllScopes", [&](Node &N) { - if (auto Value = scalarValue(N, "AllScopes")) { - if (auto AllScopes = llvm::yaml::parseBool(**Value)) - F.AllScopes = *AllScopes; - else - warning("AllScopes should be a boolean", N); - } + if (auto AllScopes = boolValue(N, "AllScopes")) + F.AllScopes = *AllScopes; }); Dict.parse(N); } @@ -212,12 +209,25 @@ private: void parse(Fragment::HoverBlock &F, Node &N) { DictParser Dict("Hover", this); Dict.handle("ShowAKA", [&](Node &N) { - if (auto Value = scalarValue(N, "ShowAKA")) { - if (auto ShowAKA = llvm::yaml::parseBool(**Value)) - F.ShowAKA = *ShowAKA; - else - warning("ShowAKA should be a boolean", N); - } + if (auto ShowAKA = boolValue(N, "ShowAKA")) + F.ShowAKA = *ShowAKA; + }); + Dict.parse(N); + } + + void parse(Fragment::InlayHintsBlock &F, Node &N) { + DictParser Dict("InlayHints", this); + Dict.handle("Enabled", [&](Node &N) { + if (auto Value = boolValue(N, "Enabled")) + F.Enabled = *Value; + }); + Dict.handle("ParameterNames", [&](Node &N) { + if (auto Value = boolValue(N, "ParameterNames")) + F.ParameterNames = *Value; + }); + Dict.handle("DeducedTypes", [&](Node &N) { + if (auto Value = boolValue(N, "DeducedTypes")) + F.DeducedTypes = *Value; }); Dict.parse(N); } @@ -331,6 +341,16 @@ private: return llvm::None; } + llvm::Optional<Located<bool>> boolValue(Node &N, llvm::StringRef Desc) { + if (auto Scalar = scalarValue(N, Desc)) { + if (auto Bool = llvm::yaml::parseBool(**Scalar)) + return Located<bool>(*Bool, Scalar->Range); + else + warning(Desc + " should be a boolean", N); + } + return llvm::None; + } + // Try to parse a list of single scalar values, or just a single value. llvm::Optional<std::vector<Located<std::string>>> scalarValues(Node &N) { std::vector<Located<std::string>> Result; |