Skip to content

Commit e0173c8

Browse files
authored
Merge pull request swiftlang#956 from ahoppen/ahoppen/dont-log-error-for-unknown-notifications
Reduce logging level for unknown notifications or requests
2 parents 9a87691 + 35c52c7 commit e0173c8

File tree

4 files changed

+102
-31
lines changed

4 files changed

+102
-31
lines changed

Sources/LanguageServerProtocol/Requests/DocumentLinkRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// The document links request is sent from the client to the server to request the location of links in a document.
14-
public struct DocumentLinkRequest: RequestType {
14+
public struct DocumentLinkRequest: TextDocumentRequest {
1515
public static let method: String = "textDocument/documentLink"
1616
public typealias Response = [DocumentLink]?
1717

Sources/LanguageServerProtocol/Requests/InlineValueRefreshRequest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
struct InlineValueRefreshRequest: RequestType {
14-
static var method: String = "workspace/inlineValue/refresh"
15-
typealias Response = VoidResponse
13+
public struct InlineValueRefreshRequest: RequestType {
14+
public static var method: String = "workspace/inlineValue/refresh"
15+
public typealias Response = VoidResponse
1616

1717
public init() {}
1818
}

Sources/LanguageServerProtocol/Requests/WillSaveWaitUntilTextDocumentRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// The document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. If a server has registered for open / close events clients should ensure that the document is open before a willSaveWaitUntil notification is sent since clients can’t change the content of a file without ownership transferal.
14-
public struct WillSaveWaitUntilTextDocumentRequest: RequestType {
14+
public struct WillSaveWaitUntilTextDocumentRequest: TextDocumentRequest {
1515
public static let method: String = "textDocument/willSaveWaitUntil"
1616
public typealias Response = [TextEdit]?
1717

Sources/SourceKitLSP/SourceKitServer.swift

Lines changed: 97 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -205,26 +205,56 @@ fileprivate enum TaskMetadata: DependencyTracker {
205205

206206
init(_ notification: any NotificationType) {
207207
switch notification {
208-
case is InitializedNotification:
208+
case is CancelRequestNotification:
209+
self = .freestanding
210+
case is CancelWorkDoneProgressNotification:
211+
self = .freestanding
212+
case is DidChangeConfigurationNotification:
209213
self = .globalConfigurationChange
210-
case is CancelRequestNotification:
214+
case let notification as DidChangeNotebookDocumentNotification:
215+
self = .documentUpdate(notification.notebookDocument.uri)
216+
case let notification as DidChangeTextDocumentNotification:
217+
self = .documentUpdate(notification.textDocument.uri)
218+
case is DidChangeWatchedFilesNotification:
211219
self = .freestanding
212-
case is ExitNotification:
220+
case is DidChangeWorkspaceFoldersNotification:
213221
self = .globalConfigurationChange
214-
case let notification as DidOpenTextDocumentNotification:
222+
case let notification as DidCloseNotebookDocumentNotification:
223+
self = .documentUpdate(notification.notebookDocument.uri)
224+
case let notification as DidCloseTextDocumentNotification:
215225
self = .documentUpdate(notification.textDocument.uri)
216-
case let notification as DidCloseTextDocumentNotification:
226+
case is DidCreateFilesNotification:
227+
self = .freestanding
228+
case is DidDeleteFilesNotification:
229+
self = .freestanding
230+
case let notification as DidOpenNotebookDocumentNotification:
231+
self = .documentUpdate(notification.notebookDocument.uri)
232+
case let notification as DidOpenTextDocumentNotification:
217233
self = .documentUpdate(notification.textDocument.uri)
218-
case let notification as DidChangeTextDocumentNotification:
234+
case is DidRenameFilesNotification:
235+
self = .freestanding
236+
case let notification as DidSaveNotebookDocumentNotification:
237+
self = .documentUpdate(notification.notebookDocument.uri)
238+
case let notification as DidSaveTextDocumentNotification:
219239
self = .documentUpdate(notification.textDocument.uri)
220-
case is DidChangeWorkspaceFoldersNotification:
240+
case is ExitNotification:
221241
self = .globalConfigurationChange
222-
case is DidChangeWatchedFilesNotification:
242+
case is InitializedNotification:
243+
self = .globalConfigurationChange
244+
case is LogMessageNotification:
223245
self = .freestanding
224-
case let notification as WillSaveTextDocumentNotification:
225-
self = .documentUpdate(notification.textDocument.uri)
226-
case let notification as DidSaveTextDocumentNotification:
246+
case is LogTraceNotification:
247+
self = .freestanding
248+
case is PublishDiagnosticsNotification:
249+
self = .freestanding
250+
case is SetTraceNotification:
251+
self = .globalConfigurationChange
252+
case is ShowMessageNotification:
253+
self = .freestanding
254+
case let notification as WillSaveTextDocumentNotification:
227255
self = .documentUpdate(notification.textDocument.uri)
256+
case is WorkDoneProgress:
257+
self = .freestanding
228258
default:
229259
logger.error(
230260
"""
@@ -238,32 +268,73 @@ fileprivate enum TaskMetadata: DependencyTracker {
238268

239269
init(_ request: any RequestType) {
240270
switch request {
241-
case is InitializeRequest:
242-
self = .globalConfigurationChange
243-
case is ShutdownRequest:
244-
self = .globalConfigurationChange
245-
case is WorkspaceSymbolsRequest:
271+
case let request as any TextDocumentRequest: self = .documentRequest(request.textDocument.uri)
272+
case is ApplyEditRequest:
246273
self = .freestanding
247-
case is BarrierRequest:
248-
self = .globalConfigurationChange
249-
case is PollIndexRequest:
274+
case is BarrierRequest:
250275
self = .globalConfigurationChange
251-
case let request as ExecuteCommandRequest:
276+
case is CallHierarchyIncomingCallsRequest:
277+
self = .freestanding
278+
case is CallHierarchyOutgoingCallsRequest:
279+
self = .freestanding
280+
case is CodeActionResolveRequest:
281+
self = .freestanding
282+
case is CodeLensRefreshRequest:
283+
self = .freestanding
284+
case is CodeLensResolveRequest:
285+
self = .freestanding
286+
case is CompletionItemResolveRequest:
287+
self = .freestanding
288+
case is CreateWorkDoneProgressRequest:
289+
self = .freestanding
290+
case is DiagnosticsRefreshRequest:
291+
self = .freestanding
292+
case is DocumentLinkResolveRequest:
293+
self = .freestanding
294+
case let request as ExecuteCommandRequest:
252295
if let uri = request.textDocument?.uri {
253296
self = .documentRequest(uri)
254297
} else {
255298
self = .freestanding
256299
}
257-
case is CallHierarchyIncomingCallsRequest:
300+
case is InitializeRequest:
301+
self = .globalConfigurationChange
302+
case is InlayHintRefreshRequest:
303+
self = .freestanding
304+
case is InlayHintResolveRequest:
305+
self = .freestanding
306+
case is InlineValueRefreshRequest:
307+
self = .freestanding
308+
case is PollIndexRequest:
309+
self = .globalConfigurationChange
310+
case is RegisterCapabilityRequest:
311+
self = .globalConfigurationChange
312+
case is ShowMessageRequest:
313+
self = .freestanding
314+
case is ShutdownRequest:
315+
self = .globalConfigurationChange
316+
case is TypeHierarchySubtypesRequest:
317+
self = .freestanding
318+
case is TypeHierarchySupertypesRequest:
319+
self = .freestanding
320+
case is UnregisterCapabilityRequest:
321+
self = .globalConfigurationChange
322+
case is WillCreateFilesRequest:
323+
self = .freestanding
324+
case is WillDeleteFilesRequest:
325+
self = .freestanding
326+
case is WillRenameFilesRequest:
327+
self = .freestanding
328+
case is WorkspaceDiagnosticsRequest:
329+
self = .freestanding
330+
case is WorkspaceFoldersRequest:
258331
self = .freestanding
259-
case is CallHierarchyOutgoingCallsRequest:
332+
case is WorkspaceSemanticTokensRefreshRequest:
260333
self = .freestanding
261-
case is TypeHierarchySupertypesRequest:
334+
case is WorkspaceSymbolResolveRequest:
262335
self = .freestanding
263-
case is TypeHierarchySubtypesRequest:
336+
case is WorkspaceSymbolsRequest:
264337
self = .freestanding
265-
case let request as any TextDocumentRequest:
266-
self = .documentRequest(request.textDocument.uri)
267338
default:
268339
logger.error(
269340
"""

0 commit comments

Comments
 (0)