Skip to content

Commit a355a56

Browse files
author
Nathan Hawes
committed
[SourceKit/InterfaceGen][test] Test that doc comments are printed after the required bystanders comment.
1 parent a7e1cb3 commit a355a56

File tree

6 files changed

+173
-3
lines changed

6 files changed

+173
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%YAML 1.2
2+
---
3+
version: 1
4+
modules:
5+
- name: _OtherCAdditions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -swift-version 5 -enable-library-evolution -module-name Other
3+
4+
import Swift
5+
6+
public func fromOther()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@_exported import Other
2+
import C
3+
4+
/// This has some interesting documentation that shouldn't be separated from
5+
/// the decl when we print the comment detailing its required bystanders in the
6+
/// generated interface of 'Other'.
7+
public func from_OtherCAdditions() {}

test/SourceKit/InterfaceGen/gen_swift_module_cross_import.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33

44
// Check the interface shows the decls from each of A's cross-import overlays.
55
//
6-
// RUN: %sourcekitd-test -req=interface-gen -module A -- -I %S/../Inputs/CrossImport > %t.response
7-
// RUN: diff --strip-trailing-cr -u %s.response %t.response
6+
// RUN: %sourcekitd-test -req=interface-gen -module A -- -I %S/../Inputs/CrossImport -module-cache-path %t.mod/mcp > %t.response
7+
// RUN: diff --strip-trailing-cr -u %s.A.response %t.response
88

99
// Make sure cursor info within the generated interface of A on one of the
1010
// decls originally from a cross-import decls shows 'A' as the parent module.
1111
//
12-
// RUN: %sourcekitd-test -req=interface-gen-open -module A -- -I %S/../Inputs/CrossImport == -req=cursor -print-raw-response -pos=11:15 -- -I %S/../Inputs/CrossImport -Xfrontend -enable-cross-import-overlays > %t.response
12+
// RUN: %sourcekitd-test -req=interface-gen-open -module A -- -I %S/../Inputs/CrossImport -module-cache-path %t.mod/mcp == -req=cursor -print-raw-response -pos=11:15 -- -I %S/../Inputs/CrossImport -Xfrontend -enable-cross-import-overlays > %t.response
1313
// RUN: %FileCheck --input-file %t.response %s
1414
//
1515
// CHECK: key.name: "From_ABAdditionsType"
1616
// CHECK: key.modulename: "A"
1717

18+
// Set up a cross-import module with doc comments
19+
//
20+
// RUN: %target-swift-frontend -emit-module-path %t.mod/_OtherCAdditions.swiftmodule -emit-module-doc-path %t.mod/_OtherCAdditions.swiftdoc -module-cache-path %t.mod/mcp -I %S/../Inputs/CrossImport %S/../Inputs/CrossImport/_OtherCAdditions.swift -parse-as-library
21+
// RUN: %sourcekitd-test -req=interface-gen -module Other -- -target %target-triple -I %S/../Inputs/CrossImport -I %t.mod/ -module-cache-path %t.mod/mcp > %t.response
22+
// RUN: diff --strip-trailing-cr -u %s.Other.response %t.response
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import SwiftOnoneSupport
2+
3+
public func fromOther()
4+
5+
6+
// MARK: - C Additions
7+
8+
import C
9+
10+
// Available when C is imported with Other
11+
/// This has some interesting documentation that shouldn't be separated from
12+
/// the decl when we print the comment detailing its required bystanders in the
13+
/// generated interface of 'Other'.
14+
public func from_OtherCAdditions()
15+
16+
17+
[
18+
{
19+
key.kind: source.lang.swift.syntaxtype.keyword,
20+
key.offset: 0,
21+
key.length: 6
22+
},
23+
{
24+
key.kind: source.lang.swift.syntaxtype.identifier,
25+
key.offset: 7,
26+
key.length: 17
27+
},
28+
{
29+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
30+
key.offset: 26,
31+
key.length: 6
32+
},
33+
{
34+
key.kind: source.lang.swift.syntaxtype.keyword,
35+
key.offset: 33,
36+
key.length: 4
37+
},
38+
{
39+
key.kind: source.lang.swift.syntaxtype.identifier,
40+
key.offset: 38,
41+
key.length: 9
42+
},
43+
{
44+
key.kind: source.lang.swift.syntaxtype.comment,
45+
key.offset: 52,
46+
key.length: 23
47+
},
48+
{
49+
key.kind: source.lang.swift.syntaxtype.comment.mark,
50+
key.offset: 55,
51+
key.length: 19
52+
},
53+
{
54+
key.kind: source.lang.swift.syntaxtype.keyword,
55+
key.offset: 76,
56+
key.length: 6
57+
},
58+
{
59+
key.kind: source.lang.swift.syntaxtype.identifier,
60+
key.offset: 83,
61+
key.length: 1
62+
},
63+
{
64+
key.kind: source.lang.swift.syntaxtype.comment,
65+
key.offset: 86,
66+
key.length: 43
67+
},
68+
{
69+
key.kind: source.lang.swift.syntaxtype.doccomment,
70+
key.offset: 129,
71+
key.length: 77
72+
},
73+
{
74+
key.kind: source.lang.swift.syntaxtype.doccomment,
75+
key.offset: 206,
76+
key.length: 80
77+
},
78+
{
79+
key.kind: source.lang.swift.syntaxtype.doccomment,
80+
key.offset: 286,
81+
key.length: 36
82+
},
83+
{
84+
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
85+
key.offset: 322,
86+
key.length: 6
87+
},
88+
{
89+
key.kind: source.lang.swift.syntaxtype.keyword,
90+
key.offset: 329,
91+
key.length: 4
92+
},
93+
{
94+
key.kind: source.lang.swift.syntaxtype.identifier,
95+
key.offset: 334,
96+
key.length: 20
97+
}
98+
]
99+
[
100+
{
101+
key.kind: source.lang.swift.ref.module,
102+
key.offset: 7,
103+
key.length: 17,
104+
key.is_system: 1
105+
},
106+
{
107+
key.kind: source.lang.swift.ref.module,
108+
key.offset: 83,
109+
key.length: 1
110+
}
111+
]
112+
[
113+
{
114+
key.kind: source.lang.swift.decl.function.free,
115+
key.accessibility: source.lang.swift.accessibility.public,
116+
key.name: "fromOther()",
117+
key.offset: 33,
118+
key.length: 16,
119+
key.nameoffset: 38,
120+
key.namelength: 11,
121+
key.attributes: [
122+
{
123+
key.offset: 26,
124+
key.length: 6,
125+
key.attribute: source.decl.attribute.public
126+
}
127+
]
128+
},
129+
{
130+
key.kind: source.lang.swift.decl.function.free,
131+
key.accessibility: source.lang.swift.accessibility.public,
132+
key.name: "from_OtherCAdditions()",
133+
key.offset: 329,
134+
key.length: 27,
135+
key.nameoffset: 334,
136+
key.namelength: 22,
137+
key.docoffset: 129,
138+
key.doclength: 193,
139+
key.attributes: [
140+
{
141+
key.offset: 322,
142+
key.length: 6,
143+
key.attribute: source.decl.attribute.public
144+
}
145+
]
146+
}
147+
]

0 commit comments

Comments
 (0)