MobileNativeFoundation / swift-index-store

Library to read from Swift / clang source code indexes
Apache License 2.0
139 stars 12 forks source link

Add support for adding missing imports #29

Open keith opened 1 year ago

keith commented 1 year ago

This works by collecting all definition USRs from all units, and cross referencing all reference USRs from each file, until there are no unhandled USRs remaining.

keith commented 1 year ago

there are a few cases this adds imports for that might be surprising:

// module a
class A {
   let property: String
}

// module b
class B: A {}

// module c
self.b.property
// module a
struct A {}

// module b
typealias B = A

extension B {
  func foo() {}
}

// module c
B().foo()

maybe some more, but most were pretty understandable and more surprising that they could be missing (mostly the usual suspects like extensions on system types, operators, uses of callAsFunction etc)