Skip to content

Commit cffdada

Browse files
committed
Send source text for find-syntactic-rename-ranges
1 parent 2c41108 commit cffdada

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Sources/SourceKitLSP/Swift/Rename.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ extension SwiftLanguageServer {
302302
let skreq = SKDRequestDictionary(sourcekitd: sourcekitd)
303303
skreq[keys.request] = requests.find_syntactic_rename_ranges
304304
skreq[keys.sourcefile] = snapshot.uri.pseudoPath
305+
// find-syntactic-rename-ranges is a syntactic sourcekitd request that doesn't use the in-memory file snapshot.
306+
// We need to send the source text again.
307+
skreq[keys.sourcetext] = snapshot.text
305308
skreq[keys.renamelocations] = renameLocations
306309

307310
let syntacticRenameRangesResponse = try await sourcekitd.send(skreq, fileContents: snapshot.text)

Tests/SourceKitLSPTests/RenameTests.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ private func assertRename(
3939
file: StaticString = #file,
4040
line: UInt = #line
4141
) async throws {
42-
// FIXME: syntactic rename does not support in-memory files... It should
43-
let ws = try await IndexedSingleSwiftFileWorkspace(markedSource)
44-
let response = try await ws.testClient.send(
42+
let testClient = try await TestSourceKitLSPClient()
43+
let uri = DocumentURI.for(.swift)
44+
let positions = testClient.openDocument(markedSource, uri: uri)
45+
let response = try await testClient.send(
4546
RenameRequest(
46-
textDocument: TextDocumentIdentifier(ws.fileURI),
47-
position: ws.positions["1️⃣"],
47+
textDocument: TextDocumentIdentifier(uri),
48+
position: positions["1️⃣"],
4849
newName: newName
4950
)
5051
)
51-
let edits = try XCTUnwrap(response?.changes?[ws.fileURI], file: file, line: line)
52+
let edits = try XCTUnwrap(response?.changes?[uri], file: file, line: line)
5253
let source = extractMarkers(markedSource).textWithoutMarkers
5354
let renamed = apply(edits: edits, to: source)
5455
XCTAssertEqual(renamed, expected, file: file, line: line)

0 commit comments

Comments
 (0)