[PATCH] D157080: [clangd] Symbol search includes parameter types for (member) functions
Florian Humblot via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 4 02:59:04 PDT 2023
florianhumblot updated this revision to Diff 547150.
florianhumblot added a comment.
Forgot to update the tests.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157080/new/
https://reviews.llvm.org/D157080
Files:
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/test/symbols.test
Index: clang-tools-extra/clangd/test/symbols.test
===================================================================
--- clang-tools-extra/clangd/test/symbols.test
+++ clang-tools-extra/clangd/test/symbols.test
@@ -36,7 +36,7 @@
# CHECK-NEXT: {
# CHECK-NEXT: "detail": "void ()",
# CHECK-NEXT: "kind": 12,
-# CHECK-NEXT: "name": "foo",
+# CHECK-NEXT: "name": "foo()",
# CHECK-NEXT: "range": {
# CHECK-NEXT: "end": {
# CHECK-NEXT: "character": {{.*}},
@@ -61,7 +61,7 @@
# CHECK-NEXT: {
# CHECK-NEXT: "detail": "int ()",
# CHECK-NEXT: "kind": 12,
-# CHECK-NEXT: "name": "main",
+# CHECK-NEXT: "name": "main()",
# CHECK-NEXT: "range": {
# CHECK-NEXT: "end": {
# CHECK-NEXT: "character": {{.*}},
Index: clang-tools-extra/clangd/Protocol.cpp
===================================================================
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -895,8 +895,16 @@
{"range", S.range},
{"selectionRange", S.selectionRange}};
- if (!S.detail.empty())
+ if (!S.detail.empty()) {
+ if (S.kind == SymbolKind::Method || S.kind == SymbolKind::Function) {
+ llvm::StringRef Detail{S.detail};
+ const auto Start = Detail.find_first_of('(');
+ const auto End = Detail.find_last_of(')');
+ const auto Distance = End - Start;
+ Result["name"] = S.name + Detail.substr(Start, Distance).str() + ')';
+ }
Result["detail"] = S.detail;
+ }
if (!S.children.empty())
Result["children"] = S.children;
if (S.deprecated)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157080.547150.patch
Type: text/x-patch
Size: 1687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230804/f2ad9bcc/attachment-0001.bin>
More information about the cfe-commits
mailing list