#include "SyncAPI.h"
#include "TestFS.h"
#include "TestIndex.h"
+#include "TestTU.h"
#include "index/MemIndex.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "llvm/Support/Error.h"
EXPECT_THAT(R.Completions, ElementsAre(Named("loopVar")));
}
+TEST(CompletionTest, UsingDecl) {
+ const char *Header(R"cpp(
+ void foo(int);
+ namespace std {
+ using ::foo;
+ })cpp");
+ const char *Source(R"cpp(
+ void bar() {
+ std::^;
+ })cpp");
+ auto Index = TestTU::withHeaderCode(Header).index();
+ clangd::CodeCompleteOptions Opts;
+ Opts.Index = Index.get();
+ Opts.AllScopes = true;
+ auto R = completions(Source, {}, Opts);
+ EXPECT_THAT(R.Completions,
+ ElementsAre(AllOf(Scope("std::"), Named("foo"),
+ Kind(CompletionItemKind::Reference))));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
// Namespace alias
namespace baz = bar;
- // FIXME: using declaration is not supported as the IndexAction will ignore
- // implicit declarations (the implicit using shadow declaration) by default,
- // and there is no way to customize this behavior at the moment.
using bar::v2;
} // namespace foo
)");
Children()))),
AllOf(WithName("baz"), WithKind(SymbolKind::Namespace),
Children()),
- AllOf(WithName("v2"), WithKind(SymbolKind::Variable))))}));
+ AllOf(WithName("v2"), WithKind(SymbolKind::Namespace))))}));
}
TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
// Namespace alias
namespace baz = bar;
- // FIXME: using declaration is not supported as the IndexAction will ignore
- // implicit declarations (the implicit using shadow declaration) by default,
- // and there is no way to customize this behavior at the moment.
using bar::v2;
} // namespace foo
)";
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+ AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
}
AllOf(QName("Public"), Not(ImplementationDetail()))));
}
+TEST_F(SymbolCollectorTest, UsingDecl) {
+ const char *Header = R"(
+ void foo();
+ namespace std {
+ using ::foo;
+ })";
+ runSymbolCollector(Header, /**/ "");
+ EXPECT_THAT(Symbols, Contains(QName("std::foo")));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
)cpp",
{CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"),
CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"),
- CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}},
+ CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"),
+ CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@UD@foo")}},
{
R"cpp( // Multiple symbols returned - implicit conversion
struct foo {};