summaryrefslogtreecommitdiff
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-06-22 06:41:43 +0000
committerSam McCall <sam.mccall@gmail.com>2018-06-22 06:41:43 +0000
commitca4c0790739e4276aa4147f3000907fbbbc5feb4 (patch)
treeb18f99f010730961c7f0e30ba98cef4c2caf5a69 /clang-tools-extra
parentc2ee4810271bcaebdeba786abb2cdc9e0eb037c2 (diff)
[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
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clangd/CodeComplete.cpp3
-rw-r--r--clang-tools-extra/clangd/CodeCompletionStrings.cpp13
-rw-r--r--clang-tools-extra/clangd/CodeCompletionStrings.h5
-rw-r--r--clang-tools-extra/clangd/index/Index.cpp1
-rw-r--r--clang-tools-extra/clangd/index/Index.h4
-rw-r--r--clang-tools-extra/clangd/index/Merge.cpp2
-rw-r--r--clang-tools-extra/clangd/index/SymbolCollector.cpp4
-rw-r--r--clang-tools-extra/clangd/index/SymbolYAML.cpp1
-rw-r--r--clang-tools-extra/unittests/clangd/CodeCompletionStringsTests.cpp8
9 files changed, 4 insertions, 37 deletions
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index 1a654eb5028..31619398d17 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -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);
}
diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.cpp b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
index c3066939a5a..814866e5a42 100644
--- a/clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -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
diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.h b/clang-tools-extra/clangd/CodeCompletionStrings.h
index 81d184cfba8..fd81db40e76 100644
--- a/clang-tools-extra/clangd/CodeCompletionStrings.h
+++ b/clang-tools-extra/clangd/CodeCompletionStrings.h
@@ -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
diff --git a/clang-tools-extra/clangd/index/Index.cpp b/clang-tools-extra/clangd/index/Index.cpp
index 7f84d756ab9..68c8242d1be 100644
--- a/clang-tools-extra/clangd/index/Index.cpp
+++ b/clang-tools-extra/clangd/index/Index.cpp
@@ -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);
diff --git a/clang-tools-extra/clangd/index/Index.h b/clang-tools-extra/clangd/index/Index.h
index b12d9218564..376ec87d7ce 100644
--- a/clang-tools-extra/clangd/index/Index.h
+++ b/clang-tools-extra/clangd/index/Index.h
@@ -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
diff --git a/clang-tools-extra/clangd/index/Merge.cpp b/clang-tools-extra/clangd/index/Merge.cpp
index 41d5345d61c..f2255ce3401 100644
--- a/clang-tools-extra/clangd/index/Merge.cpp
+++ b/clang-tools-extra/clangd/index/Merge.cpp
@@ -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 == "")
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 49180ac8ebf..08215b3f7c8 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -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;
diff --git a/clang-tools-extra/clangd/index/SymbolYAML.cpp b/clang-tools-extra/clangd/index/SymbolYAML.cpp
index 98bc7d5f45b..4120611d552 100644
--- a/clang-tools-extra/clangd/index/SymbolYAML.cpp
+++ b/clang-tools-extra/clangd/index/SymbolYAML.cpp
@@ -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",
diff --git a/clang-tools-extra/unittests/clangd/CodeCompletionStringsTests.cpp b/clang-tools-extra/unittests/clangd/CodeCompletionStringsTests.cpp
index 7712686222c..82ab0f57a01 100644
--- a/clang-tools-extra/unittests/clangd/CodeCompletionStringsTests.cpp
+++ b/clang-tools-extra/unittests/clangd/CodeCompletionStringsTests.cpp
@@ -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) {