File tree Expand file tree Collapse file tree 5 files changed +34
-7
lines changed
Tests/SwiftSourceKitPluginTests Expand file tree Collapse file tree 5 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,7 @@ var targets: [Target] = [
334334 swiftSettings: globalSwiftSettings + lspLoggingSwiftSettings + [
335335 // We can't depend on swift-crypto in the plugin because we can't module-alias it due to https://github.com/swiftlang/swift-package-manager/issues/8119
336336 . define( " NO_CRYPTO_DEPENDENCY " ) ,
337+ . define( " SKLOGGING_FOR_PLUGIN " ) ,
337338 . unsafeFlags( [
338339 " -module-alias " , " SwiftExtensions=SwiftExtensionsForPlugin " ,
339340 ] ) ,
Original file line number Diff line number Diff line change @@ -21,7 +21,11 @@ package final class LoggingScope {
2121
2222 /// The name of the current logging subsystem.
2323 package static var subsystem : String {
24+ #if SKLOGGING_FOR_PLUGIN
25+ return _subsystem ?? " org.swift.sourcekit-lsp.plugin "
26+ #else
2427 return _subsystem ?? " org.swift.sourcekit-lsp "
28+ #endif
2529 }
2630
2731 /// The name of the current logging scope.
Original file line number Diff line number Diff line change 1111//===----------------------------------------------------------------------===//
1212
1313import Foundation
14+ import SKLogging
1415import SourceKitD
1516import SwiftExtensions
1617import SwiftSourceKitPluginCommon
@@ -62,14 +63,31 @@ final class RequestHandler: Sendable {
6263 func produceResult(
6364 body: @escaping @Sendable ( ) async throws -> SKDResponseDictionaryBuilder
6465 ) -> HandleRequestResult {
65- requestHandlingQueue. async {
66- do {
67- receiver ( try await body ( ) . response)
68- } catch {
69- receiver ( SKDResponse . from ( error: error, sourcekitd: self . sourcekitd) )
66+ withLoggingScope ( " request- \( handle? . numericValue ?? 0 % 100 ) " ) {
67+ let start = Date ( )
68+ logger. debug (
69+ """
70+ Plugin received sourcekitd request (handle: \( handle? . numericValue ?? - 1 ) )
71+ \( dict. description)
72+ """
73+ )
74+ requestHandlingQueue. async {
75+ let response : SKDResponse
76+ do {
77+ response = try await body ( ) . response
78+ } catch {
79+ response = SKDResponse . from ( error: error, sourcekitd: self . sourcekitd)
80+ }
81+ logger. debug (
82+ """
83+ Finished (took \( Date ( ) . timeIntervalSince ( start) ) s)
84+ \( response. description)
85+ """
86+ )
87+ receiver ( response)
7088 }
89+ return . requestHandled
7190 }
72- return . requestHandled
7391 }
7492
7593 func sourcekitdProducesResult( body: @escaping @Sendable ( ) async -> ( ) ) -> HandleRequestResult {
@@ -139,6 +157,7 @@ final class RequestHandler: Sendable {
139157 }
140158
141159 func cancel( _ handle: RequestHandle ) {
160+ logger. debug ( " Cancelling request with handle \( handle. numericValue) " )
142161 self . completionProvider. cancel ( handle: handle)
143162 }
144163}
Original file line number Diff line number Diff line change @@ -31,4 +31,8 @@ struct RequestHandle: Sendable {
3131 }
3232 self . handle = handle
3333 }
34+
35+ var numericValue : Int {
36+ Int ( bitPattern: handle)
37+ }
3438}
Original file line number Diff line number Diff line change @@ -272,7 +272,6 @@ final class SwiftSourceKitPluginTests: XCTestCase {
272272 }
273273
274274 func testCancellation( ) async throws {
275- try XCTSkipIf ( true , " rdar://145905708 " )
276275 try await SkipUnless . sourcekitdSupportsPlugin ( )
277276 let sourcekitd = try await getSourceKitD ( )
278277 let path = scratchFilePath ( )
You can’t perform that action at this time.
0 commit comments