The sourcekitd/sourcekitd.h header uses __has_feature(blocks) to only define block-based APIs on platforms that support them. For some of these APIs, function pointer equivalents are also defined.
However, much of the internal implementation of SourceKit uses the block-based APIs. Therefore, SourceKit cannot build on any platform that does not have blocks – specifically, it does not build on Linux.
The following block-based APIs need function pointer equivalents, and SourceKit implementation callsites to these functions should use the function pointer APIs instead:
- sourcekitd_set_interrupted_connection_handler needs sourcekitd_set_interrupted_connection_handler_f
- sourcekitd_variant_dictionary_apply needs sourcekitd_variant_dictionary_apply_f
- sourcekitd_variant_array_apply needs sourcekitd_variant_array_apply_f
- sourcekitd_send_request needs sourcekitd_send_request_f
- sourcekitd_set_notification_handler needs sourcekitd_set_notification_handler_f
- sourcekitd_set_uid_handlers needs sourcekitd_set_uid_handlers_f
As far as I know, adding a function pointer API for a block-based API looks something like the following, using sourcekitd_set_notification_handler as an example:
It might be a good idea to create sub-tasks for each of these, although I'd like to confirm that this is a reasonable direction before we do that.