@@ -1420,6 +1420,67 @@ final class BackgroundIndexingTests: XCTestCase {
1420
1420
// also testing that we don't wait for type checking of Test.swift to finish.
1421
1421
XCTAssert ( Date ( ) . timeIntervalSince ( dateStarted) < 30 )
1422
1422
}
1423
+
1424
+ func testRedirectSymlink( ) async throws {
1425
+ let project = try await SwiftPMTestProject (
1426
+ files: [
1427
+ " /original.swift " : """
1428
+ func original() {
1429
+ foo()
1430
+ }
1431
+ """ ,
1432
+ " /updated.swift " : """
1433
+ func updated() {
1434
+ foo()
1435
+ }
1436
+ """ ,
1437
+ " test.swift " : """
1438
+ func 1️⃣foo() {}
1439
+ """ ,
1440
+ ] ,
1441
+ workspaces: { scratchDirectory in
1442
+ let symlink =
1443
+ scratchDirectory
1444
+ . appendingPathComponent ( " Sources " )
1445
+ . appendingPathComponent ( " MyLibrary " )
1446
+ . appendingPathComponent ( " symlink.swift " )
1447
+ try FileManager . default. createSymbolicLink (
1448
+ at: symlink,
1449
+ withDestinationURL: scratchDirectory. appendingPathComponent ( " original.swift " )
1450
+ )
1451
+ return [ WorkspaceFolder ( uri: DocumentURI ( scratchDirectory) ) ]
1452
+ } ,
1453
+ enableBackgroundIndexing: true
1454
+ )
1455
+
1456
+ let ( uri, positions) = try project. openDocument ( " test.swift " )
1457
+
1458
+ let prepare = try await project. testClient. send (
1459
+ CallHierarchyPrepareRequest ( textDocument: TextDocumentIdentifier ( uri) , position: positions [ " 1️⃣ " ] )
1460
+ )
1461
+ let initialItem = try XCTUnwrap ( prepare? . only)
1462
+ let callsBeforeRedirect = try await project. testClient. send ( CallHierarchyIncomingCallsRequest ( item: initialItem) )
1463
+ XCTAssertEqual ( callsBeforeRedirect? . only? . from. name, " original() " )
1464
+
1465
+ let symlink =
1466
+ project. scratchDirectory
1467
+ . appendingPathComponent ( " Sources " )
1468
+ . appendingPathComponent ( " MyLibrary " )
1469
+ . appendingPathComponent ( " symlink.swift " )
1470
+ try FileManager . default. removeItem ( at: symlink)
1471
+ try FileManager . default. createSymbolicLink (
1472
+ at: symlink,
1473
+ withDestinationURL: project. scratchDirectory. appendingPathComponent ( " updated.swift " )
1474
+ )
1475
+
1476
+ project. testClient. send (
1477
+ DidChangeWatchedFilesNotification ( changes: [ FileEvent ( uri: DocumentURI ( symlink) , type: . changed) ] )
1478
+ )
1479
+ try await project. testClient. send ( PollIndexRequest ( ) )
1480
+
1481
+ let callsAfterRedirect = try await project. testClient. send ( CallHierarchyIncomingCallsRequest ( item: initialItem) )
1482
+ XCTAssertEqual ( callsAfterRedirect? . only? . from. name, " updated() " )
1483
+ }
1423
1484
}
1424
1485
1425
1486
extension HoverResponseContents {
0 commit comments