Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 3999139

Browse files
committed
Fix hover on definitions inside a react component module.
This happens when a value is definied multiple times inside an inner module. E.g. @react.component defines `make` twice. Fixes #67
1 parent bb6f155 commit 3999139

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Changes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- Fix issue for uncurried functions where the internal definition of `Js.Fn.arity` is shown on hover. (See https://github.com/rescript-lang/rescript-editor-support/issues/62).
55
- Fix type hint when hovering over labeled arguments of components (See https://github.com/rescript-lang/rescript-editor-support/issues/63).
66
- Fix issue where values declared with type annotation would not show up in autocomplete, and would show no doc comment on hover. (See https://github.com/rescript-lang/rescript-vscode/issues/72).
7-
7+
- Fix hover on definitions inside a react component module, or whenever multiple definitins for the same value exist in the module (See https://github.com/rescript-lang/rescript-editor-support/issues/67).
88

99
## Release 1.0.5 of rescript-vscode
1010
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/6bdd10f6af259edc5f9cbe5b9df06836de3ab865) is vendored in [rescript-vscode 1.0.5](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.5).

examples/example-project/src/ZZ.res

+7
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,10 @@ let valueInner = Inner.vInner;
9898

9999
@ocaml.doc("Doc comment for functionWithTypeAnnotation")
100100
let functionWithTypeAnnotation : unit => int = () => 1
101+
102+
module HoverInsideModuleWithComponent = {
103+
let x = 2 // check that hover on x works
104+
105+
@react.component
106+
let make = () => React.null
107+
}

src/rescript-editor-support/ProcessCmt.re

+6-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,12 @@ and forModule = (env, mod_desc, moduleName) =>
545545
modulePath: ExportedModule(moduleName, env.modulePath),
546546
};
547547
forModuleType(env, moduleType);
548-
| Tmod_constraint(_expr, typ, _constraint, _coercion) =>
548+
| Tmod_constraint(expr, _typ, Tmodtype_implicit, Tcoerce_structure(_)) =>
549+
// implicit contraint synthesized during typechecking
550+
// e.g. when the same id is defined twice (e.g. make with @react.component)
551+
// skip the constraint and use the original module definition
552+
forModule(env, expr.mod_desc, moduleName)
553+
| Tmod_constraint(_expr, typ, constraint_, _coercion) =>
549554
/* TODO do this better I think */
550555
let env = {
551556
...env,

0 commit comments

Comments
 (0)