mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[IDE/SourceKit] New SourceKit request for filtered method list
`source.request.conformingmethods` is a new SourceKit request which receives a source position and a list of protocol namses, returns a list of methods whose return type conforms to the requested protocols. rdar://problem/44699573
This commit is contained in:
30
test/SourceKit/ConformingMethods/basic.swift
Normal file
30
test/SourceKit/ConformingMethods/basic.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
protocol Target1 {}
|
||||
protocol Target2 {}
|
||||
protocol Target3 {}
|
||||
|
||||
struct ConcreteTarget1 : Target1 {}
|
||||
struct ConcreteTarget2 : Target2 {}
|
||||
struct ConcreteTarget3 : Target3 {}
|
||||
|
||||
protocol P {
|
||||
associatedtype Assoc
|
||||
func protocolMethod(asc: Assoc) -> Self
|
||||
}
|
||||
extension P {
|
||||
func protocolMethod(asc: Assoc) -> Self { return self }
|
||||
}
|
||||
|
||||
class C : P {
|
||||
typealias Assoc = String
|
||||
static func staticMethod() -> Self {}
|
||||
func instanceMethod(x: Int) -> C {}
|
||||
func methodForTarget1() -> ConcreteTarget1 {}
|
||||
func methodForTarget2() -> ConcreteTarget2 {}
|
||||
}
|
||||
|
||||
func testing(obj: C) {
|
||||
let _ = obj.
|
||||
}
|
||||
|
||||
// RUN: %sourcekitd-test -req=conformingmethods -pos=26:14 %s -req-opts=expectedtypes='$s8MyModule7Target2PD;$s8MyModule7Target1PD' -- -module-name MyModule %s > %t.response
|
||||
// RUN: diff -u %s.response %t.response
|
||||
Reference in New Issue
Block a user