Skip to content

[5.9] [SymbolGraphGen] allow cursor symbol graphs from function params #67270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/SymbolGraphGen/Symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ std::pair<StringRef, StringRef> Symbol::getKind(const Decl *D) {
return {"swift.method", "Instance Method"};
return {"swift.func", "Function"};
}
case swift::DeclKind::Param: LLVM_FALLTHROUGH;
case swift::DeclKind::Var: {
const auto *VD = cast<ValueDecl>(D);

Expand Down Expand Up @@ -839,6 +840,7 @@ bool Symbol::supportsKind(DeclKind Kind) {
case DeclKind::Destructor: LLVM_FALLTHROUGH;
case DeclKind::Func: LLVM_FALLTHROUGH;
case DeclKind::Var: LLVM_FALLTHROUGH;
case DeclKind::Param: LLVM_FALLTHROUGH;
case DeclKind::Subscript: LLVM_FALLTHROUGH;
case DeclKind::TypeAlias: LLVM_FALLTHROUGH;
case DeclKind::AssociatedType: LLVM_FALLTHROUGH;
Expand Down
49 changes: 49 additions & 0 deletions test/SourceKit/CursorInfo/cursor_symbol_graph_param.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
func foo(_ fn: (Int) -> Void) {}

foo { bar in
}

// RUN: %empty-directory(%t)
// 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
// 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

// CHECK_FN: SYMBOL GRAPH BEGIN
// CHECK_FN: {
// CHECK_FN: "symbols": [
// CHECK_FN: {
// CHECK_FN: "identifier": {
// CHECK_FN: "interfaceLanguage": "swift",
// CHECK_FN: "precise": "s:25cursor_symbol_graph_param3fooyyySiXEF2fnL_yySiXEvp"
// CHECK_FN: },
// CHECK_FN: "kind": {
// CHECK_FN: "displayName": "Global Variable",
// CHECK_FN: "identifier": "swift.var"
// CHECK_FN: },
// CHECK_FN: "pathComponents": [
// CHECK_FN: "foo(_:)",
// CHECK_FN: "fn"
// CHECK_FN: ]
// CHECK_FN: }
// CHECK_FN: ]
// CHECK_FN: }
// CHECK_FN: SYMBOL GRAPH END

// CHECK_BAR: SYMBOL GRAPH BEGIN
// CHECK_BAR: {
// CHECK_BAR: "symbols": [
// CHECK_BAR: {
// CHECK_BAR: "identifier": {
// CHECK_BAR: "interfaceLanguage": "swift",
// CHECK_BAR: "precise": "s:25cursor_symbol_graph_paramySiXEfU_3barL_Sivp"
// CHECK_BAR: },
// CHECK_BAR: "kind": {
// CHECK_BAR: "displayName": "Global Variable",
// CHECK_BAR: "identifier": "swift.var"
// CHECK_BAR: },
// CHECK_BAR: "pathComponents": [
// CHECK_BAR: "bar"
// CHECK_BAR: ]
// CHECK_BAR: }
// CHECK_BAR: ]
// CHECK_BAR: }
// CHECK_BAR: SYMBOL GRAPH END