swift-index-store icon indicating copy to clipboard operation
swift-index-store copied to clipboard

Add support for adding missing imports

Open keith opened this issue 2 years ago • 1 comments

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 avatar May 24 '23 00:05 keith

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

  • In this case module c gets an import for module a
// module a
class A {
   let property: String
}

// module b
class B: A {}

// module c
self.b.property
  • typealiases + extensions are a bit weird, this case gets an import to A because the extension is technically on A (AFAIUI):
// 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)

keith avatar May 24 '23 00:05 keith