Skip to content

Commit a54ad31

Browse files
committed
Jump to definition: test jumping directly to the implementation.
When jumping to `Module.x` jump to `Module.res` instead of `Module.resi`. But for `let x = ...` in `Module.res` still jump to `Module.resi`, and for `let x = ...` in `Module.resi` still jump to `Module.res`.
1 parent d2aad5c commit a54ad31

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

analysis/src/References.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,16 @@ let definition ~file ~package stamp tip =
291291
match declaredForTip ~stamps:file.stamps stamp tip with
292292
| None -> None
293293
| Some declared ->
294-
let loc = validateLoc declared.name.loc declared.extentLoc in
295-
let env = QueryEnv.fromFile file in
296-
let uri = ProcessCmt.getSourceUri ~env ~package declared.modulePath in
294+
let fileImpl, declaredImpl =
295+
match alternateDeclared ~package ~file declared tip with
296+
| Some (fileImpl, _extra, declaredImpl) when Uri2.isInterface file.uri
297+
->
298+
(fileImpl, declaredImpl)
299+
| _ -> (file, declared)
300+
in
301+
let loc = validateLoc declaredImpl.name.loc declaredImpl.extentLoc in
302+
let env = QueryEnv.fromFile fileImpl in
303+
let uri = ProcessCmt.getSourceUri ~env ~package declaredImpl.modulePath in
297304
maybeLog ("Inner uri " ^ Uri2.toString uri);
298305
Some (uri, loc))
299306

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ TypeDefinition tests/src/Cross.res 28:5
8585
{"uri": "TypeDefinition.res", "range": {"start": {"line": 2, "character": 0}, "end": {"line": 2, "character": 28}}}
8686

8787
Definition tests/src/Cross.res 31:32
88-
{"uri": "DefinitionWithInterface.resi", "range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}}}
88+
{"uri": "DefinitionWithInterface.res", "range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}}}
8989

0 commit comments

Comments
 (0)