Skip to content

Conversation

@iMostfa
Copy link
Contributor

@iMostfa iMostfa commented Dec 21, 2025

Resolves: swiftlang/sourcekit-lsp#2145
along with: swiftlang/sourcekit-lsp#2399

example.mov

Add Copy Objective-C Selector Refactoring

This PR adds a new refactoring action that allows users to copy the Objective-C selector from Swift methods marked with @objc or @objcMembers

  • New SourceKit request: source.request.objc.selector - retrieves the Objective-C selector for a method at a given position
  • Refactoring support: Integrated into the semantic refactoring system to provide "Copy Objective-C Selector" as a refactoring action
  • Test coverage: Added comprehensive tests covering simple methods, methods with parameters, and methods with custom selectors

SourceKit API (SwiftSourceDocInfo.cpp:2888-2974):

  • New getObjCSelector method that resolves cursor position to an AbstractFunctionDecl
  • Validates the declaration has @objc annotation
  • Extracts and returns the selector string using getObjCSelector().getString()

Request Handling (Requests.cpp:1767-1813):

  • Added handleRequestGetObjCSelector to process selector extraction requests
  • Returns selector as text via key.text in the response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Action to Copy Objective-C Selector Name of @objc Swift Method

1 participant