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

Add example tool for "dependency tightness"

Open keith opened this issue 2 years ago • 6 comments

This tool uses to index to determine how many reference a module has on its dependencies. It outputs json formatted as:

{
  "A": {
    "B": 5,
    "C": 1
  }
}

Which indicates the module named A has 1 reference to something defined in C and 5 references to things defined in B.

keith avatar May 30 '23 20:05 keith

Could this be used to find the inverse? In a target can we determine which definitions are the easiest to extract?

maxwellE avatar May 30 '23 20:05 maxwellE

hrm probably. can you provide an example?

I think with a similar tool you could definitely find cases where a definition in 1 module is only used in another module so it should likely be moved there

keith avatar May 30 '23 20:05 keith

Its tricky because what I have working locally has to parse raw USRs to determine what a symbol belongs to (unless I am holding it wrong)

maxwellE avatar May 30 '23 20:05 maxwellE

hrm probably. can you provide an example?

I think with a similar tool you could definitely find cases where a definition in 1 module is only used in another module so it should likely be moved there

Basically I want a linear path of files that can be moved from one target it its next most adjacent target based on the number of inner references of a file to the rest of its target

maxwellE avatar May 30 '23 20:05 maxwellE

Its tricky because what I have working locally has to parse raw USRs to determine what a symbol belongs to (unless I am holding it wrong)

In this case you don't need to parse the USR because you can just collect all definitions and at that point you know what module they're defined in from the index unit.

Basically I want a linear path of files that can be moved from one target it its next most adjacent target based on the number of inner references of a file to the rest of its target

yea i think that's definitely possible with something like this. I think it would be a matter of tracking what modules reference what USRs and if there is only 1 that isn't where the definition is, it can be moved.

keith avatar May 30 '23 21:05 keith

here's an example https://github.com/lyft/swift-index-store/pull/44

keith avatar May 30 '23 22:05 keith