Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Use IndexStoreDB for Symbol Resolution #31

Closed
mattt opened this issue Apr 1, 2020 · 3 comments
Closed

Use IndexStoreDB for Symbol Resolution #31

mattt opened this issue Apr 1, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@mattt
Copy link
Contributor

mattt commented Apr 1, 2020

Currently, swift-doc builds a symbol graph syntactically. However, this approach has limitations (#25, #16). We may want to keep the current, syntactic approach around as an option for quick-and-dirty doc generation, but in the long-term, we'll likely want to leverage IndexStoreDB for this.

@mattt
Copy link
Contributor Author

mattt commented Apr 5, 2020

Having dug into this a bit over the past few days, here's what I've learned:

  • As it turns out, our current syntactic approach isn't inherently wrong. It just had a bug in its implementation (Fix SourceFile Visitor #51)
  • IndexStoreDB can help, but it's not a panacea. Having USRs for symbols goes a long way to disambiguating relationships — especially across modules, but it's no substitute for the information we're getting from our syntactic parse.

Going forward, I think the best approach will be to take a progressive approach to doc generation. As a foundation, we start with a syntactic read of Swift code. If available, we then layer on information from IndexStoreDB (we might conditionalize certain features like symbol linking on the availability of this information). Finally, we might then pull in information from imported modules, like official docs for the Swift Standard Library or Foundation.

@mattt mattt self-assigned this Apr 5, 2020
@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Apr 5, 2020

I wonder if more detailed type information would help in any way. Some time ago I've attempted to implement a type inference engine for this type of dev tools (documentation generators, refactoring tools) etc, I wonder if it could be of some use. Especially as symbol resolution in Swift is exacerbated by the presence of overloads, shadowed symbols etc

@mattt
Copy link
Contributor Author

mattt commented Sep 29, 2020

Alternatively, we can load generated symbol graphs (JSON files generated by running swift dump-symbol-graph in Swift 5.3).

@mattt mattt closed this as not planned Won't fix, can't repro, duplicate, stale Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants