File tree 5 files changed +34
-7
lines changed
Tests/SwiftSourceKitPluginTests
5 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,7 @@ var targets: [Target] = [
334
334
swiftSettings: globalSwiftSettings + lspLoggingSwiftSettings + [
335
335
// 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
336
336
. define( " NO_CRYPTO_DEPENDENCY " ) ,
337
+ . define( " SKLOGGING_FOR_PLUGIN " ) ,
337
338
. unsafeFlags( [
338
339
" -module-alias " , " SwiftExtensions=SwiftExtensionsForPlugin " ,
339
340
] ) ,
Original file line number Diff line number Diff line change @@ -21,7 +21,11 @@ package final class LoggingScope {
21
21
22
22
/// The name of the current logging subsystem.
23
23
package static var subsystem : String {
24
+ #if SKLOGGING_FOR_PLUGIN
25
+ return _subsystem ?? " org.swift.sourcekit-lsp.plugin "
26
+ #else
24
27
return _subsystem ?? " org.swift.sourcekit-lsp "
28
+ #endif
25
29
}
26
30
27
31
/// The name of the current logging scope.
Original file line number Diff line number Diff line change 11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import Foundation
14
+ import SKLogging
14
15
import SourceKitD
15
16
import SwiftExtensions
16
17
import SwiftSourceKitPluginCommon
@@ -62,14 +63,31 @@ final class RequestHandler: Sendable {
62
63
func produceResult(
63
64
body: @escaping @Sendable ( ) async throws -> SKDResponseDictionaryBuilder
64
65
) -> 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)
70
88
}
89
+ return . requestHandled
71
90
}
72
- return . requestHandled
73
91
}
74
92
75
93
func sourcekitdProducesResult( body: @escaping @Sendable ( ) async -> ( ) ) -> HandleRequestResult {
@@ -139,6 +157,7 @@ final class RequestHandler: Sendable {
139
157
}
140
158
141
159
func cancel( _ handle: RequestHandle ) {
160
+ logger. debug ( " Cancelling request with handle \( handle. numericValue) " )
142
161
self . completionProvider. cancel ( handle: handle)
143
162
}
144
163
}
Original file line number Diff line number Diff line change @@ -31,4 +31,8 @@ struct RequestHandle: Sendable {
31
31
}
32
32
self . handle = handle
33
33
}
34
+
35
+ var numericValue : Int {
36
+ Int ( bitPattern: handle)
37
+ }
34
38
}
Original file line number Diff line number Diff line change @@ -272,7 +272,6 @@ final class SwiftSourceKitPluginTests: XCTestCase {
272
272
}
273
273
274
274
func testCancellation( ) async throws {
275
- try XCTSkipIf ( true , " rdar://145905708 " )
276
275
try await SkipUnless . sourcekitdSupportsPlugin ( )
277
276
let sourcekitd = try await getSourceKitD ( )
278
277
let path = scratchFilePath ( )
You can’t perform that action at this time.
0 commit comments