Skip to content

Commit 3949496

Browse files
committed
Proper fix that avoids introducing references to ghost locations.
This also finds as reference the value defined in the interface.
1 parent 98c8801 commit 3949496

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
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
42+
- Fix issue with references to elements defined in an interface file https://github.com/rescript-lang/rescript-vscode/pull/646
4343

4444
## v1.8.2
4545

analysis/src/Commands.ml

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

analysis/src/ProcessCmt.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let rec forTypeSignatureItem ~(env : SharedTypes.Env.t) ~(exported : Exported.t)
1919
let oldDeclared = Stamps.findValue env.stamps stamp in
2020
let declared =
2121
addDeclared
22-
~name:(Location.mknoloc (Ident.name ident))
22+
~name:(Location.mkloc (Ident.name ident) loc)
2323
~extent:loc ~stamp ~env ~item val_attributes
2424
(Exported.add exported Exported.Value)
2525
Stamps.addValue
@@ -107,7 +107,7 @@ let rec forTypeSignatureItem ~(env : SharedTypes.Env.t) ~(exported : Exported.t)
107107
let declared =
108108
addDeclared ~extent:md_loc
109109
~item:(forTypeModule env md_type)
110-
~name:(Location.mknoloc (Ident.name ident))
110+
~name:(Location.mkloc (Ident.name ident) md_loc)
111111
~stamp:(Ident.binding_time ident) ~env md_attributes
112112
(Exported.add exported Exported.Module)
113113
Stamps.addModule

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

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Hover src/Hover.res 22:11
1414
{"contents": {"kind": "markdown", "value": "```rescript\nint => int\n```\n\nSome doc comment"}}
1515

1616
Hover src/Hover.res 26:6
17+
getLocItem #8: heuristic for JSX with at most one child
18+
heuristic for: [makeProps, make, createElement], give the loc of `make`
1719
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}
1820

1921
Hover src/Hover.res 33:4

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

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ References src/References.res 9:19
1616

1717
References src/References.res 20:12
1818
[
19+
{"uri": "References.res", "range": {"start": {"line": 13, "character": 2}, "end": {"line": 13, "character": 13}}},
1920
{"uri": "References.res", "range": {"start": {"line": 18, "character": 11}, "end": {"line": 18, "character": 13}}},
2021
{"uri": "References.res", "range": {"start": {"line": 20, "character": 11}, "end": {"line": 20, "character": 13}}}
2122
]

0 commit comments

Comments
 (0)