|
| 1 | +// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=INITIALIZER | %FileCheck %s --check-prefix=INITIALIZER |
| 2 | +// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=METHOD | %FileCheck %s --check-prefix=METHOD |
| 3 | +// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=AVAILABILITY | %FileCheck %s --check-prefix=AVAILABILITY |
| 4 | +// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=STATIC | %FileCheck %s --check-prefix=STATIC |
| 5 | + |
| 6 | +protocol MyProtocol { |
| 7 | + init(init1: Int) |
| 8 | + init(init2: Int) |
| 9 | + |
| 10 | + func method(method1: Int) |
| 11 | + func method(method2: Int) |
| 12 | +} |
| 13 | + |
| 14 | +extension MyProtocol { |
| 15 | + init(init2: Int) { self.init(init1: init2) } |
| 16 | + init(init3: Int) { self.init(init1: init3) } |
| 17 | + |
| 18 | + func method(method2: Int) {} |
| 19 | + func method(method3: Int) {} |
| 20 | +} |
| 21 | + |
| 22 | +class Base { |
| 23 | + init(init4: Int) { } |
| 24 | + func method(method4: Int) {} |
| 25 | +} |
| 26 | + |
| 27 | +class MyClass: Base, MyProtocol { |
| 28 | + |
| 29 | + required init(init1: Int) { super.init(init4: init1) } |
| 30 | + required init(init2: Int) { super.init(init4: init1) } |
| 31 | + init(init3: Int) { super.init(init4: init1) } |
| 32 | + override init(init4: Int) { super.init(init4: init1) } |
| 33 | + |
| 34 | + func method(method1: Int) |
| 35 | + func method(method2: Int) {} |
| 36 | + func method(method3: Int) {} |
| 37 | + override func method(method4: Int) {} |
| 38 | +} |
| 39 | + |
| 40 | +func testConstructer() { |
| 41 | + MyClass(#^INITIALIZER^#) |
| 42 | +// INITIALIZER: Begin completions, 4 items |
| 43 | +// INITIALIZER-DAG: Decl[Constructor]/CurrNominal: ['(']{#init1: Int#}[')'][#MyClass#]; |
| 44 | +// INITIALIZER-DAG: Decl[Constructor]/CurrNominal: ['(']{#init2: Int#}[')'][#MyClass#]; |
| 45 | +// INITIALIZER-DAG: Decl[Constructor]/CurrNominal: ['(']{#init3: Int#}[')'][#MyClass#]; |
| 46 | +// INITIALIZER-DAG: Decl[Constructor]/CurrNominal: ['(']{#init4: Int#}[')'][#MyClass#]; |
| 47 | +// INITIALIZER: End completions |
| 48 | +} |
| 49 | + |
| 50 | +func testMethod(obj: MyClass) { |
| 51 | + obj.method(#^METHOD^#) |
| 52 | +// METHOD: Begin completions, 4 items |
| 53 | +// METHOD-DAG: Decl[InstanceMethod]/CurrNominal: ['(']{#method1: Int#}[')'][#Void#]; |
| 54 | +// METHOD-DAG: Decl[InstanceMethod]/CurrNominal: ['(']{#method2: Int#}[')'][#Void#]; |
| 55 | +// METHOD-DAG: Decl[InstanceMethod]/CurrNominal: ['(']{#method3: Int#}[')'][#Void#]; |
| 56 | +// METHOD-DAG: Decl[InstanceMethod]/CurrNominal: ['(']{#method4: Int#}[')'][#Void#]; |
| 57 | +// METHOD: End completions |
| 58 | +} |
| 59 | + |
| 60 | +protocol HasUnavailable {} |
| 61 | +extension HasUnavailable { |
| 62 | + func method(method1: Int) {} |
| 63 | + |
| 64 | + @available(*, unavailable) |
| 65 | + func method(method2: Int) {} |
| 66 | +} |
| 67 | +struct MyStruct: HasUnavailable { |
| 68 | + @available(*, unavailable) |
| 69 | + func method(method1: Int) {} |
| 70 | + |
| 71 | + func method(method2: Int) {} |
| 72 | +} |
| 73 | +func testUnavailable(val: MyStruct) { |
| 74 | + val.method(#^AVAILABILITY^#) |
| 75 | +// AVAILABILITY: Begin completions, 2 items |
| 76 | +// AVAILABILITY-DAG: Decl[InstanceMethod]/CurrNominal: ['(']{#method2: Int#}[')'][#Void#]; |
| 77 | +// AVAILABILITY-DAG: Decl[InstanceMethod]/Super: ['(']{#method1: Int#}[')'][#Void#]; |
| 78 | +// AVAILABILITY: End completions |
| 79 | +} |
| 80 | + |
| 81 | +struct TestStatic { |
| 82 | + static func method(_ self: TestStatic) -> () -> Void {} |
| 83 | + func method() -> Void {} |
| 84 | +} |
| 85 | +func testStaticFunc() { |
| 86 | + TestStatic.method(#^STATIC^#) |
| 87 | +// STATIC: Begin completions |
| 88 | +// STATIC-DAG: Decl[StaticMethod]/CurrNominal: ['(']{#(self): TestStatic#}[')'][#() -> Void#]; |
| 89 | +// STATIC-DAG: Decl[InstanceMethod]/CurrNominal: ['(']{#(self): TestStatic#}[')'][#() -> Void#]; |
| 90 | +// STATIC: End completions |
| 91 | +} |
0 commit comments