-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Refactor main 'handleRequestImpl' function #63090
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
Conversation
@swift-ci Please smoke test |
handleRequestGlobalConfiguration(const RequestDict &Req, | ||
SourceKitCancellationToken CancellationToken, | ||
ResponseReceiver Rec) { | ||
{ |
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.
This block for non-semantic request is for minimizing diff.
Also, I have a plan to wrapping these in a function, just like the handleSemanticRequest
in this PR.
SourceKitCancellationToken CancellationToken, | ||
ResponseReceiver Rec) { | ||
if (checkVFSNotSupported(Req, Rec)) | ||
return; |
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.
Previously, rejecting VFS options is done by "allow" list at the top of handleRequestImpl
and allowed only 4 request kinds, that was often overlooked. Even if the request allowed VFS options, the request failed.
Now it's an opt-out option handled in each request handling function.
Previously, SourceKit requests are handled in a single 'handleRequestImpl'/'handleSemanticRequest' with basically a giant 'if (ReqUID == RequstXXX)' branches. Some request parameters are extracted at the top of the function, but not all request kind used all of them. Factor out each handling logic to its own function, and check/extract request parameters in it. This makes it clear that which request uses what parameters, and how they are handled.
@swift-ci Please smoke test |
8d01639
to
d4a757b
Compare
@swift-ci Please smoke test |
explicit RequestDict(sourcekitd_object_t Dict) : Dict(Dict) { | ||
sourcekitd_request_retain(Dict); | ||
} | ||
RequestDict(const RequestDict &other) : RequestDict(other.Dict) {} | ||
~RequestDict() { | ||
sourcekitd_request_release(Dict); | ||
} |
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.
This may trigger unnecessary retain/release traffic, but this should make the request dictionary handling safer.
@@ -661,7 +740,13 @@ void handleRequestImpl(sourcekitd_object_t ReqObj, | |||
Opts.SyntacticOnly = SyntacticOnly; | |||
return Rec(editorOpen(*Name, InputBuf.get(), Opts, Args, std::move(vfsOptions))); |
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.
Existing request handling functions, like this editorOpen
, will be inlined in this main request handling function in follow-ups.
Previously, SourceKit requests are handled in a single
handleRequestImpl
/handleSemanticRequest
with, basically, a giantif (ReqUID == RequstXXX)
branches. Some request parameters are extracted at the top of the function, but not all request kind used all of them.Factor out each handling logic to its own function, and check/extract request parameters in it. This makes it clear that which request uses what parameters, and how they are handled.
This is mostly a mechanical change, and mostly NFC.