Skip to content

Commit fe12ab2

Browse files
author
Nathan Hawes
committed
[SourceKit/DocSupport][test] Test that the synthesized comments generated for cross-import overlay decls are ignored.
Unlike doc comments, they shouldn't be reported in the 'fully_annotated_decl' field.
1 parent 9aafadd commit fe12ab2

File tree

3 files changed

+103
-4
lines changed

3 files changed

+103
-4
lines changed
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
// RUN: %empty-directory(%t)
1+
// RUN: %empty-directory(%t.mod)
2+
// RUN: %empty-directory(%t.mod/mcp)
23

3-
// Check the interface shows the decls from each of A's cross-import overlays.
4+
// Check doc info shows the decls from each of A's cross-import overlays and lists the required bystander modules.
45
//
5-
// RUN: %sourcekitd-test -req=doc-info -module A -- -I %S/../Inputs/CrossImport > %t.response
6-
// RUN: diff --strip-trailing-cr -u %s.response %t.response
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
714

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+
]

0 commit comments

Comments
 (0)