New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle sourcekitd error #169
Conversation
@@ -91,6 +91,10 @@ private func fromSourceKit(sourcekitObject: sourcekitd_variant_t) -> SourceKitRe | |||
/// dispatch_once_t token used to only initialize SourceKit once per session. | |||
private var sourceKitInitializationToken: dispatch_once_t = 0 | |||
|
|||
/// dispatch_semaphore_t used to waiting sourcekitd restored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dispatch_semaphore_t used when waiting for sourcekitd to be restored.
This is probably necessary, although error handling inevitably muddies up the code 😢 |
This is great work @norio-nomura! I wasn't able to figure this out the last few times I tried, so kudos! 👏 |
`sourcekitd_set_notification_handler()` set the handler to be executed on main thread queue. So, we vacate main thread to `dispatch_main()`.
Change `SwiftDocs.init(file:arguments:)` to failable.
Apply reviews.
f04ef01
to
846d91a
Compare
Updated. sourceKitten doc
Running xcodebuild
Parsing 142-success2.swift (1/5)
sourcekit: [1:connection-event-handler:9475: 0.0000] Connection interrupt
sourcekit: [1:pingService:9475: 0.0010] pinging service
sourcekit: [1:ping-event-handler:6659: 0.0111] service restored
sourcekitten: connection to SourceKitService restored!
sourcekit: [1:connection-event-handler:9475: 0.0852] Connection interrupt
sourcekit: [1:updateSemanticEditorDelay:9475: 0.0853] disabling semantic editor for 1 seconds
sourcekit: [1:pingService:9475: 0.0854] pinging service
sourcekitten: connection to SourceKitService restored!
Parsing 27947-swift-parser-parsebraceitems.swift (2/5)
sourcekit: [1:sourcekitd_send_request_sync:3331: 0.0859] request dropped while restoring service
sourcekit: [1:ping-event-handler:10095: 0.0968] service restored
sourcekitten: connection to SourceKitService restored!
restoring serviceParsing 142-nodoc.swift (3/5)
Parsing 142-fail.swift (4/5)
Parsing 142-success1.swift (5/5)
[{
"\/Users\/norio\/Documents\/workspace\/github\/SwiftLint\/Carthage\/Checkouts\/SourceKitten\/SourceKitten142\/SourceKitten142\/142-success2.swift" : {
"key.substructure" : [
{ |
@@ -6,7 +6,9 @@ | |||
|
|||
##### Enhancements | |||
|
|||
* None. | |||
* Add `Request.failableSend()` that can handle SourceKitService crashes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a breaking change in this PR: SwiftDocs(file:arguments:)
now throws.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes.
I changed it to failable SwiftDocs.init?(file:arguments:)
.
Change `SwiftDocs.init(file:arguments:)` to `SwiftDocs.init?(file:arguments:)`
Great, thanks again for this @norio-nomura! |
Thanks for reviews! 🙏 😄 |
#166
Notes:
sourcekitd_set_notification_handler()
.sourcekitd_set_notification_handler()
set the handler to be executed on main thread queue.So, we vacate main thread to
dispatch_main()
. Without that, SourceKittenFramework waits 10 seconds for SourceKitService restored.Request.sendMayThrow()
that may throwsRequest.Error
.good naming? or change
send()
to throwing error?Those files can crash sourcekitd in Xcode 7.2.1, but not newer version of sourcekitd.