[PATCH] D38083: [clangd] Skip informative qualifier chunks.
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 28 11:41:50 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314445: [clangd] Skip informative qualifier chunks. (authored by ibiryukov).
Repository:
rL LLVM
https://reviews.llvm.org/D38083
Files:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -409,6 +409,11 @@
}; // CompletionItemsCollector
+bool isInformativeQualifierChunk(CodeCompletionString::Chunk const &Chunk) {
+ return Chunk.Kind == CodeCompletionString::CK_Informative &&
+ StringRef(Chunk.Text).endswith("::");
+}
+
class PlainTextCompletionItemsCollector final
: public CompletionItemsCollector {
@@ -421,6 +426,11 @@
void ProcessChunks(const CodeCompletionString &CCS,
CompletionItem &Item) const override {
for (const auto &Chunk : CCS) {
+ // Informative qualifier chunks only clutter completion results, skip
+ // them.
+ if (isInformativeQualifierChunk(Chunk))
+ continue;
+
switch (Chunk.Kind) {
case CodeCompletionString::CK_TypedText:
// There's always exactly one CK_TypedText chunk.
@@ -453,6 +463,11 @@
CompletionItem &Item) const override {
unsigned ArgCount = 0;
for (const auto &Chunk : CCS) {
+ // Informative qualifier chunks only clutter completion results, skip
+ // them.
+ if (isInformativeQualifierChunk(Chunk))
+ continue;
+
switch (Chunk.Kind) {
case CodeCompletionString::CK_TypedText:
// The piece of text that the user is expected to type to match
Index: clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
===================================================================
--- clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
+++ clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
@@ -0,0 +1,18 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 297
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class Foo {\n public:\n int foo() const;\n int bar() const;\n};\n\nclass Bar : public Foo {\n int foo() const;\n};\n\nvoid test() {\n Bar().\n}"}}}
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":11,"character":8}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHECK-DAG: {"label":"foo() const","kind":2,"detail":"int","sortText":"200035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK-DAG: {"label":"bar() const","kind":2,"detail":"int","sortText":"000037bar","filterText":"bar","insertText":"bar","insertTextFormat":1}
+# CHECK-DAG: {"label":"Foo::foo() const","kind":2,"detail":"int","sortText":"000037foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38083.117031.patch
Type: text/x-patch
Size: 3060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170928/d30852c9/attachment.bin>
More information about the cfe-commits
mailing list