Find references written through another module path
Why
A use in another file is recorded under the path it is written with, such as Use.S.add for a functor application S in Use.res. Find References looked only under the declaration's own path (Fn.MakeSet.add), so it missed uses through the file that applies a functor, through a partial application, and plain values of a namespaced dependency. Rename then left these uses unchanged and the code stopped compiling.
Find References now also takes a recorded path that ends in the declaration's name and resolves it, and keeps it when it resolves to the declaration or its .res/.resi counterpart.
modifiedReferences functor application used from another file
// Fn.resmodule type Ord = { type t}module IntOrd = { type t = int}module MakeSet = (O: Ord) => { let add = (x: O.t) => [x]}module MakeTwo = (A: Ord, B: Ord) => { let pair = 1}module First = MakeTwo(IntOrd) // Use.resmodule S = Fn.MakeSet(Fn.IntOrd)let s = S.add(1)module Make = Fn.MakeSetmodule Aliased = Make(Fn.IntOrd)let a = Aliased.add(1)module Fin = Fn.First(Fn.IntOrd)let p = Fin.pair // Far.reslet f = Use.S.add(2)
text
Before references of add in Fn.res
After references of add in Fn.res
Fn.res 8:7 let addFn.res 8:7 let addUse.res 2:11 S.addUse.res 2:11 S.addUse.res 5:17 Aliased.addUse.res 5:17 Aliased.add Far.res 1:15 Use.S.add
text
Before references of pair in Fn.res
After references of pair in Fn.res
Fn.res 11:7 let pairFn.res 11:7 let pair Use.res 7:13 Fin.pair
text
Before references of Use.S.add in Far.res
After references of Use.S.add in Far.res
Fn.res 8:7 let addFn.res 8:7 let addUse.res 2:11 S.addUse.res 2:11 S.addUse.res 5:17 Aliased.addUse.res 5:17 Aliased.add Far.res 1:15 Use.S.add
modifiedRename functor application used from another file
text
Before rename Use.S.add in Far.res to plus
After rename Use.S.add in Far.res to plus
Fn.res let add ⇝ let plusFn.res let add ⇝ let plusUse.res S.add ⇝ S.plusUse.res S.add ⇝ S.plusUse.res Aliased.add ⇝ Aliased.plusUse.res Aliased.add ⇝ Aliased.plus Far.res Use.S.add ⇝ Use.S.plus
modifiedReferences value of a namespaced dependency
// NsUtils.res in a dependency with namespace NsDepmodule Plain = { let plain = 1} // Main.reslet p = NsDep.NsUtils.Plain.plainmodule P = NsDep.NsUtils.Plainlet q = P.plain
text
Before references of plain in Main.res
After references of plain in Main.res
NsUtils.res 2:7 let plain NsUtils.res 2:7 let plainMain.res 1:29 NsDep.NsUtils.Plain.plainMain.res 3:11 P.plain
Review
- Why not record each use under its declaration's key? Recording happens per file, without access to the other files a path goes through. Resolving at search time needs no change to the recorded data.
- Does this slow down Find References on large projects? Only recorded paths that end in the declaration's name are resolved, each distinct path once. On a 305-file project, references on a value of Big.res take 0.27 s before and after.
- Why keep the exact match on the declaration's own path? It is the common case and needs no resolution, and it keeps every result the old search found.