Skip to content

Commit

Permalink
[clangd] Wire up compilation for style blocks
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D127749
  • Loading branch information
kadircet committed Jun 15, 2022
1 parent 9096a52 commit 3ecfeb4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/ConfigCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ struct FragmentCompiler {
compile(std::move(F.Completion));
compile(std::move(F.Hover));
compile(std::move(F.InlayHints));
compile(std::move(F.Style));
}

void compile(Fragment::IfBlock &&F) {
Expand Down
8 changes: 8 additions & 0 deletions clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,14 @@ TEST_F(ConfigCompileTests, AllScopes) {
EXPECT_TRUE(compileAndApply());
EXPECT_TRUE(Conf.Completion.AllScopes);
}

TEST_F(ConfigCompileTests, Style) {
Frag = {};
Frag.Style.FullyQualifiedNamespaces.push_back(std::string("foo"));
Frag.Style.FullyQualifiedNamespaces.push_back(std::string("bar"));
EXPECT_TRUE(compileAndApply());
EXPECT_THAT(Conf.Style.FullyQualifiedNamespaces, ElementsAre("foo", "bar"));
}
} // namespace
} // namespace config
} // namespace clangd
Expand Down
13 changes: 13 additions & 0 deletions clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@ TEST(ParseYAML, IncludesIgnoreHeader) {
EXPECT_THAT(Results[0].Diagnostics.Includes.IgnoreHeader,
ElementsAre(val("foo"), val("bar")));
}

TEST(ParseYAML, Style) {
CapturedDiags Diags;
Annotations YAML(R"yaml(
Style:
FullyQualifiedNamespaces: [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].Style.FullyQualifiedNamespaces,
ElementsAre(val("foo"), val("bar")));
}
} // namespace
} // namespace config
} // namespace clangd
Expand Down

0 comments on commit 3ecfeb4

Please sign in to comment.