13#include "gmock/gmock.h"
14#include "gtest/gtest.h"
16using testing::ElementsAre;
20 const clang::clangd::FeatureModuleRegistry::entry &E) {
21 OS <<
"(name = " << E.getName() <<
", description = '" << E.getDesc() <<
"')";
27 const iterator_range<Registry<clang::clangd::FeatureModule>::iterator>
31 for (clang::clangd::FeatureModuleRegistry::entry E : Rng) {
43 OS <<
"(id = " << T.id() <<
", "
44 <<
"title = " << T.title() <<
")";
53 static constexpr const char *TweakID =
"DummyTweak";
54 struct DummyTweak final :
public Tweak {
55 const char *id()
const override {
return TweakID; }
56 bool prepare(
const Selection &)
override {
return true; }
57 Expected<Effect> apply(
const Selection &)
override {
58 return error(
"not implemented");
60 std::string title()
const override {
return id(); }
61 llvm::StringLiteral kind()
const override {
62 return llvm::StringLiteral(
"");
66 void contributeTweaks(std::vector<std::unique_ptr<Tweak>> &Out)
override {
67 Out.emplace_back(
new DummyTweak);
71static FeatureModuleRegistry::Add<Dummy>
72 X(
"dummy",
"Dummy feature module with dummy tweak");
74MATCHER_P(moduleName, Name,
"") {
return arg.getName() == Name; }
75MATCHER_P(tweakID, ID,
"") {
return arg->id() == llvm::StringRef(ID); }
81TEST(FeatureModulesRegistryTest, DummyModule) {
82 EXPECT_THAT(FeatureModuleRegistry::entries(),
83 ElementsAre(moduleName(
"dummy")));
85 ASSERT_EQ(Set.end() - Set.begin(), 1u);
86 std::vector<std::unique_ptr<Tweak>> Tweaks;
87 Set.begin()->contributeTweaks(Tweaks);
88 EXPECT_THAT(Tweaks, ElementsAre(tweakID(
"DummyTweak")));
A FeatureModuleSet is a collection of feature modules installed in clangd.
static FeatureModuleSet fromRegistry()
A FeatureModule contributes a vertical feature to clangd.
An interface base for small context-sensitive refactoring actions.
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
llvm::Error error(std::error_code EC, const char *Fmt, Ts &&... Vals)
static URISchemeRegistry::Add< TestScheme > X(TestScheme::Scheme, "Test schema")
TEST(BackgroundQueueTest, Priority)
Some operations such as code completion produce a set of candidates.
raw_ostream & operator<<(raw_ostream &OS, const clang::clangd::FeatureModuleRegistry::entry &E)