From c18b5a2496cf9d2f510a55ee3a8c5a99086dba11 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Thu, 19 Nov 2026 06:14:17 +0000 Subject: [PATCH] Find references written through another module path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 looks only under the declaration's own path (`Fn.MakeSet.add`), so it misses uses through the file that applies a functor, through a partial application, and uses of a namespaced dependency's values. Rename leaves these uses unchanged, and the code no longer compiles. Find References now also resolves the recorded paths that end in the declaration's name, and keeps those that lead to the declaration or to its .res/.resi counterpart at the same path. References modified (functor application used from another file): Example: // Fn.res module 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.res module S = Fn.MakeSet(Fn.IntOrd) let s = S.add(1) module Make = Fn.MakeSet module Aliased = Make(Fn.IntOrd) let a = Aliased.add(1) module Fin = Fn.First(Fn.IntOrd) let p = Fin.pair // Far.res let f = Use.S.add(2) Before (text): 1-based line:column, references of add in Fn.res Fn.res 8:7 let add Use.res 2:11 S.add Use.res 5:17 Aliased.add After (text): 1-based line:column, references of add in Fn.res Fn.res 8:7 let add Use.res 2:11 S.add Use.res 5:17 Aliased.add Far.res 1:15 Use.S.add Before (text): 1-based line:column, references of pair in Fn.res Fn.res 11:7 let pair After (text): 1-based line:column, references of pair in Fn.res Fn.res 11:7 let pair Use.res 7:13 Fin.pair Before (text): 1-based line:column, references of Use.S.add in Far.res Fn.res 8:7 let add Use.res 2:11 S.add Use.res 5:17 Aliased.add After (text): 1-based line:column, references of Use.S.add in Far.res Fn.res 8:7 let add Use.res 2:11 S.add Use.res 5:17 Aliased.add Far.res 1:15 Use.S.add Rename modified (functor application used from another file): Before (text): rename Use.S.add in Far.res to plus Fn.res let add ⇝ let plus Use.res S.add ⇝ S.plus Use.res Aliased.add ⇝ Aliased.plus After (text): rename Use.S.add in Far.res to plus Fn.res let add ⇝ let plus Use.res S.add ⇝ S.plus Use.res Aliased.add ⇝ Aliased.plus Far.res Use.S.add ⇝ Use.S.plus References modified (value of a namespaced dependency): Example: // NsUtils.res in a dependency with namespace NsDep module Plain = { let plain = 1 } // Main.res let p = NsDep.NsUtils.Plain.plain module P = NsDep.NsUtils.Plain let q = P.plain Before (text): 1-based line:column, references of plain in Main.res NsUtils.res 2:7 let plain After (text): 1-based line:column, references of plain in Main.res NsUtils.res 2:7 let plain Main.res 1:29 NsDep.NsUtils.Plain.plain Main.res 3:11 P.plain References modified (value of a module type, used through a module constrained by it in a .resi): Example: // SignatureItemsIntf.resi module type S = { let s: int } module N: S // SignatureItemsUse.res let s = SignatureItemsIntf.N.s Before (text): 1-based line:column, references of s in SignatureItemsIntf.resi SignatureItemsIntf.res 2:7 let s SignatureItemsIntf.resi 2:7 let s After (text): 1-based line:column, references of s in SignatureItemsIntf.resi SignatureItemsUse.res 4:30 SignatureItemsIntf.N.s SignatureItemsIntf.res 2:7 let s SignatureItemsIntf.resi 2:7 let s 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. Review: Why only a counterpart at the same path? With `module N: S` in the .resi, the counterpart of `N.s` in the .res is `S.s` in the .resi. Other modules share `S.s`: uses of `I.M.s` for `module M: S` resolve to it too. Keeping them would list `I.M.s` as a reference of `N.s`, and Rename would change it. Review: 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 per search. Resolving loads the referenced module through the analysis cache, so the first search in a session pays for loading these modules once. On 400 files that all export `t`, `make` and `map`, three searches take 0.42 s against 0.16 s before. After that, a search costs the same as before, about 15 ms. Review: 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. Fixes: #9321 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kbf3gGUP7SAjW77BvdfhQD Signed-off-by: Christoph Knittel --- analysis/src/references.ml | 89 ++++++++++--- changes/references-other-module-paths.fix.md | 1 + .../namespaced-dependency/package.json | 11 ++ .../namespaced-dependency/rescript.json | 12 ++ .../namespaced-dependency/src/NsUtils.res | 3 + .../tests-sourcedirs-dependency/package.json | 1 + .../tests-sourcedirs-dependency/rescript.json | 5 +- .../src/NamespacedDependency.res | 5 + .../src/expected/NamespacedDependency.res.txt | 25 ++++ tests/analysis_tests/tests/src/PathRefs.res | 28 +++++ .../analysis_tests/tests/src/PathRefsFar.res | 16 +++ .../analysis_tests/tests/src/PathRefsIntf.res | 10 ++ .../tests/src/PathRefsIntf.resi | 5 + .../tests/src/PathRefsIntfUse.res | 2 + .../analysis_tests/tests/src/PathRefsUse.res | 10 ++ .../tests/src/expected/PathRefs.res.txt | 118 ++++++++++++++++++ .../tests/src/expected/PathRefsFar.res.txt | 118 ++++++++++++++++++ .../tests/src/expected/PathRefsIntf.res.txt | 25 ++++ .../tests/src/expected/PathRefsIntf.resi.txt | 0 .../src/expected/PathRefsIntfUse.res.txt | 0 .../tests/src/expected/PathRefsUse.res.txt | 0 .../src/expected/SignatureItemsIntf.resi.txt | 7 ++ yarn.lock | 9 ++ 23 files changed, 480 insertions(+), 20 deletions(-) create mode 100644 changes/references-other-module-paths.fix.md create mode 100644 tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/package.json create mode 100644 tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/rescript.json create mode 100644 tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/src/NsUtils.res create mode 100644 tests/analysis_tests/tests-sourcedirs-dependency/src/NamespacedDependency.res create mode 100644 tests/analysis_tests/tests-sourcedirs-dependency/src/expected/NamespacedDependency.res.txt create mode 100644 tests/analysis_tests/tests/src/PathRefs.res create mode 100644 tests/analysis_tests/tests/src/PathRefsFar.res create mode 100644 tests/analysis_tests/tests/src/PathRefsIntf.res create mode 100644 tests/analysis_tests/tests/src/PathRefsIntf.resi create mode 100644 tests/analysis_tests/tests/src/PathRefsIntfUse.res create mode 100644 tests/analysis_tests/tests/src/PathRefsUse.res create mode 100644 tests/analysis_tests/tests/src/expected/PathRefs.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/PathRefsFar.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/PathRefsIntf.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/PathRefsIntf.resi.txt create mode 100644 tests/analysis_tests/tests/src/expected/PathRefsIntfUse.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/PathRefsUse.res.txt diff --git a/analysis/src/references.ml b/analysis/src/references.ml index 7d238853e3a..a1c9c9f66d3 100644 --- a/analysis/src/references.ml +++ b/analysis/src/references.ml @@ -440,8 +440,11 @@ let for_local_stamp ~state ~full:{file; extra; package} stamp (tip : Tip.t) = | None -> [] | Some declared -> if is_visible declared then ( + let alternate = + alternate_declared ~state ~package ~file declared tip + in let alternative_references = - match alternate_declared ~state ~package ~file declared tip with + match alternate with | None -> [] | Some (file, extra, {stamp}) -> ( match @@ -475,28 +478,76 @@ let for_local_stamp ~state ~full:{file; extra; package} stamp (tip : Tip.t) = normalize_external_reference_key ~namespace:package.namespace ~module_name:this_module_name ~path in + (* A use in another file is recorded under the path it is written + with, e.g. Use.S.add for a functor application S in Use.res, or + Dep.Utils.x for a module of the namespaced dependency Dep. + Such a path names the same declaration when it resolves to the + declaration's stamp, or to the stamp of its .res/.resi + counterpart at the same path. A counterpart at another path, + such as S.s for N.s in `module N: S`, is shared with other + modules, so uses that resolve to it are not uses of this + declaration. Only paths ending in the declaration's name can + resolve to the declaration; their resolutions are cached per + key. *) + let targets = + (Uri.is_interface file.uri, stamp) + :: + (match alternate with + | Some (alternate_file, _extra, alternate_declared) + when Module_path.to_path alternate_declared.module_path + alternate_declared.name.txt + = path -> + [ + (Uri.is_interface alternate_file.uri, alternate_declared.stamp); + ] + | _ -> []) + in + let resolutions = Hashtbl.create 16 in + let resolves_to_declaration module_name path = + match Hashtbl.find_opt resolutions (module_name, path) with + | Some result -> result + | None -> + let result = + match + Process_cmt.file_for_module ~state ~package module_name + with + | None -> false + | Some module_file -> ( + let env = Query_env.from_file module_file in + match exported_for_tip ~state ~env ~path ~package ~tip with + | None -> false + | Some (env, _name, resolved_stamp) -> + env.file.module_name = file.module_name + && List.mem + (Uri.is_interface env.file.uri, resolved_stamp) + targets) + in + Hashtbl.replace resolutions (module_name, path) result; + result + in + let refers_to_declaration module_name path = + (module_name = normalized_module_name && path = normalized_path) + || + match List.rev path with + | name :: _ when name = declared.name.txt -> + resolves_to_declaration module_name path + | _ -> false + in let externals = package.project_files |> File_set.elements |> List.filter (fun name -> name <> file.module_name) - |> List.map (fun module_name -> + |> List.concat_map (fun module_name -> Cmt.fulls_from_module ~package ~module_name - |> List.map (fun {file; extra} -> - match - Hashtbl.find_opt extra.external_references - normalized_module_name - with - | None -> [] - | Some refs -> - let locs = - refs - |> List.filter_map (fun (p, t, locs) -> - if p = normalized_path && t = tip then Some locs - else None) - in - locs - |> List.map (fun loc -> - {uri = file.uri; loc_opt = Some loc}))) - |> List.concat |> List.concat + |> List.concat_map (fun {file; extra} -> + Hashtbl.fold + (fun module_name refs acc -> + (refs + |> List.filter_map (fun (p, t, loc) -> + if t = tip && refers_to_declaration module_name p + then Some {uri = file.uri; loc_opt = Some loc} + else None)) + @ acc) + extra.external_references [])) in alternative_references @ externals) else ( diff --git a/changes/references-other-module-paths.fix.md b/changes/references-other-module-paths.fix.md new file mode 100644 index 00000000000..31bc9d1a7b1 --- /dev/null +++ b/changes/references-other-module-paths.fix.md @@ -0,0 +1 @@ +- Find References and Rename in the editor now also find uses written through another module path, such as a functor application in another file, a local alias of a functor, or a namespaced dependency. diff --git a/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/package.json b/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/package.json new file mode 100644 index 00000000000..2e1997a08a6 --- /dev/null +++ b/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/package.json @@ -0,0 +1,11 @@ +{ + "name": "@tests/sourcedirs-namespaced-dependency-lib", + "private": true, + "scripts": { + "build": "rescript build", + "clean": "rescript clean" + }, + "dependencies": { + "rescript": "workspace:^" + } +} diff --git a/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/rescript.json b/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/rescript.json new file mode 100644 index 00000000000..56e6d940ac1 --- /dev/null +++ b/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/rescript.json @@ -0,0 +1,12 @@ +{ + "name": "@tests/sourcedirs-namespaced-dependency-lib", + "namespace": "NsDep", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": [{ "module": "commonjs", "in-source": false }], + "suffix": ".res.js" +} diff --git a/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/src/NsUtils.res b/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/src/NsUtils.res new file mode 100644 index 00000000000..e642a124556 --- /dev/null +++ b/tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency/src/NsUtils.res @@ -0,0 +1,3 @@ +module Plain = { + let plain = 1 +} diff --git a/tests/analysis_tests/tests-sourcedirs-dependency/package.json b/tests/analysis_tests/tests-sourcedirs-dependency/package.json index c0a27837683..1d3b87857cf 100644 --- a/tests/analysis_tests/tests-sourcedirs-dependency/package.json +++ b/tests/analysis_tests/tests-sourcedirs-dependency/package.json @@ -7,6 +7,7 @@ }, "dependencies": { "@tests/sourcedirs-dependency-lib": "workspace:*", + "@tests/sourcedirs-namespaced-dependency-lib": "workspace:*", "rescript": "workspace:^" } } diff --git a/tests/analysis_tests/tests-sourcedirs-dependency/rescript.json b/tests/analysis_tests/tests-sourcedirs-dependency/rescript.json index 1339c0fc2c2..75c63efe703 100644 --- a/tests/analysis_tests/tests-sourcedirs-dependency/rescript.json +++ b/tests/analysis_tests/tests-sourcedirs-dependency/rescript.json @@ -6,7 +6,10 @@ "subdirs": true } ], - "dependencies": ["@tests/sourcedirs-dependency-lib"], + "dependencies": [ + "@tests/sourcedirs-dependency-lib", + "@tests/sourcedirs-namespaced-dependency-lib" + ], "package-specs": [{ "module": "commonjs", "in-source": false }], "suffix": ".res.js" } diff --git a/tests/analysis_tests/tests-sourcedirs-dependency/src/NamespacedDependency.res b/tests/analysis_tests/tests-sourcedirs-dependency/src/NamespacedDependency.res new file mode 100644 index 00000000000..14c097d286f --- /dev/null +++ b/tests/analysis_tests/tests-sourcedirs-dependency/src/NamespacedDependency.res @@ -0,0 +1,5 @@ +let p = NsDep.NsUtils.Plain.plain +// ^ref + +module P = NsDep.NsUtils.Plain +let q = P.plain diff --git a/tests/analysis_tests/tests-sourcedirs-dependency/src/expected/NamespacedDependency.res.txt b/tests/analysis_tests/tests-sourcedirs-dependency/src/expected/NamespacedDependency.res.txt new file mode 100644 index 00000000000..7f9fd5191ec --- /dev/null +++ b/tests/analysis_tests/tests-sourcedirs-dependency/src/expected/NamespacedDependency.res.txt @@ -0,0 +1,25 @@ +References src/NamespacedDependency.res 0:28 +[ + { + "range": { + "end": { "character": 33, "line": 0 }, + "start": { "character": 28, "line": 0 } + }, + "uri": "file:///NamespacedDependency.res" + }, + { + "range": { + "end": { "character": 15, "line": 4 }, + "start": { "character": 10, "line": 4 } + }, + "uri": "file:///NamespacedDependency.res" + }, + { + "range": { + "end": { "character": 11, "line": 1 }, + "start": { "character": 6, "line": 1 } + }, + "uri": "file:///NsUtils.res" + } +] + diff --git a/tests/analysis_tests/tests/src/PathRefs.res b/tests/analysis_tests/tests/src/PathRefs.res new file mode 100644 index 00000000000..07d5d738c77 --- /dev/null +++ b/tests/analysis_tests/tests/src/PathRefs.res @@ -0,0 +1,28 @@ +module type Ord = { + type t +} +module IntOrd = { + type t = int +} +module MakeSet = (O: Ord) => { + type sh = Dot | Box(O.t) + let add = (x: O.t) => [x] + // ^ref +} +module MakeTwo = (A: Ord, B: Ord) => { + let pair = 1 + // ^ref +} +module First = MakeTwo(IntOrd) +module Other = { + let add = 2 +} +module Plain = { + type r = { + // ^ref + field: int, + //^ref + } + let value = 1 + // ^ref +} diff --git a/tests/analysis_tests/tests/src/PathRefsFar.res b/tests/analysis_tests/tests/src/PathRefsFar.res new file mode 100644 index 00000000000..25b79fa4ec0 --- /dev/null +++ b/tests/analysis_tests/tests/src/PathRefsFar.res @@ -0,0 +1,16 @@ +let f = PathRefsUse.S.add(2) +// ^ref + +let b = PathRefsUse.S.Box(1) +// ^ref + +let c = PathRefsUse.Aliased.Box(2) + +let g = PathRefsUse.S.add(3) +// ^ren plus + +let o = PathRefsUse.O.add + +let v = PathRefsUse.Al.value +let r: PathRefsUse.Al.r = {field: 1} +let rf = r.field diff --git a/tests/analysis_tests/tests/src/PathRefsIntf.res b/tests/analysis_tests/tests/src/PathRefsIntf.res new file mode 100644 index 00000000000..83aa8128811 --- /dev/null +++ b/tests/analysis_tests/tests/src/PathRefsIntf.res @@ -0,0 +1,10 @@ +module type S = { + let s: int +} +module N = { + let s = 1 + // ^ref +} +module M = { + let s = 2 +} diff --git a/tests/analysis_tests/tests/src/PathRefsIntf.resi b/tests/analysis_tests/tests/src/PathRefsIntf.resi new file mode 100644 index 00000000000..f0a283e9c97 --- /dev/null +++ b/tests/analysis_tests/tests/src/PathRefsIntf.resi @@ -0,0 +1,5 @@ +module type S = { + let s: int +} +module N: S +module M: S diff --git a/tests/analysis_tests/tests/src/PathRefsIntfUse.res b/tests/analysis_tests/tests/src/PathRefsIntfUse.res new file mode 100644 index 00000000000..82628aff075 --- /dev/null +++ b/tests/analysis_tests/tests/src/PathRefsIntfUse.res @@ -0,0 +1,2 @@ +let n = PathRefsIntf.N.s +let m = PathRefsIntf.M.s diff --git a/tests/analysis_tests/tests/src/PathRefsUse.res b/tests/analysis_tests/tests/src/PathRefsUse.res new file mode 100644 index 00000000000..6f99b6f23f4 --- /dev/null +++ b/tests/analysis_tests/tests/src/PathRefsUse.res @@ -0,0 +1,10 @@ +module S = PathRefs.MakeSet(PathRefs.IntOrd) +let s = S.add(1) +module Make = PathRefs.MakeSet +module Aliased = Make(PathRefs.IntOrd) +let a = Aliased.add(1) +module Fin = PathRefs.First(PathRefs.IntOrd) +let p = Fin.pair +module O = PathRefs.Other +let o = O.add +module Al = PathRefs.Plain diff --git a/tests/analysis_tests/tests/src/expected/PathRefs.res.txt b/tests/analysis_tests/tests/src/expected/PathRefs.res.txt new file mode 100644 index 00000000000..29064b3ccb6 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/PathRefs.res.txt @@ -0,0 +1,118 @@ +References src/PathRefs.res 8:6 +[ + { + "range": { + "end": { "character": 13, "line": 1 }, + "start": { "character": 10, "line": 1 } + }, + "uri": "file:///PathRefsUse.res" + }, + { + "range": { + "end": { "character": 19, "line": 4 }, + "start": { "character": 16, "line": 4 } + }, + "uri": "file:///PathRefsUse.res" + }, + { + "range": { + "end": { "character": 25, "line": 0 }, + "start": { "character": 22, "line": 0 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 25, "line": 8 }, + "start": { "character": 22, "line": 8 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 9, "line": 8 }, + "start": { "character": 6, "line": 8 } + }, + "uri": "file:///PathRefs.res" + } +] + +References src/PathRefs.res 12:6 +[ + { + "range": { + "end": { "character": 16, "line": 6 }, + "start": { "character": 12, "line": 6 } + }, + "uri": "file:///PathRefsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 12 }, + "start": { "character": 6, "line": 12 } + }, + "uri": "file:///PathRefs.res" + } +] + +References src/PathRefs.res 20:7 +[ + { + "range": { + "end": { "character": 23, "line": 14 }, + "start": { "character": 22, "line": 14 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 8, "line": 20 }, + "start": { "character": 7, "line": 20 } + }, + "uri": "file:///PathRefs.res" + } +] + +References src/PathRefs.res 22:6 +[ + { + "range": { + "end": { "character": 32, "line": 14 }, + "start": { "character": 27, "line": 14 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 16, "line": 15 }, + "start": { "character": 11, "line": 15 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 9, "line": 22 }, + "start": { "character": 4, "line": 22 } + }, + "uri": "file:///PathRefs.res" + } +] + +References src/PathRefs.res 25:6 +[ + { + "range": { + "end": { "character": 28, "line": 13 }, + "start": { "character": 23, "line": 13 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 11, "line": 25 }, + "start": { "character": 6, "line": 25 } + }, + "uri": "file:///PathRefs.res" + } +] + diff --git a/tests/analysis_tests/tests/src/expected/PathRefsFar.res.txt b/tests/analysis_tests/tests/src/expected/PathRefsFar.res.txt new file mode 100644 index 00000000000..87dbfe312ee --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/PathRefsFar.res.txt @@ -0,0 +1,118 @@ +References src/PathRefsFar.res 0:22 +[ + { + "range": { + "end": { "character": 13, "line": 1 }, + "start": { "character": 10, "line": 1 } + }, + "uri": "file:///PathRefsUse.res" + }, + { + "range": { + "end": { "character": 19, "line": 4 }, + "start": { "character": 16, "line": 4 } + }, + "uri": "file:///PathRefsUse.res" + }, + { + "range": { + "end": { "character": 25, "line": 0 }, + "start": { "character": 22, "line": 0 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 25, "line": 8 }, + "start": { "character": 22, "line": 8 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 9, "line": 8 }, + "start": { "character": 6, "line": 8 } + }, + "uri": "file:///PathRefs.res" + } +] + +References src/PathRefsFar.res 3:22 +[ + { + "range": { + "end": { "character": 25, "line": 3 }, + "start": { "character": 22, "line": 3 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 31, "line": 6 }, + "start": { "character": 28, "line": 6 } + }, + "uri": "file:///PathRefsFar.res" + }, + { + "range": { + "end": { "character": 21, "line": 7 }, + "start": { "character": 18, "line": 7 } + }, + "uri": "file:///PathRefs.res" + } +] + +Rename src/PathRefsFar.res 8:22 plus +[ + { + "edits": [ + { + "newText": "plus", + "range": { + "end": { "character": 13, "line": 1 }, + "start": { "character": 10, "line": 1 } + } + }, + { + "newText": "plus", + "range": { + "end": { "character": 19, "line": 4 }, + "start": { "character": 16, "line": 4 } + } + } + ], + "textDocument": { "uri": "file:///PathRefsUse.res", "version": 0 } + }, + { + "edits": [ + { + "newText": "plus", + "range": { + "end": { "character": 25, "line": 0 }, + "start": { "character": 22, "line": 0 } + } + }, + { + "newText": "plus", + "range": { + "end": { "character": 25, "line": 8 }, + "start": { "character": 22, "line": 8 } + } + } + ], + "textDocument": { "uri": "file:///PathRefsFar.res", "version": 0 } + }, + { + "edits": [ + { + "newText": "plus", + "range": { + "end": { "character": 9, "line": 8 }, + "start": { "character": 6, "line": 8 } + } + } + ], + "textDocument": { "uri": "file:///PathRefs.res", "version": 0 } + } +] + diff --git a/tests/analysis_tests/tests/src/expected/PathRefsIntf.res.txt b/tests/analysis_tests/tests/src/expected/PathRefsIntf.res.txt new file mode 100644 index 00000000000..74b92708c64 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/PathRefsIntf.res.txt @@ -0,0 +1,25 @@ +References src/PathRefsIntf.res 4:6 +[ + { + "range": { + "end": { "character": 24, "line": 0 }, + "start": { "character": 23, "line": 0 } + }, + "uri": "file:///PathRefsIntfUse.res" + }, + { + "range": { + "end": { "character": 7, "line": 1 }, + "start": { "character": 6, "line": 1 } + }, + "uri": "file:///PathRefsIntf.resi" + }, + { + "range": { + "end": { "character": 7, "line": 4 }, + "start": { "character": 6, "line": 4 } + }, + "uri": "file:///PathRefsIntf.res" + } +] + diff --git a/tests/analysis_tests/tests/src/expected/PathRefsIntf.resi.txt b/tests/analysis_tests/tests/src/expected/PathRefsIntf.resi.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/PathRefsIntfUse.res.txt b/tests/analysis_tests/tests/src/expected/PathRefsIntfUse.res.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/PathRefsUse.res.txt b/tests/analysis_tests/tests/src/expected/PathRefsUse.res.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/SignatureItemsIntf.resi.txt b/tests/analysis_tests/tests/src/expected/SignatureItemsIntf.resi.txt index 38f778289e4..3690dc7ff80 100644 --- a/tests/analysis_tests/tests/src/expected/SignatureItemsIntf.resi.txt +++ b/tests/analysis_tests/tests/src/expected/SignatureItemsIntf.resi.txt @@ -1,5 +1,12 @@ References src/SignatureItemsIntf.resi 1:6 [ + { + "range": { + "end": { "character": 30, "line": 3 }, + "start": { "character": 29, "line": 3 } + }, + "uri": "file:///SignatureItemsUse.res" + }, { "range": { "end": { "character": 7, "line": 1 }, diff --git a/yarn.lock b/yarn.lock index 8478c97b249..605df379b27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -694,6 +694,15 @@ __metadata: resolution: "@tests/sourcedirs-dependency@workspace:tests/analysis_tests/tests-sourcedirs-dependency" dependencies: "@tests/sourcedirs-dependency-lib": "workspace:*" + "@tests/sourcedirs-namespaced-dependency-lib": "workspace:*" + rescript: "workspace:^" + languageName: unknown + linkType: soft + +"@tests/sourcedirs-namespaced-dependency-lib@workspace:*, @tests/sourcedirs-namespaced-dependency-lib@workspace:tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency": + version: 0.0.0-use.local + resolution: "@tests/sourcedirs-namespaced-dependency-lib@workspace:tests/analysis_tests/tests-sourcedirs-dependency/namespaced-dependency" + dependencies: rescript: "workspace:^" languageName: unknown linkType: soft