@@ -1371,6 +1371,67 @@ final class BackgroundIndexingTests: XCTestCase {
1371
1371
// also testing that we don't wait for type checking of Test.swift to finish.
1372
1372
XCTAssert ( Date ( ) . timeIntervalSince ( dateStarted) < 30 )
1373
1373
}
1374
+
1375
+ func testRedirectSymlink( ) async throws {
1376
+ let project = try await SwiftPMTestProject (
1377
+ files: [
1378
+ " /original.swift " : """
1379
+ func original() {
1380
+ foo()
1381
+ }
1382
+ """ ,
1383
+ " /updated.swift " : """
1384
+ func updated() {
1385
+ foo()
1386
+ }
1387
+ """ ,
1388
+ " test.swift " : """
1389
+ func 1️⃣foo() {}
1390
+ """ ,
1391
+ ] ,
1392
+ workspaces: { scratchDirectory in
1393
+ let symlink =
1394
+ scratchDirectory
1395
+ . appendingPathComponent ( " Sources " )
1396
+ . appendingPathComponent ( " MyLibrary " )
1397
+ . appendingPathComponent ( " symlink.swift " )
1398
+ try FileManager . default. createSymbolicLink (
1399
+ at: symlink,
1400
+ withDestinationURL: scratchDirectory. appendingPathComponent ( " original.swift " )
1401
+ )
1402
+ return [ WorkspaceFolder ( uri: DocumentURI ( scratchDirectory) ) ]
1403
+ } ,
1404
+ enableBackgroundIndexing: true
1405
+ )
1406
+
1407
+ let ( uri, positions) = try project. openDocument ( " test.swift " )
1408
+
1409
+ let prepare = try await project. testClient. send (
1410
+ CallHierarchyPrepareRequest ( textDocument: TextDocumentIdentifier ( uri) , position: positions [ " 1️⃣ " ] )
1411
+ )
1412
+ let initialItem = try XCTUnwrap ( prepare? . only)
1413
+ let callsBeforeRedirect = try await project. testClient. send ( CallHierarchyIncomingCallsRequest ( item: initialItem) )
1414
+ XCTAssertEqual ( callsBeforeRedirect? . only? . from. name, " original() " )
1415
+
1416
+ let symlink =
1417
+ project. scratchDirectory
1418
+ . appendingPathComponent ( " Sources " )
1419
+ . appendingPathComponent ( " MyLibrary " )
1420
+ . appendingPathComponent ( " symlink.swift " )
1421
+ try FileManager . default. removeItem ( at: symlink)
1422
+ try FileManager . default. createSymbolicLink (
1423
+ at: symlink,
1424
+ withDestinationURL: project. scratchDirectory. appendingPathComponent ( " updated.swift " )
1425
+ )
1426
+
1427
+ project. testClient. send (
1428
+ DidChangeWatchedFilesNotification ( changes: [ FileEvent ( uri: DocumentURI ( symlink) , type: . changed) ] )
1429
+ )
1430
+ try await project. testClient. send ( PollIndexRequest ( ) )
1431
+
1432
+ let callsAfterRedirect = try await project. testClient. send ( CallHierarchyIncomingCallsRequest ( item: initialItem) )
1433
+ XCTAssertEqual ( callsAfterRedirect? . only? . from. name, " updated() " )
1434
+ }
1374
1435
}
1375
1436
1376
1437
extension HoverResponseContents {
0 commit comments