Skip to content

Commit 983cbdf

Browse files
include information about synthesized symbols' sources
rdar://75741632
1 parent ae2a4cc commit 983cbdf

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

lib/SymbolGraphGen/Edge.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,21 @@ void Edge::serialize(llvm::json::OStream &OS) const {
5757
});
5858
}
5959
}
60+
61+
// If our source symbol is a synthesized decl, write in information about
62+
// where it's inheriting docs from.
63+
if (Source.getSynthesizedBaseTypeDecl()) {
64+
Symbol inheritedSym(Graph, Source.getSymbolDecl(), nullptr);
65+
SmallString<256> USR, Display;
66+
llvm::raw_svector_ostream DisplayOS(Display);
67+
68+
inheritedSym.getUSR(USR);
69+
inheritedSym.printPath(DisplayOS);
70+
71+
OS.attributeObject("sourceOrigin", [&](){
72+
OS.attribute("identifier", USR.str());
73+
OS.attribute("displayName", Display.str());
74+
});
75+
}
6076
});
6177
}

lib/SymbolGraphGen/FormatVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
#define SWIFT_SYMBOLGRAPH_FORMAT_MAJOR 0
1717
#define SWIFT_SYMBOLGRAPH_FORMAT_MINOR 5
18-
#define SWIFT_SYMBOLGRAPH_FORMAT_PATCH 2
18+
#define SWIFT_SYMBOLGRAPH_FORMAT_PATCH 3
1919

2020
#endif // SWIFT_SYMBOLGRAPHGEN_FORMATVERSION_H
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -module-name InheritedDocs -emit-module -emit-module-path %t/
3+
// RUN: %target-swift-symbolgraph-extract -module-name InheritedDocs -I %t -pretty-print -output-dir %t
4+
// RUN: %FileCheck %s --input-file %t/InheritedDocs.symbols.json
5+
6+
// CHECK: "source": "s:13InheritedDocs1PPAAE8someFuncyyF::SYNTHESIZED::s:13InheritedDocs1SV"
7+
// CHECK-NEXT: "target": "s:13InheritedDocs1SV"
8+
// CHECK-NEXT: "sourceOrigin": {
9+
// CHECK-NEXT: "identifier": "s:13InheritedDocs1PPAAE8someFuncyyF"
10+
// CHECK-NEXT: "displayName": "P.someFunc()"
11+
// CHECK-NEXT: }
12+
13+
/// Protocol P
14+
public protocol P {
15+
/// Some Function
16+
func someFunc()
17+
}
18+
19+
public extension P {
20+
func someFunc() {}
21+
}
22+
23+
public struct S: P {
24+
}

0 commit comments

Comments
 (0)