Skip to content

Commit 6dd4d06

Browse files
authored
Merge pull request #24732 from rintaro/sourcekit-test-pureswift-sysmodule
[SourceKit] Add InterfaceGen test case for pure Swift system module
2 parents 23a868e + 663defa commit 6dd4d06

File tree

3 files changed

+337
-0
lines changed

3 files changed

+337
-0
lines changed

test/IDE/complete_from_swiftonly_systemmodule.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// RUN: %t/SomeModule.swift
1111

1212
// RUN: %target-swift-ide-test -code-completion -sdk %t/SDK -iframework %t/SDK/Frameworks -source-filename %t/main.swift -code-completion-token=GLOBAL | %FileCheck --check-prefix GLOBAL %s
13+
// RUN: %target-swift-ide-test -code-completion -sdk %t/SDK -iframework %t/SDK/Frameworks -source-filename %t/main.swift -code-completion-token=GLOBAL_TYPE | %FileCheck --check-prefix GLOBAL_TYPE %s
1314
// RUN: %target-swift-ide-test -code-completion -sdk %t/SDK -iframework %t/SDK/Frameworks -source-filename %t/main.swift -code-completion-token=INSTANCE | %FileCheck --check-prefix INSTANCE %s
1415
// RUN: %target-swift-ide-test -code-completion -sdk %t/SDK -iframework %t/SDK/Frameworks -source-filename %t/main.swift -code-completion-token=INITIALIZER | %FileCheck --check-prefix INITIALIZER %s
1516

@@ -36,6 +37,10 @@ internal func internalFunc() {}
3637
public func _secretFunc() {}
3738
public func publicFunc() {}
3839

40+
internal class InternalClass {}
41+
public class _SecretClass {}
42+
public class PublicClass {}
43+
3944
// BEGIN main.swift
4045
import SomeModule
4146

