Skip to content

Commit b7bc7bc

Browse files
author
Nathan Hawes
authored
Merge pull request #30551 from nathawes/cross-import-doc-info
[SourceKit/DocSupport] Update cross-import overlay symbols reported in the module doc-info request with their required bystanders.
2 parents bf4a80b + fe12ab2 commit b7bc7bc

File tree

7 files changed

+373
-2
lines changed

7 files changed

+373
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %empty-directory(%t.mod)
2+
// RUN: %empty-directory(%t.mod/mcp)
3+
4+
// Check doc info shows the decls from each of A's cross-import overlays and lists the required bystander modules.
5+
//
6+
// RUN: %sourcekitd-test -req=doc-info -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
8+
9+
// Set up a cross-import module with doc comments and check the synthesized comments don't appear in the fully_annotated_decl entries.
10+
//
11+
// 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
12+
// RUN: %sourcekitd-test -req=doc-info -module Other -- -target %target-triple -I %S/../Inputs/CrossImport -I %t.mod/ -module-cache-path %t.mod/mcp > %t.response
13+
// RUN: diff --strip-trailing-cr -u %s.Other.response %t.response
14+
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
import SwiftOnoneSupport
2+
3+
func fromA()
4+
5+
6+
// MARK: - B Additions
7+
8+
import B
9+
10+
// Available when B is imported with A
11+
struct From_ABAdditionsType {
12+
}
13+
14+
// Available when B is imported with A
15+
func from_ABAdditions()
16+
17+
18+
// MARK: - B and C Additions
19+
20+
import C
21+
22+
// Available when B and C are imported with A
23+
func from__ABAdditionsCAdditions()
24+
25+
// Available when B and C are imported with A
26+
func other(x x: A.From_ABAdditionsType)
27+
28+
29+
[
30+
{
31+
key.kind: source.lang.swift.syntaxtype.keyword,
32+
key.offset: 0,
33+
key.length: 6
34+
},
35+
{
36+
key.kind: source.lang.swift.syntaxtype.identifier,
37+
key.offset: 7,
38+
key.length: 17
39+
},
40+
{
41+
key.kind: source.lang.swift.syntaxtype.keyword,
42+
key.offset: 26,
43+
key.length: 4
44+
},
45+
{
46+
key.kind: source.lang.swift.syntaxtype.identifier,
47+
key.offset: 31,
48+
key.length: 5
49+
},
50+
{
51+
key.kind: source.lang.swift.syntaxtype.comment,
52+
key.offset: 41,
53+
key.length: 23
54+
},
55+
{
56+
key.kind: source.lang.swift.syntaxtype.comment.mark,
57+
key.offset: 44,
58+
key.length: 19
59+
},
60+
{
61+
key.kind: source.lang.swift.syntaxtype.keyword,
62+
key.offset: 65,
63+
key.length: 6
64+
},
65+
{
66+
key.kind: source.lang.swift.syntaxtype.identifier,
67+
key.offset: 72,
68+
key.length: 1
69+
},
70+
{
71+
key.kind: source.lang.swift.syntaxtype.comment,
72+
key.offset: 75,
73+
key.length: 39
74+
},
75+
{
76+
key.kind: source.lang.swift.syntaxtype.keyword,
77+
key.offset: 114,
78+
key.length: 6
79+
},
80+
{
81+
key.kind: source.lang.swift.syntaxtype.identifier,
82+
key.offset: 121,
83+
key.length: 20
84+
},
85+
{
86+
key.kind: source.lang.swift.syntaxtype.comment,
87+
key.offset: 147,
88+
key.length: 39
89+
},
90+
{
91+
key.kind: source.lang.swift.syntaxtype.keyword,
92+
key.offset: 186,
93+
key.length: 4
94+
},
95+
{
96+
key.kind: source.lang.swift.syntaxtype.identifier,
97+
key.offset: 191,
98+
key.length: 16
99+
},
100+
{
101+
key.kind: source.lang.swift.syntaxtype.comment,
102+
key.offset: 212,
103+
key.length: 29
104+
},
105+
{
106+
key.kind: source.lang.swift.syntaxtype.comment.mark,
107+
key.offset: 215,
108+
key.length: 25
109+
},
110+
{
111+
key.kind: source.lang.swift.syntaxtype.keyword,
112+
key.offset: 242,
113+
key.length: 6
114+
},
115+
{
116+
key.kind: source.lang.swift.syntaxtype.identifier,
117+
key.offset: 249,
118+
key.length: 1
119+
},
120+
{
121+
key.kind: source.lang.swift.syntaxtype.comment,
122+
key.offset: 252,
123+
key.length: 46
124+
},
125+
{
126+
key.kind: source.lang.swift.syntaxtype.keyword,
127+
key.offset: 298,
128+
key.length: 4
129+
},
130+
{
131+
key.kind: source.lang.swift.syntaxtype.identifier,
132+
key.offset: 303,
133+
key.length: 27
134+
},
135+
{
136+
key.kind: source.lang.swift.syntaxtype.comment,
137+
key.offset: 334,
138+
key.length: 46
139+
},
140+
{
141+
key.kind: source.lang.swift.syntaxtype.keyword,
142+
key.offset: 380,
143+
key.length: 4
144+
},
145+
{
146+
key.kind: source.lang.swift.syntaxtype.identifier,
147+
key.offset: 385,
148+
key.length: 5
149+
},
150+
{
151+
key.kind: source.lang.swift.syntaxtype.argument,
152+
key.offset: 391,
153+
key.length: 1
154+
},
155+
{
156+
key.kind: source.lang.swift.syntaxtype.parameter,
157+
key.offset: 393,
158+
key.length: 1
159+
},
160+
{
161+
key.kind: source.lang.swift.syntaxtype.typeidentifier,
162+
key.offset: 396,
163+
key.length: 1
164+
},
165+
{
166+
key.kind: source.lang.swift.ref.struct,
167+
key.name: "From_ABAdditionsType",
168+
key.usr: "s:12_ABAdditions05From_A4TypeV",
169+
key.offset: 398,
170+
key.length: 20
171+
}
172+
]
173+
[
174+
{
175+
key.kind: source.lang.swift.decl.function.free,
176+
key.name: "fromA()",
177+
key.usr: "s:1A5fromAyyF",
178+
key.offset: 26,
179+
key.length: 12,
180+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fromA</decl.name>()</decl.function.free>"
181+
},
182+
{
183+
key.kind: source.lang.swift.decl.struct,
184+
key.name: "From_ABAdditionsType",
185+
key.usr: "s:12_ABAdditions05From_A4TypeV",
186+
key.offset: 114,
187+
key.length: 31,
188+
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>From_ABAdditionsType</decl.name></decl.struct>",
189+
key.required_bystanders: [
190+
"B"
191+
]
192+
},
193+
{
194+
key.kind: source.lang.swift.decl.function.free,
195+
key.name: "from_ABAdditions()",
196+
key.usr: "s:12_ABAdditions05from_A0yyF",
197+
key.offset: 186,
198+
key.length: 23,
199+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>from_ABAdditions</decl.name>()</decl.function.free>",
200+
key.required_bystanders: [
201+
"B"
202+
]
203+
},
204+
{
205+
key.kind: source.lang.swift.decl.function.free,
206+
key.name: "from__ABAdditionsCAdditions()",
207+
key.usr: "s:23__ABAdditionsCAdditions06from__aB0yyF",
208+
key.offset: 298,
209+
key.length: 34,
210+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>from__ABAdditionsCAdditions</decl.name>()</decl.function.free>",
211+
key.required_bystanders: [
212+
"C",
213+
"B"
214+
]
215+
},
216+
{
217+
key.kind: source.lang.swift.decl.function.free,
218+
key.name: "other(x:)",
219+
key.usr: "s:23__ABAdditionsCAdditions5other1xy01_A005From_A4TypeV_tF",
220+
key.offset: 380,
221+
key.length: 39,
222+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>other</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:12_ABAdditions05From_A4TypeV\">From_ABAdditionsType</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.free>",
223+
key.entities: [
224+
{
225+
key.kind: source.lang.swift.decl.var.local,
226+
key.keyword: "x",
227+
key.name: "x",
228+
key.offset: 396,
229+
key.length: 22
230+
}
231+
],
232+
key.required_bystanders: [
233+
"C",
234+
"B"
235+
]
236+
}
237+
]
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import SwiftOnoneSupport
2+
3+
func fromOther()
4+
5+
6+
// MARK: - C Additions
7+
8+
import C
9+
10+
// Available when C is imported with Other
11+
func from_OtherCAdditions()
12+
13+
14+
[
15+
{
16+
key.kind: source.lang.swift.syntaxtype.keyword,
17+
key.offset: 0,
18+
key.length: 6
19+
},
20+
{
21+
key.kind: source.lang.swift.syntaxtype.identifier,
22+
key.offset: 7,
23+
key.length: 17
24+
},
25+
{
26+
key.kind: source.lang.swift.syntaxtype.keyword,
27+
key.offset: 26,
28+
key.length: 4
29+
},
30+
{
31+
key.kind: source.lang.swift.syntaxtype.identifier,
32+
key.offset: 31,
33+
key.length: 9
34+
},
35+
{
36+
key.kind: source.lang.swift.syntaxtype.comment,
37+
key.offset: 45,
38+
key.length: 23
39+
},
40+
{
41+
key.kind: source.lang.swift.syntaxtype.comment.mark,
42+
key.offset: 48,
43+
key.length: 19
44+
},
45+
{
46+
key.kind: source.lang.swift.syntaxtype.keyword,
47+
key.offset: 69,
48+
key.length: 6
49+
},
50+
{
51+
key.kind: source.lang.swift.syntaxtype.identifier,
52+
key.offset: 76,
53+
key.length: 1
54+
},
55+
{
56+
key.kind: source.lang.swift.syntaxtype.comment,
57+
key.offset: 79,
58+
key.length: 43
59+
},
60+
{
61+
key.kind: source.lang.swift.syntaxtype.keyword,
62+
key.offset: 122,
63+
key.length: 4
64+
},
65+
{
66+
key.kind: source.lang.swift.syntaxtype.identifier,
67+
key.offset: 127,
68+
key.length: 20
69+
}
70+
]
71+
[
72+
{
73+
key.kind: source.lang.swift.decl.function.free,
74+
key.name: "fromOther()",
75+
key.usr: "s:5Other04fromA0yyF",
76+
key.offset: 26,
77+
key.length: 16,
78+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fromOther</decl.name>()</decl.function.free>"
79+
},
80+
{
81+
key.kind: source.lang.swift.decl.function.free,
82+
key.name: "from_OtherCAdditions()",
83+
key.usr: "s:16_OtherCAdditions05from_aB0yyF",
84+
key.doc.full_as_xml: "<Function><Name>from_OtherCAdditions()</Name><USR>s:16_OtherCAdditions05from_aB0yyF</USR><Declaration>func from_OtherCAdditions()</Declaration><CommentParts><Abstract><Para>This has some interesting documentation that shouldn’t be separated from the decl when we print the comment detailing its required bystanders in the generated interface of ‘Other’.</Para></Abstract></CommentParts></Function>",
85+
key.offset: 122,
86+
key.length: 27,
87+
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>from_OtherCAdditions</decl.name>()</decl.function.free>",
88+
key.required_bystanders: [
89+
"C"
90+
]
91+
}
92+
]

tools/SourceKit/include/SourceKit/Core/LangSupport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ struct DocEntityInfo {
485485
llvm::SmallString<64> LocalizationKey;
486486
std::vector<DocGenericParam> GenericParams;
487487
std::vector<std::string> GenericRequirements;
488+
std::vector<std::string> RequiredBystanders;
488489
unsigned Offset = 0;
489490
unsigned Length = 0;
490491
bool IsUnavailable = false;

0 commit comments

Comments
 (0)