[SR-15852] Add structural type data to symbol graph
Closed this issue · 2 comments
Previous ID | SR-15852 |
Radar | None |
Original Reporter | @WFT |
Type | New Feature |
Additional Detail from JIRA
Votes | 0 |
Component/s | Swift-DocC |
Labels | New Feature |
Assignee | None |
Priority | Medium |
md5: 5e91a1a29db3a0603ba5134fd34897a1
Issue Description:
Filed based on discussion on swift forums. Filed under "Swift-DocC" because there isn't a separate "SymbolKit" component.
Declarations/symbols (properties, methods, subscripts, etc.) should have their type information encoded as structural data. This helps with the goal of visualizing the connections between types and declarations.
An example: for the following declaration of bar(baz: )
, we should be able to pull out both that the parameter baz takes an Optional with the generic Wrapped parameter substituted with String AND that the return type is a tuple with element .0
equal to Int and element .what
equal to Array with the generic Element parameter substituted by UInt. For each type mentioned here I’d like to be able to pull out the USR/“precise identifier” of the type if there is one (i.e. not for the anonymous tuple) along with any generic parameters substituted.
struct Foo {
func bar(baz: String?) -> (Int, what: [UInt]) { (0, what: []) }
}
Ideally I’d be able to draw out from the information above that given the result of calling bar(baz: )
I can get a UInt by accessing the Array subscript of the .what
member. That requires being able to take the generic substitution map from [UInt]
and apply it to a symbol like Array’s subscript. If I could then also connect that to Sequence.Element
(so I can tell that iteration can also extract a UInt), that would be fantastic!
The symbol graph contains type signatures (parameters and return values) for functions/methods, and as of swiftlang/swift#70207 also for subscripts and initializers.
If you want to request more type signature information that's not already in symbol graph files today, please open new issues on the compiler for that source language (for issues on the Swift compiler please prefix the issue with "[SymbolGraphGen]")