[clangd] Remove FilterText from the index.

Summary:
It's almost always identical to Name, and in fact we never used it (we used name
instead).
The only case where they differ is objc method selectors (foo: vs foo:bar:).
We can live with the latter for both name and filterText, so I've made that
change too.

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits

Differential Revision: https://reviews.llvm.org/D48375

llvm-svn: 335321
This commit is contained in:
Sam McCall 2018-06-22 06:41:43 +00:00
parent aa5f4d2e23
commit 032db94ac9
9 changed files with 4 additions and 37 deletions

View File

@ -249,7 +249,8 @@ struct CompletionCandidate {
I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->Declaration);
getLabelAndInsertText(*SemaCCS, &I.label, &I.insertText,
Opts.EnableSnippets);
I.filterText = getFilterText(*SemaCCS);
if (const char* Text = SemaCCS->getTypedText())
I.filterText = Text;
I.documentation = formatDocumentation(*SemaCCS, SemaDocComment);
I.detail = getDetail(*SemaCCS);
}

View File

@ -249,18 +249,5 @@ std::string getDetail(const CodeCompletionString &CCS) {
return "";
}
std::string getFilterText(const CodeCompletionString &CCS) {
for (const auto &Chunk : CCS) {
switch (Chunk.Kind) {
case CodeCompletionString::CK_TypedText:
// There's always exactly one CK_TypedText chunk.
return Chunk.Text;
default:
break;
}
}
return "";
}
} // namespace clangd
} // namespace clang

View File

@ -65,11 +65,6 @@ std::string formatDocumentation(const CodeCompletionString &CCS,
/// is usually the return type of a function.
std::string getDetail(const CodeCompletionString &CCS);
/// Gets the piece of text that the user is expected to type to match the
/// code-completion string, typically a keyword or the name of a declarator or
/// macro.
std::string getFilterText(const CodeCompletionString &CCS);
} // namespace clangd
} // namespace clang

View File

@ -85,7 +85,6 @@ static void own(Symbol &S, DenseSet<StringRef> &Strings,
Intern(S.Definition.FileURI);
Intern(S.CompletionLabel);
Intern(S.CompletionFilterText);
Intern(S.CompletionPlainInsertText);
Intern(S.CompletionSnippetInsertText);

View File

@ -156,10 +156,6 @@ struct Symbol {
/// candidate list. For example, "Foo(X x, Y y) const" is a label for a
/// function.
llvm::StringRef CompletionLabel;
/// The piece of text that the user is expected to type to match the
/// code-completion string, typically a keyword or the name of a declarator or
/// macro.
llvm::StringRef CompletionFilterText;
/// What to insert when completing this symbol (plain text version).
llvm::StringRef CompletionPlainInsertText;
/// What to insert when completing this symbol (snippet version). This is

View File

@ -98,8 +98,6 @@ mergeSymbol(const Symbol &L, const Symbol &R, Symbol::Details *Scratch) {
S.References += O.References;
if (S.CompletionLabel == "")
S.CompletionLabel = O.CompletionLabel;
if (S.CompletionFilterText == "")
S.CompletionFilterText = O.CompletionFilterText;
if (S.CompletionPlainInsertText == "")
S.CompletionPlainInsertText = O.CompletionPlainInsertText;
if (S.CompletionSnippetInsertText == "")

View File

@ -378,6 +378,8 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND,
Symbol S;
S.ID = std::move(ID);
std::tie(S.Scope, S.Name) = splitQualifiedName(QName);
// FIXME: this returns foo:bar: for objective-C methods, we prefer only foo:
// for consistency with CodeCompletionString and a clean name/signature split.
S.IsIndexedForCodeCompletion = isIndexedForCodeCompletion(ND, Ctx);
S.SymInfo = index::getSymbolInfo(&ND);
@ -403,7 +405,6 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND,
/*EnableSnippets=*/true);
getLabelAndInsertText(*CCS, &IgnoredLabel, &PlainInsertText,
/*EnableSnippets=*/false);
std::string FilterText = getFilterText(*CCS);
std::string Documentation =
formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
/*CommentsFromHeaders=*/true));
@ -417,7 +418,6 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND,
QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
Include = std::move(*Header);
}
S.CompletionFilterText = FilterText;
S.CompletionLabel = Label;
S.CompletionPlainInsertText = PlainInsertText;
S.CompletionSnippetInsertText = SnippetInsertText;

View File

@ -111,7 +111,6 @@ template <> struct MappingTraits<Symbol> {
IO.mapOptional("IsIndexedForCodeCompletion", Sym.IsIndexedForCodeCompletion,
false);
IO.mapRequired("CompletionLabel", Sym.CompletionLabel);
IO.mapRequired("CompletionFilterText", Sym.CompletionFilterText);
IO.mapRequired("CompletionPlainInsertText", Sym.CompletionPlainInsertText);
IO.mapOptional("CompletionSnippetInsertText",

View File

@ -43,13 +43,6 @@ TEST_F(CompletionStringTest, Detail) {
EXPECT_EQ(getDetail(*Builder.TakeString()), "result");
}
TEST_F(CompletionStringTest, FilterText) {
Builder.AddTypedTextChunk("typed");
Builder.AddTypedTextChunk("redundant typed no no");
auto *S = Builder.TakeString();
EXPECT_EQ(getFilterText(*S), "typed");
}
TEST_F(CompletionStringTest, Documentation) {
Builder.addBriefComment("This is ignored");
EXPECT_EQ(formatDocumentation(*Builder.TakeString(), "Is this brief?"),
@ -115,7 +108,6 @@ TEST_F(CompletionStringTest, FunctionSnippet) {
EXPECT_EQ(Label, "Foo(p1, p2)");
EXPECT_EQ(InsertText, "Foo(${1:p1}, ${2:p2})");
EXPECT_EQ(formatDocumentation(*CCS, "Foo's comment"), "Foo's comment");
EXPECT_EQ(getFilterText(*CCS), "Foo");
}
TEST_F(CompletionStringTest, EscapeSnippet) {