@@ -1499,6 +1499,37 @@ class PathHierarchyTests: XCTestCase {
1499
1499
}
1500
1500
}
1501
1501
1502
+ func testDiagnosticDoesNotSuggestReplacingPartOfSymbolName( ) throws {
1503
+ let exampleDocumentation = Folder ( name: " CatalogName.docc " , content: [
1504
+ JSONFile ( name: " ModuleName.symbols.json " , content: makeSymbolGraph ( moduleName: " ModuleName " , symbols: [
1505
+ makeSymbol ( id: " some-class-id-1 " , kind: . class, pathComponents: [ " SomeClass-(Something) " ] ) ,
1506
+ makeSymbol ( id: " some-class-id-2 " , kind: . class, pathComponents: [ " SomeClass-(Something) " ] ) ,
1507
+ ] ) ) ,
1508
+ ] )
1509
+ let catalogURL = try exampleDocumentation. write ( inside: createTemporaryDirectory ( ) )
1510
+ let ( _, _, context) = try loadBundle ( from: catalogURL)
1511
+ let tree = context. linkResolver. localResolver. pathHierarchy
1512
+
1513
+ XCTAssert ( context. problems. isEmpty, " Unexpected problems \( context. problems. map ( \. diagnostic. summary) ) " )
1514
+
1515
+ try assertPathCollision ( " ModuleName/SomeClass-(Something) " , in: tree, collisions: [
1516
+ ( " some-class-id-1 " , " -5bq4k " ) ,
1517
+ ( " some-class-id-2 " , " -5bq4n " ) ,
1518
+ ] )
1519
+
1520
+ XCTAssertThrowsError (
1521
+ try tree. findNode ( path: " ModuleName/SomeClass-(Something) " , onlyFindSymbols: true , parent: nil )
1522
+ ) { untypedError in
1523
+ let error = untypedError as! PathHierarchy . Error
1524
+ let referenceError = error. makeTopicReferenceResolutionErrorInfo ( ) { context. linkResolver. localResolver. fullName ( of: $0, in: context) }
1525
+ XCTAssertEqual ( referenceError. message, " 'SomeClass-(Something)' is ambiguous at '/ModuleName' " )
1526
+ XCTAssertEqual ( referenceError. solutions. map ( \. summary) , [
1527
+ " Insert \' -5bq4k \' for \n \' SomeClass-(Something) \' " ,
1528
+ " Insert \' -5bq4n \' for \n \' SomeClass-(Something) \' " ,
1529
+ ] )
1530
+ }
1531
+ }
1532
+
1502
1533
func testSnippets( ) throws {
1503
1534
let ( _, context) = try testBundleAndContext ( named: " Snippets " )
1504
1535
let tree = context. linkResolver. localResolver. pathHierarchy
0 commit comments