Hi I am looking for a way to find all declarations of
structs that implement a specific protocol in a swift module.
I have been searching for existing tooling and found the following tools but none of them seem to be a good fit for what I'm trying to accomplish:
SwiftSyntax: and libSyntax are libraries to parse and manipulate swift source files.
The problem: is that these libraries do no semantic processing and thus it is hard to get type information for example for types that get extended across multiple files using Swift Extensions.
swiftc -dump-ast: parses swift source files, creates an Abstract Syntax Tree from these files, type checks it, annotates it with type information, and dumps the typed AST in human readable format.
The problem: is that this ast-dump format is not suitable for parsing. (See what @jrose and @Vinicius_Vendramini wrote in Improving the AST dump format)
SourceKit: provides "a way to interface with the compiler (via a C API) and primarily do semantic things that editors need, like provide code-completion"
The problem: is that I cannot seem to find how to use it to lookup types that conform to a certain protocol.
Currently there is only syntactic support, there is no way to do semantic queries via using SwiftSyntax.
I can imagine though that a lot of things have changed and evolved since then.
I am looking for something similar to what you see in (docC generated) swift documentation under the title Conforming Types for protocol reference pages.
What would be the best (and/or easiest) way to extract this type information from a swift code base? Are there some SourceKit requests that I can use for this? Or should I use some other tooling?