Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adjust Tests
  • Loading branch information
thecoolwinter committed Aug 19, 2025
commit 1a3a7d5575db4e6559e20b6c9260469596dcfd8e
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class SemanticTokenHighlightProvider<

private var tokenMap: SemanticTokenMap?
private var documentURI: String?
private weak var languageServer: LanguageServer<DocumentType>?
weak var languageServer: LanguageServer<DocumentType>?
private weak var textView: TextView?

private var lastEditCallback: EditCallback?
Expand Down
15 changes: 8 additions & 7 deletions CodeEditTests/Features/LSP/LanguageServer+CodeFileDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ final class LanguageServerCodeFileDocumentTests: XCTestCase {
),
lspPid: -1,
serverCapabilities: capabilities,
rootPath: tempTestDir
rootPath: tempTestDir,
logContainer: LanguageServerLogContainer(language: .swift)
)
_ = try await server.lspInstance.initializeIfNeeded()
return (connection: bufferingConnection, server: server)
Expand Down Expand Up @@ -231,13 +232,13 @@ final class LanguageServerCodeFileDocumentTests: XCTestCase {
let (connection, server) = try await makeTestServer()
// Create a CodeFileDocument to test with, attach it to the workspace and file
let codeFile = try await openCodeFile(for: server, connection: connection, file: file, syncOption: option)
XCTAssertNotNil(server.openFiles.contentCoordinator(for: codeFile))
server.openFiles.contentCoordinator(for: codeFile)?.setUpUpdatesTask()
XCTAssertNotNil(codeFile.languageServerObjects.textCoordinator.languageServer)
codeFile.languageServerObjects.textCoordinator.setUpUpdatesTask()
codeFile.content?.replaceString(in: .zero, with: #"func testFunction() -> String { "Hello " }"#)

let textView = TextView(string: "")
textView.setTextStorage(codeFile.content!)
textView.delegate = server.openFiles.contentCoordinator(for: codeFile)
textView.delegate = codeFile.languageServerObjects.textCoordinator

textView.replaceCharacters(in: NSRange(location: 39, length: 0), with: "Worlld")
textView.replaceCharacters(in: NSRange(location: 39, length: 6), with: "")
Expand Down Expand Up @@ -289,13 +290,13 @@ final class LanguageServerCodeFileDocumentTests: XCTestCase {
let (connection, server) = try await makeTestServer()
let codeFile = try await openCodeFile(for: server, connection: connection, file: file, syncOption: option)

XCTAssertNotNil(server.openFiles.contentCoordinator(for: codeFile))
server.openFiles.contentCoordinator(for: codeFile)?.setUpUpdatesTask()
XCTAssertNotNil(codeFile.languageServerObjects.textCoordinator.languageServer)
codeFile.languageServerObjects.textCoordinator.setUpUpdatesTask()
codeFile.content?.replaceString(in: .zero, with: #"func testFunction() -> String { "Hello " }"#)

let textView = TextView(string: "")
textView.setTextStorage(codeFile.content!)
textView.delegate = server.openFiles.contentCoordinator(for: codeFile)
textView.delegate = codeFile.languageServerObjects.textCoordinator
textView.replaceCharacters(in: NSRange(location: 39, length: 0), with: "Worlld")
textView.replaceCharacters(in: NSRange(location: 39, length: 6), with: "")
textView.replaceCharacters(in: NSRange(location: 39, length: 0), with: "World")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ final class LanguageServerDocumentObjectsTests: XCTestCase {
),
lspPid: -1,
serverCapabilities: capabilities,
rootPath: URL(fileURLWithPath: "")
rootPath: URL(fileURLWithPath: ""),
logContainer: LanguageServerLogContainer(language: .swift)
)
_ = try await server.lspInstance.initializeIfNeeded()
document = MockDocumentType()
Expand All @@ -75,7 +76,7 @@ final class LanguageServerDocumentObjectsTests: XCTestCase {
XCTAssertNotNil(server.openFiles.document(for: languageServerURI))

try await server.closeDocument(languageServerURI)
XCTAssertNil(document.languageServerObjects.highlightProvider)
XCTAssertNil(document.languageServerObjects.textCoordinator)
XCTAssertNil(document.languageServerObjects.highlightProvider.languageServer)
XCTAssertNil(document.languageServerObjects.textCoordinator.languageServer)
}
}
Loading