Author: sammccall Date: Thu Jun 21 23:41:43 2018 New Revision: 335321 URL: http://llvm.org/viewvc/llvm-project?rev=335321&view=rev Log: [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 Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.h clang-tools-extra/trunk/clangd/index/Index.cpp clang-tools-extra/trunk/clangd/index/Index.h clang-tools-extra/trunk/clangd/index/Merge.cpp clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Jun 21 23:41:43 2018 @@ -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); } Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp Thu Jun 21 23:41:43 2018 @@ -249,18 +249,5 @@ std::string getDetail(const CodeCompleti 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 Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.h?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/CodeCompletionStrings.h (original) +++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.h Thu Jun 21 23:41:43 2018 @@ -65,11 +65,6 @@ std::string formatDocumentation(const Co /// 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 Modified: clang-tools-extra/trunk/clangd/index/Index.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/Index.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu Jun 21 23:41:43 2018 @@ -85,7 +85,6 @@ static void own(Symbol &S, DenseSet<Stri Intern(S.Definition.FileURI); Intern(S.CompletionLabel); - Intern(S.CompletionFilterText); Intern(S.CompletionPlainInsertText); Intern(S.CompletionSnippetInsertText); Modified: clang-tools-extra/trunk/clangd/index/Index.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/Index.h (original) +++ clang-tools-extra/trunk/clangd/index/Index.h Thu Jun 21 23:41:43 2018 @@ -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 Modified: clang-tools-extra/trunk/clangd/index/Merge.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Merge.cpp?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/Merge.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Merge.cpp Thu Jun 21 23:41:43 2018 @@ -98,8 +98,6 @@ mergeSymbol(const Symbol &L, const Symbo 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 == "") Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original) +++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Thu Jun 21 23:41:43 2018 @@ -378,6 +378,8 @@ const Symbol *SymbolCollector::addDeclar 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::addDeclar /*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::addDeclar QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts)) Include = std::move(*Header); } - S.CompletionFilterText = FilterText; S.CompletionLabel = Label; S.CompletionPlainInsertText = PlainInsertText; S.CompletionSnippetInsertText = SnippetInsertText; Modified: clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp (original) +++ clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp Thu Jun 21 23:41:43 2018 @@ -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", Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp?rev=335321&r1=335320&r2=335321&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp Thu Jun 21 23:41:43 2018 @@ -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, FunctionSni 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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits