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

Fix hovering for uncurried types, and type of labels in a component. #64

Merged
merged 2 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## master
- Add support for autocomplete for `foo->`: the type of `foo` is used to determine the module to take completions from.
- Add support for autocomplete for decorators such as `@module` and `@val`.
- 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).
- Fix type hint when hovering over labeled arguments of components (See https://github.com/rescript-lang/rescript-editor-support/issues/63).

## Release 1.0.5 of rescript-vscode
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).
Expand Down
8 changes: 7 additions & 1 deletion src/rescript-editor-support/Hover.re
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
let%opt path = typ |> Shared.digConstructor;
let%opt (_env, {docstring, name: {txt}, item: {decl}}) =
digConstructor(~env, ~getModule, path);
Some((decl |> Shared.declToString(txt), docstring));
let isUncurriedInternal =
Utils.startsWith(Path.name(path), "Js.Fn.arity");
if (isUncurriedInternal) {
None;
} else {
Some((decl |> Shared.declToString(txt), docstring));
};
};
let (typeString, docstring) =
switch (extraTypeInfo) {
Expand Down
13 changes: 13 additions & 0 deletions src/rescript-editor-support/References.re
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ let locsForPos = (~extra, pos) => {

let locForPos = (~extra, pos) => {
switch (locsForPos(~extra, pos)) {
| [
(loc1, Typed(_, LocalReference(_))),
(
loc2,
Typed(_, GlobalReference("Js_OO", Tip("unsafe_downgrade"), _)),
),
(loc3, _) as l3,
]
when loc1 == loc2 && loc2 == loc3 =>
// JSX and compiler combined:
// ~x becomes Js_OO.unsafe_downgrade(Props)#x
// heuristic for: [Props, unsafe_downgrade, x], give loc of `x`
Some(l3)
| [(loc1, _), (loc2, _) as l, (loc3, _)]
when loc1 == loc2 && loc2 == loc3 =>
// JSX with at most one child
Expand Down