[clangd] Fix label and snippet for funcs in the index
This is a follow-up to r330004 to fix functions with required template args, e.g. std::make_shared. llvm-svn: 330087
This commit is contained in:
parent
713f09d014
commit
f118d51fff
|
@ -27,16 +27,11 @@ namespace clang {
|
|||
namespace clangd {
|
||||
|
||||
namespace {
|
||||
/// If \p ND is a template specialization, returns the primary template.
|
||||
/// If \p ND is a template specialization, returns the described template.
|
||||
/// Otherwise, returns \p ND.
|
||||
const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
|
||||
if (auto Cls = dyn_cast<CXXRecordDecl>(&ND)) {
|
||||
if (auto T = Cls->getDescribedTemplate())
|
||||
return *T;
|
||||
} else if (auto Func = dyn_cast<FunctionDecl>(&ND)) {
|
||||
if (auto T = Func->getPrimaryTemplate())
|
||||
return *T;
|
||||
}
|
||||
if (auto T = ND.getDescribedTemplate())
|
||||
return *T;
|
||||
return ND;
|
||||
}
|
||||
|
||||
|
|
|
@ -201,8 +201,8 @@ template <class Ty>
|
|||
class vector {
|
||||
};
|
||||
|
||||
template <class Ty>
|
||||
vector<Ty> make_vector(Ty* begin, Ty* end) {}
|
||||
template <class Ty, class Arg>
|
||||
vector<Ty> make_vector(Arg A) {}
|
||||
)cpp";
|
||||
|
||||
FileIndex M;
|
||||
|
@ -222,9 +222,9 @@ vector<Ty> make_vector(Ty* begin, Ty* end) {}
|
|||
}
|
||||
|
||||
if (Sym.Name == "make_vector") {
|
||||
EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
|
||||
EXPECT_EQ(Sym.CompletionLabel, "make_vector<class Ty>(Arg A)");
|
||||
EXPECT_EQ(Sym.CompletionSnippetInsertText,
|
||||
"make_vector(${1:Ty *begin}, ${2:Ty *end})");
|
||||
"make_vector<${1:class Ty}>(${2:Arg A})");
|
||||
EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
|
||||
SeenMakeVector = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue