@@ -1544,31 +1544,11 @@ class PathHierarchyTests: XCTestCase {
1544
1544
[ " X " , " Y " ] ,
1545
1545
[ " X " , " Y2 " , " Z " , " W " ] ,
1546
1546
]
1547
- let graph = SymbolGraph (
1548
- metadata: SymbolGraph . Metadata (
1549
- formatVersion: SymbolGraph . SemanticVersion ( major: 1 , minor: 1 , patch: 1 ) ,
1550
- generator: " unit-test "
1551
- ) ,
1552
- module: SymbolGraph . Module (
1553
- name: " Module " ,
1554
- platform: SymbolGraph . Platform ( architecture: nil , vendor: nil , operatingSystem: nil )
1555
- ) ,
1556
- symbols: symbolPaths. map {
1557
- SymbolGraph . Symbol (
1558
- identifier: SymbolGraph . Symbol. Identifier ( precise: $0. joined ( separator: " . " ) , interfaceLanguage: " swift " ) ,
1559
- names: SymbolGraph . Symbol. Names ( title: " Title " , navigator: nil , subHeading: nil , prose: nil ) , // names doesn't matter for path disambiguation
1560
- pathComponents: $0,
1561
- docComment: nil ,
1562
- accessLevel: SymbolGraph . Symbol. AccessControl ( rawValue: " public " ) ,
1563
- kind: SymbolGraph . Symbol. Kind ( parsedIdentifier: . class, displayName: " Kind Display Name " ) , // kind display names doesn't matter for path disambiguation
1564
- mixins: [ : ]
1565
- )
1566
- } ,
1567
- relationships: [ ]
1568
- )
1569
- let exampleDocumentation = Folder ( name: " MyKit.docc " , content: [
1570
- try TextFile ( name: " mykit.symbols.json " , utf8Content: XCTUnwrap ( String ( data: JSONEncoder ( ) . encode ( graph) , encoding: . utf8) ) ) ,
1571
- InfoPlist ( displayName: " MyKit " , identifier: " com.test.MyKit " ) ,
1547
+ let exampleDocumentation = Folder ( name: " unit-test.docc " , content: [
1548
+ JSONFile ( name: " Module.symbols.json " , content: makeSymbolGraph (
1549
+ moduleName: " Module " ,
1550
+ symbols: symbolPaths. map { ( $0. joined ( separator: " . " ) , . swift, $0) }
1551
+ ) ) ,
1572
1552
] )
1573
1553
let tempURL = try createTemporaryDirectory ( )
1574
1554
let bundleURL = try exampleDocumentation. write ( inside: tempURL)
@@ -1595,6 +1575,49 @@ class PathHierarchyTests: XCTestCase {
1595
1575
XCTAssertEqual ( paths [ " X.Y2.Z.W " ] , " /Module/X/Y2/Z/W " )
1596
1576
}
1597
1577
1578
+ func testMixedLanguageSymbolWithItsExtendingModule( ) throws {
1579
+ let containerID = " some-container-symbol-id "
1580
+ let memberID = " some-member-symbol-id "
1581
+
1582
+ let exampleDocumentation = Folder ( name: " unit-test.docc " , content: [
1583
+ Folder ( name: " clang " , content: [
1584
+ JSONFile ( name: " ModuleName.symbols.json " , content: makeSymbolGraph (
1585
+ moduleName: " ModuleName " ,
1586
+ symbols: [
1587
+ ( containerID, . objectiveC, [ " ContainerName " ] )
1588
+ ]
1589
+ ) ) ,
1590
+ ] ) ,
1591
+
1592
+ Folder ( name: " swift " , content: [
1593
+ JSONFile ( name: " ModuleName.symbols.json " , content: makeSymbolGraph (
1594
+ moduleName: " ModuleName " ,
1595
+ symbols: [
1596
+ ( containerID, . swift, [ " ContainerName " ] )
1597
+ ]
1598
+ ) ) ,
1599
+
1600
+ JSONFile ( name
: " [email protected] " , content
: makeSymbolGraph (
1601
+ moduleName: " ExtendingModule " ,
1602
+ symbols: [
1603
+ ( memberID, . swift, [ " ContainerName " , " MemberName " ] )
1604
+ ] ,
1605
+ relationships: [
1606
+ . init( source: memberID, target: containerID, kind: . memberOf, targetFallback: nil )
1607
+ ]
1608
+ ) ) ,
1609
+ ] )
1610
+ ] )
1611
+
1612
+ let tempURL = try createTempFolder ( content: [ exampleDocumentation] )
1613
+ let ( _, _, context) = try loadBundle ( from: tempURL)
1614
+ let tree = try XCTUnwrap ( context. linkResolver. localResolver? . pathHierarchy)
1615
+
1616
+ let paths = tree. caseInsensitiveDisambiguatedPaths ( )
1617
+ XCTAssertEqual ( paths [ containerID] , " /ModuleName/ContainerName " )
1618
+ XCTAssertEqual ( paths [ memberID] , " /ModuleName/ContainerName/MemberName " )
1619
+ }
1620
+
1598
1621
func testMultiPlatformModuleWithExtension( ) throws {
1599
1622
let ( _, context) = try testBundleAndContext ( named: " MultiPlatformModuleWithExtension " )
1600
1623
let tree = try XCTUnwrap ( context. linkResolver. localResolver? . pathHierarchy)
@@ -1636,6 +1659,29 @@ class PathHierarchyTests: XCTestCase {
1636
1659
1637
1660
// MARK: Test helpers
1638
1661
1662
+ private func makeSymbolGraph(
1663
+ moduleName: String ,
1664
+ symbols: [ ( identifier: String , language: SourceLanguage , pathComponents: [ String ] ) ] ,
1665
+ relationships: [ SymbolGraph . Relationship ] = [ ]
1666
+ ) -> SymbolGraph {
1667
+ return SymbolGraph (
1668
+ metadata: SymbolGraph . Metadata ( formatVersion: . init( major: 0 , minor: 5 , patch: 3 ) , generator: " unit-test " ) ,
1669
+ module: SymbolGraph . Module ( name: moduleName, platform: . init( ) ) ,
1670
+ symbols: symbols. map { identifier, language, pathComponents in
1671
+ SymbolGraph . Symbol (
1672
+ identifier: . init( precise: identifier, interfaceLanguage: language. id) ,
1673
+ names: . init( title: " SymbolName " , navigator: nil , subHeading: nil , prose: nil ) , // names doesn't matter for path disambiguation
1674
+ pathComponents: pathComponents,
1675
+ docComment: nil ,
1676
+ accessLevel: . public,
1677
+ kind: . init( parsedIdentifier: . class, displayName: " Kind Display Name " ) , // kind display names doesn't matter for path disambiguation
1678
+ mixins: [ : ]
1679
+ )
1680
+ } ,
1681
+ relationships: relationships
1682
+ )
1683
+ }
1684
+
1639
1685
private func assertFindsPath( _ path: String , in tree: PathHierarchy , asSymbolID symbolID: String , file: StaticString = #file, line: UInt = #line) throws {
1640
1686
do {
1641
1687
let symbol = try tree. findSymbol ( path: path)
0 commit comments