Skip to content

Commit 98c8801

Browse files
committed
Fix issue with references to elements defined in an interface file
Fixes #645
1 parent 14e8772 commit 98c8801

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
- Fix issue where code analysis would not track types in inner modules across implementations and interfaces https://github.com/rescript-association/reanalyze/issues/186
4141

42+
- Fix issue with references to elements defined in an interface file https://github.com/rescript-lang/rescript-vscode/issues/645
43+
4244
## v1.8.2
4345

4446
#### :rocket: New Feature

analysis/src/Commands.ml

+5-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@ let references ~path ~pos ~debug =
172172
| Some loc -> loc
173173
| None -> Uri.toTopLevelLoc uri2
174174
in
175-
Protocol.stringifyLocation
176-
{uri = Uri.toString uri2; range = Utils.cmtLocToRange loc}
177-
:: acc)
175+
if loc.loc_ghost then acc
176+
else
177+
Protocol.stringifyLocation
178+
{uri = Uri.toString uri2; range = Utils.cmtLocToRange loc}
179+
:: acc)
178180
[])
179181
in
180182
print_endline

analysis/tests/src/References.res

+11
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ let c = x
99

1010
let foo = (~xx) => xx + 1
1111
// ^ref
12+
13+
module M: {
14+
let aa: int
15+
} = {
16+
let aa = 10
17+
}
18+
19+
let bb = M.aa
20+
let cc = bb
21+
let dd = M.aa
22+
// ^ref

analysis/tests/src/expected/References.res.txt

+6
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ References src/References.res 9:19
1414
{"uri": "References.res", "range": {"start": {"line": 9, "character": 19}, "end": {"line": 9, "character": 21}}}
1515
]
1616

17+
References src/References.res 20:12
18+
[
19+
{"uri": "References.res", "range": {"start": {"line": 18, "character": 11}, "end": {"line": 18, "character": 13}}},
20+
{"uri": "References.res", "range": {"start": {"line": 20, "character": 11}, "end": {"line": 20, "character": 13}}}
21+
]
22+

0 commit comments

Comments
 (0)