@@ -44,10 +49,21 @@ func test(value: SomeValue) {
4449
// GLOBAL: Begin completions
4550
// GLOBAL-NOT: _secretFunc
4651
// GLOBAL-NOT: internalFunc
52+
// GLOBAL-NOT: _SecretClass
53+
// GLOBAL-NOT: InternalClass
4754
// GLOBAL-DAG: Decl[Struct]/OtherModule[SomeModule]: SomeValue[#SomeValue#];
4855
// GLOBAL-DAG: Decl[FreeFunction]/OtherModule[SomeModule]: publicFunc()[#Void#];
56+
// GLOBAL-DAG: Decl[Class]/OtherModule[SomeModule]: PublicClass[#PublicClass#]; name=PublicClass
4957
// GLOBAL: End completions
5058

59+
let _: #^GLOBAL_TYPE^#
60+
// GLOBAL_TYPE: Begin completions
61+
// GLOBAL_TYPE-NOT: InternalClass
62+
// GLOBAL_TYPE-NOT: _SecretClass
63+
// GLOBAL-TYPE-DAG: Decl[Struct]/OtherModule[SomeModule]: SomeValue[#SomeValue#];
64+
// GLOBAL-TYPE-DAG: Decl[Class]/OtherModule[SomeModule]: PublicClass[#PublicClass#];
65+
// GLOBAL_TYPE: End completions
66+
5167
let _ = value.#^INSTANCE^#
5268
// INSTANCE: Begin completions, 3 items
5369
// INSTANCE-DAG: Keyword[self]/CurrNominal: self[#SomeValue#];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: mkdir -p %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule
4+
// RUN: %target-swift-frontend \
5+
// RUN: -emit-module \
6+
// RUN: -module-name SomeModule \
7+
// RUN: -o %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule/%module-target-triple.swiftmodule \
8+
// RUN: -swift-version 5 \
9+
// RUN: %s
10+
11+
// RUN: %sourcekitd-test -req=interface-gen -module SomeModule -- -sdk %t/SDK -Fsystem %t/SDK/Frameworks -target %target-triple > %t.response
12+
// RUN: diff -u %s.response %t.response
13+
14+
public struct SomeValue {
15+
internal var internalValue: Int { return 1 }
16+
public var _secretValue: Int { return 1 }
17+
public var publicValue: Int { return 1 }
18+
19+
internal func internalMethod() -> Int { return 1 }
20+
public func _secretMethod() -> Int { return 1 }
21+
public func publicMethod() -> Int { return 1 }
22+
23+
internal init(internal: Int) {}
24+
public init(_secret: Int) {}
25+
public init(public: Int) {}
26+
}
27+
28+
internal func internalFunc() {}
29+
public func _secretFunc() {}
30+
public func publicFunc() {}
31+
32+
internal class InternalClass {}
33+
public class _SecretClass {
34+
public var publicVarInSeretClass: Int = 0
35+
}
36+
public class PublicClass {}
Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
import SwiftOnoneSupport
2+
3+
public class PublicClass {
4+
}
5+
6+
public struct SomeValue {
7+
8+
public var publicValue: Int { get }
9+
10+
public func publicMethod() -> Int
11+
12+
public init(public: Int)
13+
}
14+
15+
public func publicFunc()
16+
17+
18+
[
19+
{
20+
key.kind: source.lang.swift.syntaxtype.keyword,
21+
key.offset: 0,
22+
key.length: 6
23+
},
24+
{
25+
key.kind: source.lang.swift.syntaxtype.identifier,
26+
key.offset: 7,
27+
key.length: 17
28+
},
29+
{
30+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
31+
key.offset: 26,
32+
key.length: 6
33+
},
34+
{
35+
key.kind: source.lang.swift.syntaxtype.keyword,
36+
key.offset: 33,
37+
key.length: 5
38+
},
39+
{
40+
key.kind: source.lang.swift.syntaxtype.identifier,
41+
key.offset: 39,
42+
key.length: 11
43+
},
44+
{
45+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
46+
key.offset: 56,
47+
key.length: 6
48+
},
49+
{
50+
key.kind: source.lang.swift.syntaxtype.keyword,
51+
key.offset: 63,
52+
key.length: 6
53+
},
54+
{
55+
key.kind: source.lang.swift.syntaxtype.identifier,
56+
key.offset: 70,
57+
key.length: 9
58+
},
59+
{
60+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
61+
key.offset: 87,
62+
key.length: 6
63+
},
64+
{
65+
key.kind: source.lang.swift.syntaxtype.keyword,
66+
key.offset: 94,
67+
key.length: 3
68+
},
69+
{
70+
key.kind: source.lang.swift.syntaxtype.identifier,
71+
key.offset: 98,
72+
key.length: 11
73+
},
74+
{
75+
key.kind: source.lang.swift.syntaxtype.typeidentifier,
76+
key.offset: 111,
77+
key.length: 3
78+
},
79+
{
80+
key.kind: source.lang.swift.syntaxtype.keyword,
81+
key.offset: 117,
82+
key.length: 3
83+
},
84+
{
85+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
86+
key.offset: 128,
87+
key.length: 6
88+
},
89+
{
90+
key.kind: source.lang.swift.syntaxtype.keyword,
91+
key.offset: 135,
92+
key.length: 4
93+
},
94+
{
95+
key.kind: source.lang.swift.syntaxtype.identifier,
96+
key.offset: 140,
97+
key.length: 12
98+
},
99+
{
100+
key.kind: source.lang.swift.syntaxtype.typeidentifier,
101+
key.offset: 158,
102+
key.length: 3
103+
},
104+
{
105+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
106+
key.offset: 167,
107+
key.length: 6
108+
},
109+
{
110+
key.kind: source.lang.swift.syntaxtype.keyword,
111+
key.offset: 174,
112+
key.length: 4
113+
},
114+
{
115+
key.kind: source.lang.swift.syntaxtype.identifier,
116+
key.offset: 179,
117+
key.length: 6
118+
},
119+
{
120+
key.kind: source.lang.swift.syntaxtype.typeidentifier,
121+
key.offset: 187,
122+
key.length: 3
123+
},
124+
{
125+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
126+
key.offset: 195,
127+
key.length: 6
128+
},
129+
{
130+
key.kind: source.lang.swift.syntaxtype.keyword,
131+
key.offset: 202,
132+
key.length: 4
133+
},
134+
{
135+
key.kind: source.lang.swift.syntaxtype.identifier,
136+
key.offset: 207,
137+
key.length: 10
138+
}
139+
]
140+
[
141+
{
142+
key.kind: source.lang.swift.ref.module,
143+
key.offset: 7,
144+
key.length: 17,
145+
key.is_system: 1
146+
},
147+
{
148+
key.kind: source.lang.swift.ref.struct,
149+
key.offset: 111,
150+
key.length: 3,
151+
key.is_system: 1
152+
},
153+
{
154+
key.kind: source.lang.swift.ref.struct,
155+
key.offset: 158,
156+
key.length: 3,
157+
key.is_system: 1
158+
},
159+
{
160+
key.kind: source.lang.swift.ref.struct,
161+
key.offset: 187,
162+
key.length: 3,
163+
key.is_system: 1
164+
}
165+
]
166+
[
167+
{
168+
key.kind: source.lang.swift.decl.class,
169+
key.accessibility: source.lang.swift.accessibility.public,
170+
key.name: "PublicClass",
171+
key.offset: 33,
172+
key.length: 21,
173+
key.runtime_name: "_TtC4main11PublicClass",
174+
key.nameoffset: 39,
175+
key.namelength: 11,
176+
key.bodyoffset: 52,
177+
key.bodylength: 1,
178+
key.attributes: [
179+
{
180+
key.offset: 26,
181+
key.length: 6,
182+
key.attribute: source.decl.attribute.public
183+
}
184+
]
185+
},
186+
{
187+
key.kind: source.lang.swift.decl.struct,
188+
key.accessibility: source.lang.swift.accessibility.public,
189+
key.name: "SomeValue",
190+
key.offset: 63,
191+
key.length: 130,
192+
key.nameoffset: 70,
193+
key.namelength: 9,
194+
key.bodyoffset: 81,
195+
key.bodylength: 111,
196+
key.attributes: [
197+
{
198+
key.offset: 56,
199+
key.length: 6,
200+
key.attribute: source.decl.attribute.public
201+
}
202+
],
203+
key.substructure: [
204+
{
205+
key.kind: source.lang.swift.decl.var.instance,
206+
key.accessibility: source.lang.swift.accessibility.public,
207+
key.name: "publicValue",
208+
key.offset: 94,
209+
key.length: 28,
210+
key.typename: "Int",
211+
key.nameoffset: 98,
212+
key.namelength: 11,
213+
key.bodyoffset: 116,
214+
key.bodylength: 5,
215+
key.attributes: [
216+
{
217+
key.offset: 87,
218+
key.length: 6,
219+
key.attribute: source.decl.attribute.public
220+
}
221+
]
222+
},
223+
{
224+
key.kind: source.lang.swift.decl.function.method.instance,
225+
key.accessibility: source.lang.swift.accessibility.public,
226+
key.name: "publicMethod()",
227+
key.offset: 135,
228+
key.length: 26,
229+
key.typename: "Int",
230+
key.nameoffset: 140,
231+
key.namelength: 14,
232+
key.attributes: [
233+
{
234+
key.offset: 128,
235+
key.length: 6,
236+
key.attribute: source.decl.attribute.public
237+
}
238+
]
239+
},
240+
{
241+
key.kind: source.lang.swift.decl.function.method.instance,
242+
key.accessibility: source.lang.swift.accessibility.public,
243+
key.name: "init(public:)",
244+
key.offset: 174,
245+
key.length: 17,
246+
key.nameoffset: 174,
247+
key.namelength: 17,
248+
key.attributes: [
249+
{
250+
key.offset: 167,
251+
key.length: 6,
252+
key.attribute: source.decl.attribute.public
253+
}
254+
],
255+
key.substructure: [
256+
{
257+
key.kind: source.lang.swift.decl.var.parameter,
258+
key.name: "public",
259+
key.offset: 179,
260+
key.length: 11,
261+
key.typename: "Int",
262+
key.nameoffset: 179,
263+
key.namelength: 6
264+
}
265+
]
266+
}
267+
]
268+
},
269+
{
270+
key.kind: source.lang.swift.decl.function.free,
271+
key.accessibility: source.lang.swift.accessibility.public,
272+
key.name: "publicFunc()",
273+
key.offset: 202,
274+
key.length: 17,
275+
key.nameoffset: 207,
276+
key.namelength: 12,
277+
key.attributes: [
278+
{
279+
key.offset: 195,
280+
key.length: 6,
281+
key.attribute: source.decl.attribute.public
282+
}
283+
]
284+
}
285+
]

0 commit comments

Comments
 (0)