sammccall updated this revision to Diff 152108.
sammccall added a comment.

use foo: instead of foo:bar: for name.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48375

Files:
  clangd/CodeComplete.cpp
  clangd/CodeCompletionStrings.cpp
  clangd/CodeCompletionStrings.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/Merge.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompletionStringsTests.cpp

Index: unittests/clangd/CodeCompletionStringsTests.cpp
===================================================================
--- unittests/clangd/CodeCompletionStringsTests.cpp
+++ unittests/clangd/CodeCompletionStringsTests.cpp
@@ -43,13 +43,6 @@
   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 @@
   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) {
Index: clangd/index/SymbolYAML.cpp
===================================================================
--- clangd/index/SymbolYAML.cpp
+++ clangd/index/SymbolYAML.cpp
@@ -111,7 +111,6 @@
     IO.mapOptional("IsIndexedForCodeCompletion", Sym.IsIndexedForCodeCompletion,
                    false);
     IO.mapRequired("CompletionLabel", Sym.CompletionLabel);
-    IO.mapRequired("CompletionFilterText", Sym.CompletionFilterText);
     IO.mapRequired("CompletionPlainInsertText", Sym.CompletionPlainInsertText);
 
     IO.mapOptional("CompletionSnippetInsertText",
Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -377,6 +377,8 @@
   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);
@@ -402,7 +404,6 @@
                         /*EnableSnippets=*/true);
   getLabelAndInsertText(*CCS, &IgnoredLabel, &PlainInsertText,
                         /*EnableSnippets=*/false);
-  std::string FilterText = getFilterText(*CCS);
   std::string Documentation =
       formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
                                               /*CommentsFromHeaders=*/true));
@@ -416,7 +417,6 @@
             QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
       Include = std::move(*Header);
   }
-  S.CompletionFilterText = FilterText;
   S.CompletionLabel = Label;
   S.CompletionPlainInsertText = PlainInsertText;
   S.CompletionSnippetInsertText = SnippetInsertText;
Index: clangd/index/Merge.cpp
===================================================================
--- clangd/index/Merge.cpp
+++ clangd/index/Merge.cpp
@@ -98,8 +98,6 @@
   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 == "")
Index: clangd/index/Index.h
===================================================================
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -156,10 +156,6 @@
   /// 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
Index: clangd/index/Index.cpp
===================================================================
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -85,7 +85,6 @@
   Intern(S.Definition.FileURI);
 
   Intern(S.CompletionLabel);
-  Intern(S.CompletionFilterText);
   Intern(S.CompletionPlainInsertText);
   Intern(S.CompletionSnippetInsertText);
 
Index: clangd/CodeCompletionStrings.h
===================================================================
--- clangd/CodeCompletionStrings.h
+++ clangd/CodeCompletionStrings.h
@@ -65,11 +65,6 @@
 /// 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
 
Index: clangd/CodeCompletionStrings.cpp
===================================================================
--- clangd/CodeCompletionStrings.cpp
+++ clangd/CodeCompletionStrings.cpp
@@ -249,18 +249,5 @@
   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
Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -249,7 +249,8 @@
       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);
     }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to