diff --git a/Sources/LSPTestSupport/TestJSONRPCConnection.swift b/Sources/LSPTestSupport/TestJSONRPCConnection.swift index e6de86a3e..34eb8eefc 100644 --- a/Sources/LSPTestSupport/TestJSONRPCConnection.swift +++ b/Sources/LSPTestSupport/TestJSONRPCConnection.swift @@ -95,11 +95,11 @@ public final class TestClient: MessageHandler { public var allowUnexpectedNotification: Bool = true public func appendOneShotNotificationHandler(_ handler: @escaping (Notification) -> Void) { - oneShotNotificationHandlers.append({ anyNote in - guard let note = anyNote as? Notification else { - fatalError("received notification of the wrong type \(anyNote); expected \(N.self)") + oneShotNotificationHandlers.append({ anyNotification in + guard let notification = anyNotification as? Notification else { + fatalError("received notification of the wrong type \(anyNotification); expected \(N.self)") } - handler(note) + handler(notification) }) } @@ -171,15 +171,15 @@ extension TestClient: Connection { /// Send a notification and expect a notification in reply synchronously. /// For testing notifications that behave like requests - e.g. didChange & publishDiagnostics. - public func sendNoteSync( + public func sendNotificationSync( _ notification: some NotificationType, _ handler: @escaping (Notification) -> Void ) { - let expectation = XCTestExpectation(description: "sendNoteSync - note received") + let expectation = XCTestExpectation(description: "sendNotificationSync - notification received") - handleNextNotification { (note: Notification) in - handler(note) + handleNextNotification { (notification: Notification) in + handler(notification) expectation.fulfill() } @@ -194,21 +194,21 @@ extension TestClient: Connection { /// Send a notification and expect two notifications in reply synchronously. /// For testing notifications that behave like requests - e.g. didChange & publishDiagnostics. - public func sendNoteSync( + public func sendNotificationSync( _ notification: NSend, _ handler1: @escaping (Notification) -> Void, _ handler2: @escaping (Notification) -> Void ) where NSend: NotificationType { - let expectation = XCTestExpectation(description: "sendNoteSync - note received") + let expectation = XCTestExpectation(description: "sendNotificationSync - notification received") expectation.expectedFulfillmentCount = 2 - handleNextNotification { (note: Notification) in - handler1(note) + handleNextNotification { (notification: Notification) in + handler1(notification) expectation.fulfill() } - appendOneShotNotificationHandler { (note: Notification) in - handler2(note) + appendOneShotNotificationHandler { (notification: Notification) in + handler2(notification) expectation.fulfill() } @@ -230,9 +230,9 @@ public final class TestServer: MessageHandler { } public func handle(_ params: N, from clientID: ObjectIdentifier) { - let note = Notification(params, clientID: clientID) + let notification = Notification(params, clientID: clientID) if params is EchoNotification { - self.client.send(note.params) + self.client.send(notification.params) } else { fatalError("Unhandled notification") } @@ -312,7 +312,7 @@ public struct EchoError: RequestType { } public struct EchoNotification: NotificationType { - public static var method: String = "test_server/echo_note" + public static var method: String = "test_server/echo_notification" public var string: String diff --git a/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift b/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift index 609427f77..6fba1d0c1 100644 --- a/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift +++ b/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift @@ -366,8 +366,8 @@ extension ClangLanguageServerShim { /// Intercept clangd's `PublishDiagnosticsNotification` to withold it if we're using fallback /// build settings. - func publishDiagnostics(_ note: Notification) async { - let params = note.params + func publishDiagnostics(_ notification: Notification) async { + let params = notification.params // Technically, the publish diagnostics notification could still originate // from when we opened the file with fallback build settings and we could // have received real build settings since, which haven't been acknowledged @@ -394,7 +394,7 @@ extension ClangLanguageServerShim { ) ) } else { - await sourceKitServer.sendNotificationToClient(note.params) + await sourceKitServer.sendNotificationToClient(notification.params) } } @@ -431,30 +431,30 @@ extension ClangLanguageServerShim { // MARK: - Text synchronization - public func openDocument(_ note: DidOpenTextDocumentNotification) async { - openDocuments[note.textDocument.uri] = note.textDocument.language + public func openDocument(_ notification: DidOpenTextDocumentNotification) async { + openDocuments[notification.textDocument.uri] = notification.textDocument.language // Send clangd the build settings for the new file. We need to do this before // sending the open notification, so that the initial diagnostics already // have build settings. - await documentUpdatedBuildSettings(note.textDocument.uri) - clangd.send(note) + await documentUpdatedBuildSettings(notification.textDocument.uri) + clangd.send(notification) } - public func closeDocument(_ note: DidCloseTextDocumentNotification) { - openDocuments[note.textDocument.uri] = nil - clangd.send(note) + public func closeDocument(_ notification: DidCloseTextDocumentNotification) { + openDocuments[notification.textDocument.uri] = nil + clangd.send(notification) } - public func changeDocument(_ note: DidChangeTextDocumentNotification) { - clangd.send(note) + public func changeDocument(_ notification: DidChangeTextDocumentNotification) { + clangd.send(notification) } - public func willSaveDocument(_ note: WillSaveTextDocumentNotification) { + public func willSaveDocument(_ notification: WillSaveTextDocumentNotification) { } - public func didSaveDocument(_ note: DidSaveTextDocumentNotification) { - clangd.send(note) + public func didSaveDocument(_ notification: DidSaveTextDocumentNotification) { + clangd.send(notification) } // MARK: - Build System Integration @@ -476,13 +476,13 @@ extension ClangLanguageServerShim { if let compileCommand = clangBuildSettings?.compileCommand, let pathString = (try? AbsolutePath(validating: url.path))?.pathString { - let note = DidChangeConfigurationNotification( + let notification = DidChangeConfigurationNotification( settings: .clangd( ClangWorkspaceSettings( compilationDatabaseChanges: [pathString: compileCommand]) ) ) - clangd.send(note) + clangd.send(notification) } } @@ -490,12 +490,12 @@ extension ClangLanguageServerShim { // In order to tell clangd to reload an AST, we send it an empty `didChangeTextDocument` // with `forceRebuild` set in case any missing header files have been added. // This works well for us as the moment since clangd ignores the document version. - let note = DidChangeTextDocumentNotification( + let notification = DidChangeTextDocumentNotification( textDocument: VersionedTextDocumentIdentifier(uri, version: 0), contentChanges: [], forceRebuild: true ) - clangd.send(note) + clangd.send(notification) } // MARK: - Text Document diff --git a/Sources/SourceKitLSP/DocumentManager.swift b/Sources/SourceKitLSP/DocumentManager.swift index d4820465d..59ec06a75 100644 --- a/Sources/SourceKitLSP/DocumentManager.swift +++ b/Sources/SourceKitLSP/DocumentManager.swift @@ -200,17 +200,17 @@ extension DocumentManager { /// Convenience wrapper for `open(_:language:version:text:)` that logs on failure. @discardableResult - func open(_ note: DidOpenTextDocumentNotification) -> DocumentSnapshot? { - let doc = note.textDocument + func open(_ notification: DidOpenTextDocumentNotification) -> DocumentSnapshot? { + let doc = notification.textDocument return orLog("failed to open document", level: .error) { try open(doc.uri, language: doc.language, version: doc.version, text: doc.text) } } /// Convenience wrapper for `close(_:)` that logs on failure. - func close(_ note: DidCloseTextDocumentNotification) { + func close(_ notification: DidCloseTextDocumentNotification) { orLog("failed to close document", level: .error) { - try close(note.textDocument.uri) + try close(notification.textDocument.uri) } } @@ -218,14 +218,14 @@ extension DocumentManager { /// that logs on failure. @discardableResult func edit( - _ note: DidChangeTextDocumentNotification, + _ notification: DidChangeTextDocumentNotification, willEditDocument: ((_ before: LineTable, TextDocumentContentChangeEvent) -> Void)? = nil ) -> (preEditSnapshot: DocumentSnapshot, postEditSnapshot: DocumentSnapshot)? { return orLog("failed to edit document", level: .error) { return try edit( - note.textDocument.uri, - newVersion: note.textDocument.version, - edits: note.contentChanges, + notification.textDocument.uri, + newVersion: notification.textDocument.version, + edits: notification.contentChanges, willEditDocument: willEditDocument ) } diff --git a/Sources/SourceKitLSP/SourceKitServer.swift b/Sources/SourceKitLSP/SourceKitServer.swift index eea1cfabc..071ceb49f 100644 --- a/Sources/SourceKitLSP/SourceKitServer.swift +++ b/Sources/SourceKitLSP/SourceKitServer.swift @@ -1033,12 +1033,12 @@ extension SourceKitServer { await openDocument(notification, workspace: workspace) } - private func openDocument(_ note: DidOpenTextDocumentNotification, workspace: Workspace) async { + private func openDocument(_ notification: DidOpenTextDocumentNotification, workspace: Workspace) async { // Immediately open the document even if the build system isn't ready. This is important since // we check that the document is open when we receive messages from the build system. - documentManager.open(note) + documentManager.open(notification) - let textDocument = note.textDocument + let textDocument = notification.textDocument let uri = textDocument.uri let language = textDocument.language @@ -1050,7 +1050,7 @@ extension SourceKitServer { await workspace.buildSystemManager.registerForChangeNotifications(for: uri, language: language) // If the document is ready, we can immediately send the notification. - await service.openDocument(note) + await service.openDocument(notification) } func closeDocument(_ notification: DidCloseTextDocumentNotification) async { @@ -1062,16 +1062,16 @@ extension SourceKitServer { await self.closeDocument(notification, workspace: workspace) } - func closeDocument(_ note: DidCloseTextDocumentNotification, workspace: Workspace) async { + func closeDocument(_ notification: DidCloseTextDocumentNotification, workspace: Workspace) async { // Immediately close the document. We need to be sure to clear our pending work queue in case // the build system still isn't ready. - documentManager.close(note) + documentManager.close(notification) - let uri = note.textDocument.uri + let uri = notification.textDocument.uri await workspace.buildSystemManager.unregisterForChangeNotifications(for: uri) - await workspace.documentService[uri]?.closeDocument(note) + await workspace.documentService[uri]?.closeDocument(notification) } func changeDocument(_ notification: DidChangeTextDocumentNotification) async { @@ -1098,10 +1098,10 @@ extension SourceKitServer { } func didSaveDocument( - _ note: DidSaveTextDocumentNotification, + _ notification: DidSaveTextDocumentNotification, languageService: ToolchainLanguageServer ) async { - await languageService.didSaveDocument(note) + await languageService.didSaveDocument(notification) } func didChangeWorkspaceFolders(_ notification: DidChangeWorkspaceFoldersNotification) async { diff --git a/Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift b/Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift index bb48be76d..8d81c2fc0 100644 --- a/Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift +++ b/Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift @@ -92,9 +92,9 @@ public actor SwiftLanguageServer: ToolchainLanguageServer { let sourcekitd: SourceKitD - /// Queue on which notifications from sourcekitd are handled to ensure we are + /// Queue on which notes from sourcekitd are handled to ensure we are /// handling them in-order. - let sourcekitdNotificationHandlingQueue = AsyncQueue(.serial) + let sourcekitdNoteHandlingQueue = AsyncQueue(.serial) let capabilityRegistry: CapabilityRegistry @@ -119,9 +119,9 @@ public actor SwiftLanguageServer: ToolchainLanguageServer { var enablePublishDiagnostics: Bool { // Since LSP 3.17.0, diagnostics can be reported through pull-based requests, - // in addition to the existing push-based publish notifications. + // in addition to the existing push-based publish notes. // If the client supports pull diagnostics, we report the capability - // and we should disable the publish notifications to avoid double-reporting. + // and we should disable the publish notes to avoid double-reporting. return capabilityRegistry.pullDiagnosticsRegistration(for: .swift) == nil } @@ -294,8 +294,8 @@ public actor SwiftLanguageServer: ToolchainLanguageServer { isFromFallbackBuildSettings: compileCommand?.isFallback ?? true ) - await sourceKitServer?.sendNotificationToClient( - PublishDiagnosticsNotification( + await sourceKitServer?.sendNoteToClient( + PublishDiagnosticsNote( uri: documentUri, version: snapshot.version, diagnostics: diagnostics @@ -337,7 +337,7 @@ public actor SwiftLanguageServer: ToolchainLanguageServer { extension SwiftLanguageServer { public func initializeSync(_ initialize: InitializeRequest) throws -> InitializeResult { - sourcekitd.addNotificationHandler(self) + sourcekitd.addNoteHandler(self) return InitializeResult( capabilities: ServerCapabilities( @@ -390,7 +390,7 @@ extension SwiftLanguageServer { ) } - public func clientInitialized(_: InitializedNotification) { + public func clientInitialized(_: InitializedNote) { // Nothing to do. } @@ -399,7 +399,7 @@ extension SwiftLanguageServer { await session.close() self.currentCompletionSession = nil } - self.sourcekitd.removeNotificationHandler(self) + self.sourcekitd.removeNoteHandler(self) } /// Tell sourcekitd to crash itself. For testing purposes only. @@ -462,7 +462,7 @@ extension SwiftLanguageServer { // MARK: - Text synchronization - public func openDocument(_ note: DidOpenTextDocumentNotification) async { + public func openDocument(_ note: DidOpenTextDocumentNote) async { let keys = self.keys guard let snapshot = self.documentManager.open(note) else { @@ -488,7 +488,7 @@ extension SwiftLanguageServer { await self.publishDiagnostics(response: dict, for: snapshot, compileCommand: compileCommand) } - public func closeDocument(_ note: DidCloseTextDocumentNotification) async { + public func closeDocument(_ note: DidCloseTextDocumentNote) async { let keys = self.keys self.documentManager.close(note) @@ -507,7 +507,7 @@ extension SwiftLanguageServer { await semanticTokensManager.discardSemanticTokens(for: note.textDocument.uri) } - public func changeDocument(_ note: DidChangeTextDocumentNotification) async { + public func changeDocument(_ note: DidChangeTextDocumentNote) async { let keys = self.keys var edits: [IncrementalEdit] = [] @@ -565,11 +565,11 @@ extension SwiftLanguageServer { } } - public func willSaveDocument(_ note: WillSaveTextDocumentNotification) { + public func willSaveDocument(_ note: WillSaveTextDocumentNote) { } - public func didSaveDocument(_ note: DidSaveTextDocumentNotification) { + public func didSaveDocument(_ note: DidSaveTextDocumentNote) { } @@ -1328,21 +1328,21 @@ extension SwiftLanguageServer { } } -extension SwiftLanguageServer: SKDNotificationHandler { - public nonisolated func notification(_ notification: SKDResponse) { - sourcekitdNotificationHandlingQueue.async { - await self.notificationImpl(notification) +extension SwiftLanguageServer: SKDNoteHandler { + public nonisolated func note(_ note: SKDResponse) { + sourcekitdNoteHandlingQueue.async { + await self.noteImpl(note) } } - private func notificationImpl(_ notification: SKDResponse) async { - // Check if we need to update our `state` based on the contents of the notification. - if notification.value?[self.keys.notification] == self.values.notification_sema_enabled { + private func noteImpl(_ note: SKDResponse) async { + // Check if we need to update our `state` based on the contents of the note. + if note.value?[self.keys.note] == self.values.note_sema_enabled { self.state = .connected } if self.state == .connectionInterrupted { - // If we get a notification while we are restoring the connection, it means that the server has restarted. + // If we get a note while we are restoring the connection, it means that the server has restarted. // We still need to wait for semantic functionality to come back up. self.state = .semanticFunctionalityDisabled @@ -1354,7 +1354,7 @@ extension SwiftLanguageServer: SKDNotificationHandler { } } - if notification.error == .connectionInterrupted { + if note.error == .connectionInterrupted { self.state = .connectionInterrupted // We don't have any open documents anymore after sourcekitd crashed. @@ -1362,15 +1362,15 @@ extension SwiftLanguageServer: SKDNotificationHandler { self.documentManager = DocumentManager() } - guard let dict = notification.value else { - log(notification.description, level: .error) + guard let dict = note.value else { + log(note.description, level: .error) return } - logAsync(level: .debug) { _ in notification.description } + logAsync(level: .debug) { _ in note.description } - if let kind: sourcekitd_uid_t = dict[self.keys.notification], - kind == self.values.notification_documentupdate, + if let kind: sourcekitd_uid_t = dict[self.keys.note], + kind == self.values.note_documentupdate, let name: String = dict[self.keys.name] { diff --git a/Tests/LanguageServerProtocolJSONRPCTests/ConnectionTests.swift b/Tests/LanguageServerProtocolJSONRPCTests/ConnectionTests.swift index 56f3631f9..f1846e720 100644 --- a/Tests/LanguageServerProtocolJSONRPCTests/ConnectionTests.swift +++ b/Tests/LanguageServerProtocolJSONRPCTests/ConnectionTests.swift @@ -58,37 +58,37 @@ class ConnectionTests: XCTestCase { func testMessageBuffer() throws { let client = connection.client let clientConnection = connection.clientConnection - let expectation = self.expectation(description: "note received") + let expectation = self.expectation(description: "notification received") - client.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.string, "hello!") + client.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.string, "hello!") expectation.fulfill() } - let note1 = try JSONEncoder().encode(JSONRPCMessage.notification(EchoNotification(string: "hello!"))) - let note2 = try JSONEncoder().encode(JSONRPCMessage.notification(EchoNotification(string: "no way!"))) + let notification1 = try JSONEncoder().encode(JSONRPCMessage.notification(EchoNotification(string: "hello!"))) + let notification2 = try JSONEncoder().encode(JSONRPCMessage.notification(EchoNotification(string: "no way!"))) - let note1Str: String = "Content-Length: \(note1.count)\r\n\r\n\(String(data: note1, encoding: .utf8)!)" - let note2Str: String = "Content-Length: \(note2.count)\r\n\r\n\(String(data: note2, encoding: .utf8)!)" + let notification1Str: String = "Content-Length: \(notification1.count)\r\n\r\n\(String(data: notification1, encoding: .utf8)!)" + let notification2Str: String = "Content-Length: \(notification2.count)\r\n\r\n\(String(data: notification2, encoding: .utf8)!)" - for b in note1Str.utf8.dropLast() { + for b in notification1Str.utf8.dropLast() { clientConnection.send(_rawData: [b].withUnsafeBytes { DispatchData(bytes: $0) }) } clientConnection.send( - _rawData: [note1Str.utf8.last!, note2Str.utf8.first!].withUnsafeBytes { DispatchData(bytes: $0) } + _rawData: [notification1Str.utf8.last!, notification2Str.utf8.first!].withUnsafeBytes { DispatchData(bytes: $0) } ) waitForExpectations(timeout: defaultTimeout) - let expectation2 = self.expectation(description: "note received") + let expectation2 = self.expectation(description: "notification received") - client.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.string, "no way!") + client.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.string, "no way!") expectation2.fulfill() } - for b in note2Str.utf8.dropFirst() { + for b in notification2Str.utf8.dropFirst() { clientConnection.send(_rawData: [b].withUnsafeBytes { DispatchData(bytes: $0) }) } @@ -121,12 +121,12 @@ class ConnectionTests: XCTestCase { waitForExpectations(timeout: defaultTimeout) } - func testEchoNote() { + func testEchoNotification() { let client = connection.client - let expectation = self.expectation(description: "note received") + let expectation = self.expectation(description: "notification received") - client.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.string, "hello!") + client.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.string, "hello!") expectation.fulfill() } @@ -154,13 +154,13 @@ class ConnectionTests: XCTestCase { func testUnknownNotification() { let client = connection.client - let expectation = self.expectation(description: "note received") + let expectation = self.expectation(description: "notification received") - struct UnknownNote: NotificationType { + struct UnknownNotification: NotificationType { static let method: String = "unknown" } - client.send(UnknownNote()) + client.send(UnknownNotification()) // Nothing bad should happen; check that the next request works. @@ -195,7 +195,7 @@ class ConnectionTests: XCTestCase { func testSendAfterClose() { let client = connection.client - let expectation = self.expectation(description: "note received") + let expectation = self.expectation(description: "notification received") connection.clientConnection.close() @@ -218,7 +218,7 @@ class ConnectionTests: XCTestCase { let server = connection.server let expectation = self.expectation(description: "received notification") - client.handleNextNotification { (note: Notification) in + client.handleNextNotification { (notification: Notification) in expectation.fulfill() } @@ -232,7 +232,7 @@ class ConnectionTests: XCTestCase { let client = connection.client let expectation = self.expectation(description: "received notification") - client.handleNextNotification { (note: Notification) in + client.handleNextNotification { (notification: Notification) in expectation.fulfill() } let notification = EchoNotification(string: "about to close!") diff --git a/Tests/LanguageServerProtocolTests/ConnectionTests.swift b/Tests/LanguageServerProtocolTests/ConnectionTests.swift index 903f2ca96..015a80e2b 100644 --- a/Tests/LanguageServerProtocolTests/ConnectionTests.swift +++ b/Tests/LanguageServerProtocolTests/ConnectionTests.swift @@ -64,12 +64,12 @@ class ConnectionTests: XCTestCase { waitForExpectations(timeout: defaultTimeout) } - func testEchoNote() { + func testEchoNotification() { let client = connection.client - let expectation = self.expectation(description: "note received") + let expectation = self.expectation(description: "notification received") - client.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.string, "hello!") + client.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.string, "hello!") expectation.fulfill() } diff --git a/Tests/SourceKitDTests/CrashRecoveryTests.swift b/Tests/SourceKitDTests/CrashRecoveryTests.swift index bacf74156..b9fd31d4a 100644 --- a/Tests/SourceKitDTests/CrashRecoveryTests.swift +++ b/Tests/SourceKitDTests/CrashRecoveryTests.swift @@ -55,12 +55,12 @@ final class CrashRecoveryTests: XCTestCase { let documentOpened = self.expectation(description: "documentOpened") documentOpened.expectedFulfillmentCount = 2 - ws.sk.handleNextNotification({ (note: LanguageServerProtocol.Notification) in + ws.sk.handleNextNotification({ (notification: LanguageServerProtocol.Notification) in log("Received diagnostics for open - syntactic") documentOpened.fulfill() }) ws.sk.appendOneShotNotificationHandler({ - (note: LanguageServerProtocol.Notification) in + (notification: LanguageServerProtocol.Notification) in log("Received diagnostics for open - semantic") documentOpened.fulfill() }) @@ -79,15 +79,15 @@ final class CrashRecoveryTests: XCTestCase { } """ ) - ws.sk.sendNoteSync( + ws.sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: VersionedTextDocumentIdentifier(loc.docUri, version: 2), contentChanges: [addFuncChange] ), - { (note: LanguageServerProtocol.Notification) -> Void in + { (notification: LanguageServerProtocol.Notification) -> Void in log("Received diagnostics for text edit - syntactic") }, - { (note: LanguageServerProtocol.Notification) -> Void in + { (notification: LanguageServerProtocol.Notification) -> Void in log("Received diagnostics for text edit - semantic") } ) diff --git a/Tests/SourceKitLSPTests/BuildSystemTests.swift b/Tests/SourceKitLSPTests/BuildSystemTests.swift index 1178d1ff6..97be23157 100644 --- a/Tests/SourceKitLSPTests/BuildSystemTests.swift +++ b/Tests/SourceKitLSPTests/BuildSystemTests.swift @@ -169,7 +169,7 @@ final class BuildSystemTests: XCTestCase { let documentManager = await self.testServer.server!._documentManager - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: doc, @@ -178,8 +178,8 @@ final class BuildSystemTests: XCTestCase { text: text ) ), - { (note: Notification) in - XCTAssertEqual(note.params.diagnostics.count, 1) + { (notification: Notification) in + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual(text, documentManager.latestSnapshot(doc)!.text) } ) @@ -190,8 +190,8 @@ final class BuildSystemTests: XCTestCase { buildSystem.buildSettingsByFile[doc] = newSettings let expectation = XCTestExpectation(description: "refresh") - sk.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.diagnostics.count, 0) + sk.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.diagnostics.count, 0) XCTAssertEqual(text, documentManager.latestSnapshot(doc)!.text) expectation.fulfill() } @@ -220,7 +220,7 @@ final class BuildSystemTests: XCTestCase { let documentManager = await self.testServer.server!._documentManager - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: doc, @@ -229,14 +229,14 @@ final class BuildSystemTests: XCTestCase { text: text ) ), - { (note: Notification) in + { (notification: Notification) in // Syntactic analysis - no expected errors here. - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) XCTAssertEqual(text, documentManager.latestSnapshot(doc)!.text) }, - { (note: Notification) in + { (notification: Notification) in // Semantic analysis - expect one error here. - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) } ) @@ -247,14 +247,14 @@ final class BuildSystemTests: XCTestCase { let expectation = XCTestExpectation(description: "refresh") expectation.expectedFulfillmentCount = 2 - sk.handleNextNotification { (note: Notification) in + sk.handleNextNotification { (notification: Notification) in // Semantic analysis - SourceKit currently caches diagnostics so we still see an error. - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) expectation.fulfill() } - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNotificationHandler { (notification: Notification) in // Semantic analysis - no expected errors here because we fixed the settings. - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) expectation.fulfill() } await buildSystem.delegate?.fileBuildSettingsChanged([doc]) @@ -287,7 +287,7 @@ final class BuildSystemTests: XCTestCase { let documentManager = await self.testServer.server!._documentManager - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: doc, @@ -296,9 +296,9 @@ final class BuildSystemTests: XCTestCase { text: text ) ), - { (note: Notification) in + { (notification: Notification) in // Expect diagnostics to be withheld. - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) XCTAssertEqual(text, documentManager.latestSnapshot(doc)!.text) } ) @@ -309,8 +309,8 @@ final class BuildSystemTests: XCTestCase { buildSystem.buildSettingsByFile[doc] = newSettings let expectation = XCTestExpectation(description: "refresh due to fallback --> primary") - sk.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.diagnostics.count, 1) + sk.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual(text, documentManager.latestSnapshot(doc)!.text) expectation.fulfill() } @@ -341,7 +341,7 @@ final class BuildSystemTests: XCTestCase { let documentManager = await self.testServer.server!._documentManager - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: doc, @@ -350,14 +350,14 @@ final class BuildSystemTests: XCTestCase { text: text ) ), - { (note: Notification) in + { (notification: Notification) in // Syntactic analysis - one expected errors here (for `func`). - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual(text, documentManager.latestSnapshot(doc)!.text) }, - { (note: Notification) in + { (notification: Notification) in // Should be the same syntactic analysis since we are using fallback arguments - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) } ) @@ -365,14 +365,14 @@ final class BuildSystemTests: XCTestCase { buildSystem.buildSettingsByFile[doc] = primarySettings let expectation = XCTestExpectation(description: "refresh due to fallback --> primary") expectation.expectedFulfillmentCount = 2 - sk.handleNextNotification { (note: Notification) in + sk.handleNextNotification { (notification: Notification) in // Syntactic analysis with new args - one expected errors here (for `func`). - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) expectation.fulfill() } - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNotificationHandler { (notification: Notification) in // Semantic analysis - two errors since `-DFOO` was not passed. - XCTAssertEqual(note.params.diagnostics.count, 2) + XCTAssertEqual(notification.params.diagnostics.count, 2) expectation.fulfill() } await buildSystem.delegate?.fileBuildSettingsChanged([doc]) @@ -389,9 +389,9 @@ final class BuildSystemTests: XCTestCase { ws.testServer.client.allowUnexpectedNotification = false let expectation = self.expectation(description: "initial") - ws.testServer.client.handleNextNotification { (note: Notification) in + ws.testServer.client.handleNextNotification { (notification: Notification) in // Should withhold diagnostics since we should be using fallback arguments. - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) expectation.fulfill() } @@ -399,9 +399,9 @@ final class BuildSystemTests: XCTestCase { try await fulfillmentOfOrThrow([expectation]) let use_d = self.expectation(description: "update settings to d.cpp") - ws.testServer.client.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.diagnostics.count, 1) - if let diag = note.params.diagnostics.first { + ws.testServer.client.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.diagnostics.count, 1) + if let diag = notification.params.diagnostics.first { XCTAssertEqual(diag.severity, .warning) XCTAssertEqual(diag.message, "UNIQUE_INCLUDED_FROM_D") } @@ -412,9 +412,9 @@ final class BuildSystemTests: XCTestCase { try await fulfillmentOfOrThrow([use_d]) let use_c = self.expectation(description: "update settings to c.cpp") - ws.testServer.client.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.diagnostics.count, 1) - if let diag = note.params.diagnostics.first { + ws.testServer.client.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.diagnostics.count, 1) + if let diag = notification.params.diagnostics.first { XCTAssertEqual(diag.severity, .warning) XCTAssertEqual(diag.message, "UNIQUE_INCLUDED_FROM_C") } diff --git a/Tests/SourceKitLSPTests/CodeActionTests.swift b/Tests/SourceKitLSPTests/CodeActionTests.swift index 7bc1dc253..a0c18daf9 100644 --- a/Tests/SourceKitLSPTests/CodeActionTests.swift +++ b/Tests/SourceKitLSPTests/CodeActionTests.swift @@ -301,19 +301,19 @@ final class CodeActionTests: XCTestCase { let syntacticDiagnosticsReceived = self.expectation(description: "Syntactic diagnotistics received") let semanticDiagnosticsReceived = self.expectation(description: "Semantic diagnotistics received") - ws.sk.appendOneShotNotificationHandler { (note: Notification) in + ws.sk.appendOneShotNotificationHandler { (notification: Notification) in // syntactic diagnostics - XCTAssertEqual(note.params.uri, def.docUri) - XCTAssertEqual(note.params.diagnostics, []) + XCTAssertEqual(notification.params.uri, def.docUri) + XCTAssertEqual(notification.params.diagnostics, []) syntacticDiagnosticsReceived.fulfill() } var diags: [Diagnostic]! = nil - ws.sk.appendOneShotNotificationHandler { (note: Notification) in + ws.sk.appendOneShotNotificationHandler { (notification: Notification) in // semantic diagnostics - XCTAssertEqual(note.params.uri, def.docUri) - XCTAssertEqual(note.params.diagnostics.count, 1) - diags = note.params.diagnostics + XCTAssertEqual(notification.params.uri, def.docUri) + XCTAssertEqual(notification.params.diagnostics.count, 1) + diags = notification.params.diagnostics semanticDiagnosticsReceived.fulfill() } diff --git a/Tests/SourceKitLSPTests/LocalClangTests.swift b/Tests/SourceKitLSPTests/LocalClangTests.swift index c6ab9f9ab..031a42b33 100644 --- a/Tests/SourceKitLSPTests/LocalClangTests.swift +++ b/Tests/SourceKitLSPTests/LocalClangTests.swift @@ -233,8 +233,8 @@ final class LocalClangTests: XCTestCase { let expectation = XCTestExpectation(description: "diagnostics") - ws.sk.handleNextNotification { (note: Notification) in - let diagnostics = note.params.diagnostics + ws.sk.handleNextNotification { (notification: Notification) in + let diagnostics = notification.params.diagnostics // It seems we either get no diagnostics or a `-Wswitch` warning. Either is fine // as long as our code action works properly. XCTAssert( @@ -291,15 +291,15 @@ final class LocalClangTests: XCTestCase { let expectation = XCTestExpectation(description: "diagnostics") - ws.sk.handleNextNotification { (note: Notification) in + ws.sk.handleNextNotification { (notification: Notification) in // Don't use exact equality because of differences in recent clang. - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range, + notification.params.diagnostics.first?.range, Position(loc)..) in - XCTAssertEqual(note.params.diagnostics.count, 0) + ws.sk.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.diagnostics.count, 0) expectation.fulfill() } @@ -335,9 +335,9 @@ final class LocalClangTests: XCTestCase { let mainLoc = ws.testLoc("Object:include:main") let diagnostics = self.expectation(description: "diagnostics") - ws.sk.handleNextNotification { (note: Notification) in + ws.sk.handleNextNotification { (notification: Notification) in diagnostics.fulfill() - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) } try ws.openDocument(mainLoc.url, language: .c) @@ -365,8 +365,8 @@ final class LocalClangTests: XCTestCase { // Initially the workspace should build fine. let documentOpened = self.expectation(description: "documentOpened") - ws.sk.handleNextNotification({ (note: LanguageServerProtocol.Notification) in - XCTAssert(note.params.diagnostics.isEmpty) + ws.sk.handleNextNotification({ (notification: LanguageServerProtocol.Notification) in + XCTAssert(notification.params.diagnostics.isEmpty) documentOpened.fulfill() }) @@ -385,8 +385,8 @@ final class LocalClangTests: XCTestCase { // Now we should get a diagnostic in main.c file because `Object` is no longer defined. let updatedNotificationsReceived = self.expectation(description: "updatedNotificationsReceived") - ws.sk.handleNextNotification({ (note: LanguageServerProtocol.Notification) in - XCTAssertFalse(note.params.diagnostics.isEmpty) + ws.sk.handleNextNotification({ (notification: LanguageServerProtocol.Notification) in + XCTAssertFalse(notification.params.diagnostics.isEmpty) updatedNotificationsReceived.fulfill() }) diff --git a/Tests/SourceKitLSPTests/LocalSwiftTests.swift b/Tests/SourceKitLSPTests/LocalSwiftTests.swift index 45004f8e5..8a3ab6a0d 100644 --- a/Tests/SourceKitLSPTests/LocalSwiftTests.swift +++ b/Tests/SourceKitLSPTests/LocalSwiftTests.swift @@ -69,7 +69,7 @@ final class LocalSwiftTests: XCTestCase { let documentManager = await connection.server!._documentManager - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -80,58 +80,58 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") - XCTAssertEqual(note.params.version, 12) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 12) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual("func", documentManager.latestSnapshot(uri)!.text) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.version, 12) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 12) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 0, utf16index: 4) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 13), contentChanges: [ .init(range: Range(Position(line: 0, utf16index: 4)), text: " foo() {}\n") ] ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 1 - syntactic") // 1 = remaining semantic error // 0 = semantic update finished already - XCTAssertEqual(note.params.version, 13) - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 13) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual("func foo() {}\n", documentManager.latestSnapshot(uri)!.text) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 1 - semantic") - XCTAssertEqual(note.params.version, 13) - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.version, 13) + XCTAssertEqual(notification.params.diagnostics.count, 0) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 14), contentChanges: [ .init(range: Range(Position(line: 1, utf16index: 0)), text: "bar()") ] ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 2 - syntactic") - XCTAssertEqual(note.params.version, 14) + XCTAssertEqual(notification.params.version, 14) // 1 = semantic update finished already // 0 = only syntactic - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func foo() {} @@ -140,30 +140,30 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 2 - semantic") - XCTAssertEqual(note.params.version, 14) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 14) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 1, utf16index: 0) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 14), contentChanges: [ .init(range: Position(line: 1, utf16index: 0)..) in + { (notification: Notification) in log("Received diagnostics for edit 3 - syntactic") // 1 = remaining semantic error // 0 = semantic update finished already - XCTAssertEqual(note.params.version, 14) - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 14) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func foo() {} @@ -172,26 +172,26 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 3 - semantic") - XCTAssertEqual(note.params.version, 14) - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.version, 14) + XCTAssertEqual(notification.params.diagnostics.count, 0) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 15), contentChanges: [ .init(range: Position(line: 1, utf16index: 0)..) in + { (notification: Notification) in log("Received diagnostics for edit 4 - syntactic") - XCTAssertEqual(note.params.version, 15) + XCTAssertEqual(notification.params.version, 15) // 1 = semantic update finished already // 0 = only syntactic - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func foo() {} @@ -200,18 +200,18 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 4 - semantic") - XCTAssertEqual(note.params.version, 15) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 15) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 1, utf16index: 0) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 16), contentChanges: [ @@ -224,11 +224,11 @@ final class LocalSwiftTests: XCTestCase { ) ] ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 5 - syntactic") - XCTAssertEqual(note.params.version, 16) + XCTAssertEqual(notification.params.version, 16) // Could be remaining semantic error or new one. - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func bar() {} @@ -237,12 +237,12 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 5 - semantic") - XCTAssertEqual(note.params.version, 16) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 16) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 1, utf16index: 0) ) } @@ -256,7 +256,7 @@ final class LocalSwiftTests: XCTestCase { let documentManager = await connection.server!._documentManager - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -267,58 +267,58 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") - XCTAssertEqual(note.params.version, 12) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 12) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual("func", documentManager.latestSnapshot(uri)!.text) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.version, 12) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 12) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 0, utf16index: 4) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 13), contentChanges: [ .init(range: Range(Position(line: 0, utf16index: 4)), text: " foo() {}\n") ] ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 1 - syntactic") - XCTAssertEqual(note.params.version, 13) + XCTAssertEqual(notification.params.version, 13) // 1 = remaining semantic error // 0 = semantic update finished already - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual("func foo() {}\n", documentManager.latestSnapshot(uri)!.text) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 1 - semantic") - XCTAssertEqual(note.params.version, 13) - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.version, 13) + XCTAssertEqual(notification.params.diagnostics.count, 0) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 14), contentChanges: [ .init(range: Range(Position(line: 1, utf16index: 0)), text: "bar()") ] ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 2 - syntactic") - XCTAssertEqual(note.params.version, 14) + XCTAssertEqual(notification.params.version, 14) // 1 = semantic update finished already // 0 = only syntactic - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func foo() {} @@ -327,30 +327,30 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 2 - semantic") - XCTAssertEqual(note.params.version, 14) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 14) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 1, utf16index: 0) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 14), contentChanges: [ .init(range: Position(line: 1, utf16index: 0)..) in + { (notification: Notification) in log("Received diagnostics for edit 3 - syntactic") - XCTAssertEqual(note.params.version, 14) + XCTAssertEqual(notification.params.version, 14) // 1 = remaining semantic error // 0 = semantic update finished already - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func foo() {} @@ -359,26 +359,26 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 3 - semantic") - XCTAssertEqual(note.params.version, 14) - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.version, 14) + XCTAssertEqual(notification.params.diagnostics.count, 0) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 15), contentChanges: [ .init(range: Position(line: 1, utf16index: 0)..) in + { (notification: Notification) in log("Received diagnostics for edit 4 - syntactic") - XCTAssertEqual(note.params.version, 15) + XCTAssertEqual(notification.params.version, 15) // 1 = semantic update finished already // 0 = only syntactic - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func foo() {} @@ -387,18 +387,18 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 4 - semantic") - XCTAssertEqual(note.params.version, 15) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 15) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 1, utf16index: 0) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 16), contentChanges: [ @@ -411,11 +411,11 @@ final class LocalSwiftTests: XCTestCase { ) ] ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 5 - syntactic") - XCTAssertEqual(note.params.version, 16) + XCTAssertEqual(notification.params.version, 16) // Could be remaining semantic error or new one. - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( """ func bar() {} @@ -424,12 +424,12 @@ final class LocalSwiftTests: XCTestCase { documentManager.latestSnapshot(uri)!.text ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 5 - semantic") - XCTAssertEqual(note.params.version, 16) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 16) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 1, utf16index: 0) ) } @@ -461,7 +461,7 @@ final class LocalSwiftTests: XCTestCase { ) ) - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: includedURI, @@ -470,13 +470,13 @@ final class LocalSwiftTests: XCTestCase { text: text ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") - XCTAssertEqual(note.params.uri, includedURI) + XCTAssertEqual(notification.params.uri, includedURI) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.uri, includedURI) + XCTAssertEqual(notification.params.uri, includedURI) } ) } @@ -489,7 +489,7 @@ final class LocalSwiftTests: XCTestCase { sk.allowUnexpectedNotification = false - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uriA, @@ -500,25 +500,25 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") - XCTAssertEqual(note.params.version, 12) + XCTAssertEqual(notification.params.version, 12) // 1 = semantic update finished already // 0 = only syntactic - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.version, 12) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 12) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 0, utf16index: 0) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uriB, @@ -529,40 +529,40 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") - XCTAssertEqual(note.params.version, 12) + XCTAssertEqual(notification.params.version, 12) // 1 = semantic update finished already // 0 = only syntactic - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.version, 12) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 12) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 0, utf16index: 0) ) } ) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uriA, version: 13), contentChanges: [ .init(range: nil, text: "foo()\n") ] ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 1 - syntactic") - XCTAssertEqual(note.params.version, 13) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 13) + XCTAssertEqual(notification.params.diagnostics.count, 1) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for edit 1 - semantic") - XCTAssertEqual(note.params.version, 13) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 13) + XCTAssertEqual(notification.params.diagnostics.count, 1) } ) } @@ -572,7 +572,7 @@ final class LocalSwiftTests: XCTestCase { let uriA = DocumentURI(urlA) sk.allowUnexpectedNotification = false - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uriA, @@ -583,19 +583,19 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") - XCTAssertEqual(note.params.version, 12) + XCTAssertEqual(notification.params.version, 12) // 1 = semantic update finished already // 0 = only syntactic - XCTAssertLessThanOrEqual(note.params.diagnostics.count, 1) + XCTAssertLessThanOrEqual(notification.params.diagnostics.count, 1) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.version, 12) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 12) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 0, utf16index: 0) ) } @@ -603,7 +603,7 @@ final class LocalSwiftTests: XCTestCase { sk.send(DidCloseTextDocumentNotification(textDocument: .init(urlA))) - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uriA, @@ -614,35 +614,35 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") - XCTAssertEqual(note.params.version, 13) + XCTAssertEqual(notification.params.version, 13) // 1 = syntactic, no cached semantic diagnostic from previous version - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 0, utf16index: 3) ) }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.version, 13) - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.version, 13) + XCTAssertEqual(notification.params.diagnostics.count, 1) XCTAssertEqual( - note.params.diagnostics.first?.range.lowerBound, + notification.params.diagnostics.first?.range.lowerBound, Position(line: 0, utf16index: 3) ) } ) } - func testEducationalNotesAreUsedAsDiagnosticCodes() { + func testEducationalNotificationsAreUsedAsDiagnosticCodes() { let url = URL(fileURLWithPath: "/\(UUID())/a.swift") let uri = DocumentURI(url) sk.allowUnexpectedNotification = false - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -651,13 +651,13 @@ final class LocalSwiftTests: XCTestCase { text: "@propertyWrapper struct Bar {}" ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - let diag = note.params.diagnostics.first! + XCTAssertEqual(notification.params.diagnostics.count, 1) + let diag = notification.params.diagnostics.first! XCTAssertEqual(diag.code, .string("property-wrapper-requirements")) XCTAssertEqual(diag.codeDescription?.href.fileURL?.lastPathComponent, "property-wrapper-requirements.md") } @@ -670,7 +670,7 @@ final class LocalSwiftTests: XCTestCase { sk.allowUnexpectedNotification = false - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -683,13 +683,13 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - let diag = note.params.diagnostics.first! + XCTAssertEqual(notification.params.diagnostics.count, 1) + let diag = notification.params.diagnostics.first! XCTAssertNotNil(diag.codeActions) XCTAssertEqual(diag.codeActions!.count, 1) let fixit = diag.codeActions!.first! @@ -713,13 +713,13 @@ final class LocalSwiftTests: XCTestCase { ) } - func testFixitsAreIncludedInPublishDiagnosticsNotes() { + func testFixitsAreIncludedInPublishDiagnosticsNotifications() { let url = URL(fileURLWithPath: "/\(UUID())/a.swift") let uri = DocumentURI(url) sk.allowUnexpectedNotification = false - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -732,17 +732,17 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - let diag = note.params.diagnostics.first! + XCTAssertEqual(notification.params.diagnostics.count, 1) + let diag = notification.params.diagnostics.first! XCTAssertEqual(diag.relatedInformation?.count, 2) - if let note1 = diag.relatedInformation?.first(where: { $0.message.contains("'?'") }) { - XCTAssertEqual(note1.codeActions?.count, 1) - if let fixit = note1.codeActions?.first { + if let notification1 = diag.relatedInformation?.first(where: { $0.message.contains("'?'") }) { + XCTAssertEqual(notification1.codeActions?.count, 1) + if let fixit = notification1.codeActions?.first { // Expected Fix-it: Replace `let a` with `_` because it's never used let expectedTextEdit = TextEdit( range: Position(line: 1, utf16index: 7)..) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - let diag = note.params.diagnostics.first! + XCTAssertEqual(notification.params.diagnostics.count, 1) + let diag = notification.params.diagnostics.first! XCTAssertNotNil(diag.codeActions) XCTAssertEqual(diag.codeActions!.count, 1) let fixit = diag.codeActions!.first! @@ -848,7 +848,7 @@ final class LocalSwiftTests: XCTestCase { let uri = DocumentURI(url) var diagnostic: Diagnostic? = nil - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -861,13 +861,13 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - diagnostic = note.params.diagnostics.first + XCTAssertEqual(notification.params.diagnostics.count, 1) + diagnostic = notification.params.diagnostics.first } ) @@ -911,12 +911,12 @@ final class LocalSwiftTests: XCTestCase { ) } - func testFixitsAreReturnedFromCodeActionsNotes() throws { + func testFixitsAreReturnedFromCodeActionsNotifications() throws { let url = URL(fileURLWithPath: "/\(UUID())/a.swift") let uri = DocumentURI(url) var diagnostic: Diagnostic? - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -929,13 +929,13 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - diagnostic = note.params.diagnostics.first + XCTAssertEqual(notification.params.diagnostics.count, 1) + diagnostic = notification.params.diagnostics.first } ) @@ -985,7 +985,7 @@ final class LocalSwiftTests: XCTestCase { let uri = DocumentURI(url) var diagnostic: Diagnostic? - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -997,13 +997,13 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - diagnostic = note.params.diagnostics.first + XCTAssertEqual(notification.params.diagnostics.count, 1) + diagnostic = notification.params.diagnostics.first } ) @@ -1037,12 +1037,12 @@ final class LocalSwiftTests: XCTestCase { ) } - func testMuliEditFixitCodeActionNote() throws { + func testMuliEditFixitCodeActionNotification() throws { let url = URL(fileURLWithPath: "/\(UUID())/a.swift") let uri = DocumentURI(url) var diagnostic: Diagnostic? - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -1057,13 +1057,13 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - syntactic") }, - { (note: Notification) in + { (notification: Notification) in log("Received diagnostics for open - semantic") - XCTAssertEqual(note.params.diagnostics.count, 1) - diagnostic = note.params.diagnostics.first! + XCTAssertEqual(notification.params.diagnostics.count, 1) + diagnostic = notification.params.diagnostics.first! } ) @@ -1948,7 +1948,7 @@ final class LocalSwiftTests: XCTestCase { await swiftLanguageServer.setReusedNodeCallback({ reusedNodes.append($0) }) sk.allowUnexpectedNotification = false - sk.sendNoteSync( + sk.sendNotificationSync( DidOpenTextDocumentNotification( textDocument: TextDocumentItem( uri: uri, @@ -1962,10 +1962,10 @@ final class LocalSwiftTests: XCTestCase { """ ) ), - { (note: LanguageServerProtocol.Notification) -> Void in + { (notification: LanguageServerProtocol.Notification) -> Void in log("Received diagnostics for open - syntactic") }, - { (note: LanguageServerProtocol.Notification) -> Void in + { (notification: LanguageServerProtocol.Notification) -> Void in log("Received diagnostics for open - semantic") } ) @@ -1973,17 +1973,17 @@ final class LocalSwiftTests: XCTestCase { // Send a request that triggers a syntax tree to be built. _ = try sk.sendSync(FoldingRangeRequest(textDocument: .init(uri))) - sk.sendNoteSync( + sk.sendNotificationSync( DidChangeTextDocumentNotification( textDocument: .init(uri, version: 1), contentChanges: [ .init(range: Range(Position(line: 2, utf16index: 7)), text: "a") ] ), - { (note: LanguageServerProtocol.Notification) -> Void in + { (notification: LanguageServerProtocol.Notification) -> Void in log("Received diagnostics for text edit - syntactic") }, - { (note: LanguageServerProtocol.Notification) -> Void in + { (notification: LanguageServerProtocol.Notification) -> Void in log("Received diagnostics for text edit - semantic") } ) diff --git a/Tests/SourceKitLSPTests/PublishDiagnosticsTests.swift b/Tests/SourceKitLSPTests/PublishDiagnosticsTests.swift index 5db0735da..14ed1b0b8 100644 --- a/Tests/SourceKitLSPTests/PublishDiagnosticsTests.swift +++ b/Tests/SourceKitLSPTests/PublishDiagnosticsTests.swift @@ -52,7 +52,7 @@ final class PublishDiagnosticsTests: XCTestCase { private func openDocument(text: String) { sk.send( - DidOpenTextDocumentNotification( + DidOpenTextDocumentNote( textDocument: TextDocumentItem( uri: uri, language: .swift, @@ -66,7 +66,7 @@ final class PublishDiagnosticsTests: XCTestCase { private func editDocument(changes: [TextDocumentContentChangeEvent]) { sk.send( - DidChangeTextDocumentNotification( + DidChangeTextDocumentNote( textDocument: VersionedTextDocumentIdentifier( uri, version: version @@ -80,13 +80,13 @@ final class PublishDiagnosticsTests: XCTestCase { let syntacticDiagnosticsReceived = self.expectation(description: "Syntactic diagnotistics received") let semanticDiagnosticsReceived = self.expectation(description: "Semantic diagnotistics received") - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in // Unresolved identifier is not a syntactic diagnostic. XCTAssertEqual(note.params.diagnostics, []) syntacticDiagnosticsReceived.fulfill() } - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in XCTAssertEqual(note.params.diagnostics.count, 1) XCTAssertEqual( note.params.diagnostics.first?.range, @@ -112,13 +112,13 @@ final class PublishDiagnosticsTests: XCTestCase { ) let initialSemanticDiagnosticsReceived = self.expectation(description: "Semantic diagnotistics after open received") - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in // Unresolved identifier is not a syntactic diagnostic. XCTAssertEqual(note.params.diagnostics, []) initialSyntacticDiagnosticsReceived.fulfill() } - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in XCTAssertEqual(note.params.diagnostics.count, 1) XCTAssertEqual( note.params.diagnostics.first?.range, @@ -142,7 +142,7 @@ final class PublishDiagnosticsTests: XCTestCase { ) let editedSemanticDiagnosticsReceived = self.expectation(description: "Semantic diagnotistics after edit received") - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in // We should report the semantic diagnostic reported by the edit range-shifted XCTAssertEqual(note.params.diagnostics.count, 1) XCTAssertEqual( @@ -152,7 +152,7 @@ final class PublishDiagnosticsTests: XCTestCase { editedSyntacticDiagnosticsReceived.fulfill() } - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in XCTAssertEqual(note.params.diagnostics.count, 1) XCTAssertEqual( note.params.diagnostics.first?.range, @@ -178,13 +178,13 @@ final class PublishDiagnosticsTests: XCTestCase { ) let initialSemanticDiagnosticsReceived = self.expectation(description: "Semantic diagnotistics after open received") - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in // Unresolved identifier is not a syntactic diagnostic. XCTAssertEqual(note.params.diagnostics, []) initialSyntacticDiagnosticsReceived.fulfill() } - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in XCTAssertEqual(note.params.diagnostics.count, 1) XCTAssertEqual( note.params.diagnostics.first?.range, @@ -209,7 +209,7 @@ final class PublishDiagnosticsTests: XCTestCase { ) let editedSemanticDiagnosticsReceived = self.expectation(description: "Semantic diagnotistics after edit received") - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in // We should report the semantic diagnostic reported by the edit range-shifted XCTAssertEqual(note.params.diagnostics.count, 1) XCTAssertEqual( @@ -219,7 +219,7 @@ final class PublishDiagnosticsTests: XCTestCase { editedSyntacticDiagnosticsReceived.fulfill() } - sk.appendOneShotNotificationHandler { (note: Notification) in + sk.appendOneShotNoteHandler { (note: Note) in XCTAssertEqual(note.params.diagnostics.count, 1) XCTAssertEqual( note.params.diagnostics.first?.range, diff --git a/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift b/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift index 4d8ba61f7..3f8d5c558 100644 --- a/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift +++ b/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift @@ -109,19 +109,19 @@ final class PullDiagnosticsTests: XCTestCase { XCTAssertEqual(diagnostics.count, 1) let diagnostic = try XCTUnwrap(diagnostics.first) XCTAssertEqual(diagnostic.range, Position(line: 4, utf16index: 7)..) in + ws.sk.handleNextNotification { (notification: Notification) in // Semantic analysis: no errors expected here. - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) startExpectation.fulfill() } - ws.sk.appendOneShotNotificationHandler { (note: Notification) in + ws.sk.appendOneShotNotificationHandler { (notification: Notification) in // Semantic analysis: expect module import error. - XCTAssertEqual(note.params.diagnostics.count, 1) - if let diagnostic = note.params.diagnostics.first { + XCTAssertEqual(notification.params.diagnostics.count, 1) + if let diagnostic = notification.params.diagnostics.first { XCTAssert( diagnostic.message.contains("no such module"), "expected module import error but found \"\(diagnostic.message)\"" @@ -294,14 +294,14 @@ final class SKTests: XCTestCase { let finishExpectation = XCTestExpectation(description: "post-build diagnostics") finishExpectation.expectedFulfillmentCount = 2 - ws.sk.handleNextNotification { (note: Notification) in + ws.sk.handleNextNotification { (notification: Notification) in // Semantic analysis - SourceKit currently caches diagnostics so we still see an error. - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) finishExpectation.fulfill() } - ws.sk.appendOneShotNotificationHandler { (note: Notification) in + ws.sk.appendOneShotNotificationHandler { (notification: Notification) in // Semantic analysis: no more errors expected, import should resolve since we built. - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) finishExpectation.fulfill() } await server.filesDependenciesUpdated([DocumentURI(moduleRef.url)]) @@ -319,10 +319,10 @@ final class SKTests: XCTestCase { let moduleRef = ws.testLoc("libX:call:main") let startExpectation = XCTestExpectation(description: "initial diagnostics") - ws.sk.handleNextNotification { (note: Notification) in + ws.sk.handleNextNotification { (notification: Notification) in // Expect one error: // - Implicit declaration of function invalid - XCTAssertEqual(note.params.diagnostics.count, 1) + XCTAssertEqual(notification.params.diagnostics.count, 1) startExpectation.fulfill() } @@ -341,10 +341,10 @@ final class SKTests: XCTestCase { try ws.buildAndIndex() let finishExpectation = XCTestExpectation(description: "post-build diagnostics") - ws.sk.handleNextNotification { (note: Notification) in + ws.sk.handleNextNotification { (notification: Notification) in // No more errors expected, import should resolve since we the generated header file // now has the proper contents. - XCTAssertEqual(note.params.diagnostics.count, 0) + XCTAssertEqual(notification.params.diagnostics.count, 0) finishExpectation.fulfill() } await server.filesDependenciesUpdated([DocumentURI(moduleRef.url)]) diff --git a/Tests/SourceKitLSPTests/WorkspaceTests.swift b/Tests/SourceKitLSPTests/WorkspaceTests.swift index 619f9e9c2..30979b6c3 100644 --- a/Tests/SourceKitLSPTests/WorkspaceTests.swift +++ b/Tests/SourceKitLSPTests/WorkspaceTests.swift @@ -123,8 +123,8 @@ final class WorkspaceTests: XCTestCase { let expectation = self.expectation(description: "diagnostics") - ws.sk.handleNextNotification { (note: Notification) in - XCTAssertEqual(note.params.diagnostics.count, 0) + ws.sk.handleNextNotification { (notification: Notification) in + XCTAssertEqual(notification.params.diagnostics.count, 0) expectation.fulfill() }