mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Extensive cross-language tooling support needs to bridge decl names between two different languages more freely. This SourceKit request is designed to translate Objc names to Swift names and vice versa. Working similarly to cursor-info requisition, the name translation request requires a Swift reference to a Swift/Clang decl, and the preferred name to translate from, and language kind that the given name belongs to. If the translation succeeds, SourceKit service responds with the corresponding name than belongs to the other kind of language. Newly introduced keys: “key.namekind": “source.lang.name.kind.objc” | "source.lang.name.kind.swift" “key.basename”: “name" “key.argnames”: [“name"] “key.selectorpieces”: [“name[:]"] This commit only implements translation from Objc to Swift.
23 lines
1.3 KiB
Swift
23 lines
1.3 KiB
Swift
import Foo
|
|
|
|
func foo1() {
|
|
_ = FooComparisonResult.orderedAscending
|
|
_ = FooComparisonResult.orderedDescending
|
|
_ = FooComparisonResult.orderedSame
|
|
_ = FooRuncingOptions.enableMince
|
|
_ = FooRuncingOptions.enableQuince
|
|
}
|
|
|
|
// REQUIRES: objc_interop
|
|
// RUN: %sourcekitd-test -req=translate -objc-name orderedSome -pos=4:30 %s -- -F %S/Inputs/mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK1 %s
|
|
// RUN: %sourcekitd-test -req=translate -objc-selector orderedSome -pos=4:30 %s -- -F %S/Inputs/mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK-NONE %s
|
|
// RUN: %sourcekitd-test -req=translate -objc-name enableThird -pos=7:30 %s -- -F %S/Inputs/mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK2 %s
|
|
// RUN: %sourcekitd-test -req=translate -objc-name FooRuncingEnableThird -pos=7:30 %s -- -F %S/Inputs/mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK2 %s
|
|
// RUN: %sourcekitd-test -req=translate -objc-name FooRuncinEnableThird -pos=7:30 %s -- -F %S/Inputs/mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK2 %s
|
|
// RUN: %sourcekitd-test -req=translate -objc-name FooRinEnableThird -pos=7:30 %s -- -F %S/Inputs/mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK3 %s
|
|
|
|
// CHECK1: orderedSome
|
|
// CHECK-NONE: <empty name translation info>
|
|
// CHECK2: enableThird
|
|
// CHECK3: inEnableThird
|