[clangd] Add parsing for IgnoreHeaders config option

This commit is contained in:
Kadir Cetinkaya 2022-05-06 14:32:04 +02:00
parent ac0f4c8f36
commit 9fe89a1f0f
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
2 changed files with 24 additions and 0 deletions

View File

@ -128,6 +128,7 @@ private:
Dict.handle("UnusedIncludes", [&](Node &N) {
F.UnusedIncludes = scalarValue(N, "UnusedIncludes");
});
Dict.handle("Includes", [&](Node &N) { parse(F.Includes, N); });
Dict.handle("ClangTidy", [&](Node &N) { parse(F.ClangTidy, N); });
Dict.parse(N);
}
@ -154,6 +155,15 @@ private:
Dict.parse(N);
}
void parse(Fragment::DiagnosticsBlock::IncludesBlock &F, Node &N) {
DictParser Dict("Includes", this);
Dict.handle("IgnoreHeader", [&](Node &N) {
if (auto Values = scalarValues(N))
F.IgnoreHeader = std::move(*Values);
});
Dict.parse(N);
}
void parse(Fragment::IndexBlock &F, Node &N) {
DictParser Dict("Index", this);
Dict.handle("Background",

View File

@ -247,6 +247,20 @@ InlayHints:
EXPECT_EQ(Results[0].InlayHints.DeducedTypes, llvm::None);
}
TEST(ParseYAML, IncludesIgnoreHeader) {
CapturedDiags Diags;
Annotations YAML(R"yaml(
Diagnostics:
Includes:
IgnoreHeader: [foo, bar]
)yaml");
auto Results =
Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
ASSERT_THAT(Diags.Diagnostics, IsEmpty());
ASSERT_EQ(Results.size(), 1u);
EXPECT_THAT(Results[0].Diagnostics.Includes.IgnoreHeader,
ElementsAre(val("foo"), val("bar")));
}
} // namespace
} // namespace config
} // namespace clangd