Skip to content

Commit 2565925

Browse files
[SymbolGraphGen] allow cursor symbol graphs from function params (#67267)
rdar://105516823
1 parent bfc8407 commit 2565925

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

lib/SymbolGraphGen/Symbol.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ std::pair<StringRef, StringRef> Symbol::getKind(const Decl *D) {
9191
return {"swift.method", "Instance Method"};
9292
return {"swift.func", "Function"};
9393
}
94+
case swift::DeclKind::Param: LLVM_FALLTHROUGH;
9495
case swift::DeclKind::Var: {
9596
const auto *VD = cast<ValueDecl>(D);
9697

@@ -839,6 +840,7 @@ bool Symbol::supportsKind(DeclKind Kind) {
839840
case DeclKind::Destructor: LLVM_FALLTHROUGH;
840841
case DeclKind::Func: LLVM_FALLTHROUGH;
841842
case DeclKind::Var: LLVM_FALLTHROUGH;
843+
case DeclKind::Param: LLVM_FALLTHROUGH;
842844
case DeclKind::Subscript: LLVM_FALLTHROUGH;
843845
case DeclKind::TypeAlias: LLVM_FALLTHROUGH;
844846
case DeclKind::AssociatedType: LLVM_FALLTHROUGH;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
func foo(_ fn: (Int) -> Void) {}
2+
3+
foo { bar in
4+
}
5+
6+
// RUN: %empty-directory(%t)
7+
// RUN: %sourcekitd-test -req=cursor -pos=1:12 -req-opts=retrieve_symbol_graph=1 %s -- %s -target %target-triple | %FileCheck -check-prefix=CHECK_FN %s
8+
// RUN: %sourcekitd-test -req=cursor -pos=3:7 -req-opts=retrieve_symbol_graph=1 %s -- %s -target %target-triple | %FileCheck -check-prefix=CHECK_BAR %s
9+
10+
// CHECK_FN: SYMBOL GRAPH BEGIN
11+
// CHECK_FN: {
12+
// CHECK_FN: "symbols": [
13+
// CHECK_FN: {
14+
// CHECK_FN: "identifier": {
15+
// CHECK_FN: "interfaceLanguage": "swift",
16+
// CHECK_FN: "precise": "s:25cursor_symbol_graph_param3fooyyySiXEF2fnL_yySiXEvp"
17+
// CHECK_FN: },
18+
// CHECK_FN: "kind": {
19+
// CHECK_FN: "displayName": "Global Variable",
20+
// CHECK_FN: "identifier": "swift.var"
21+
// CHECK_FN: },
22+
// CHECK_FN: "pathComponents": [
23+
// CHECK_FN: "foo(_:)",
24+
// CHECK_FN: "fn"
25+
// CHECK_FN: ]
26+
// CHECK_FN: }
27+
// CHECK_FN: ]
28+
// CHECK_FN: }
29+
// CHECK_FN: SYMBOL GRAPH END
30+
31+
// CHECK_BAR: SYMBOL GRAPH BEGIN
32+
// CHECK_BAR: {
33+
// CHECK_BAR: "symbols": [
34+
// CHECK_BAR: {
35+
// CHECK_BAR: "identifier": {
36+
// CHECK_BAR: "interfaceLanguage": "swift",
37+
// CHECK_BAR: "precise": "s:25cursor_symbol_graph_paramySiXEfU_3barL_Sivp"
38+
// CHECK_BAR: },
39+
// CHECK_BAR: "kind": {
40+
// CHECK_BAR: "displayName": "Global Variable",
41+
// CHECK_BAR: "identifier": "swift.var"
42+
// CHECK_BAR: },
43+
// CHECK_BAR: "pathComponents": [
44+
// CHECK_BAR: "bar"
45+
// CHECK_BAR: ]
46+
// CHECK_BAR: }
47+
// CHECK_BAR: ]
48+
// CHECK_BAR: }
49+
// CHECK_BAR: SYMBOL GRAPH END

0 commit comments

Comments
 (0)