Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with not finding type for function arguments #706

Merged
merged 3 commits into from
Jan 21, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- Highlight `catch` like a keyword https://github.com/rescript-lang/rescript-vscode/pull/677
- Make signature help work in calls nested inside of other calls. https://github.com/rescript-lang/rescript-vscode/pull/687
- Fix pipe completion to work on aliased types. https://github.com/rescript-lang/rescript-vscode/pull/700
- Fix issue with not finding type for function arguments. https://github.com/rescript-lang/rescript-vscode/pull/706

## v1.10.0

Expand Down
2 changes: 1 addition & 1 deletion analysis/src/LocalTables.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let populateValues ~env localTables =
env.QueryEnv.file.stamps
|> Stamps.iterValues (fun _ declared ->
Hashtbl.replace localTables.valueTable
(declared.name.txt, declared.extentLoc |> Loc.start)
(declared.name.txt, declared.name.loc |> Loc.start)
declared)

let populateConstructors ~env localTables =
Expand Down
24 changes: 24 additions & 0 deletions analysis/tests/src/CompletionFunctionArguments.res
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,27 @@ let fnTakingRecord = (r: someRecord) => {

// let _ = fnTakingRecord({})
// ^com

module FineModule = {
type t = {
online: bool,
somethingElse: string,
}

let setToFalse = (t: t) => {
...t,
online: false,
}
}

let _ =
<div
onMouseDown={thisGetsBrokenLoc => {
let reassignedWorks = thisGetsBrokenLoc
ignore(reassignedWorks)
// thisGetsBrokenLoc->a
// ^com
// reassignedWorks->a
// ^com
}}
/>
32 changes: 32 additions & 0 deletions analysis/tests/src/expected/CompletionFunctionArguments.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,35 @@ Completable: Cexpression CArgument Value[fnTakingRecord]($0)->recordBody
"documentation": null
}]

Complete src/CompletionFunctionArguments.res 109:29
posCursor:[109:29] posNoWhite:[109:28] Found expr:[105:3->114:4]
JSX <div:[105:3->105:6] onMouseDown[106:4->106:15]=...[106:35->113:5]> _children:114:2
posCursor:[109:29] posNoWhite:[109:28] Found expr:[106:35->113:5]
posCursor:[109:29] posNoWhite:[109:28] Found expr:[107:6->109:29]
posCursor:[109:29] posNoWhite:[109:28] Found expr:[108:6->109:29]
posCursor:[109:29] posNoWhite:[109:28] Found expr:[109:9->109:29]
Completable: Cpath Value[thisGetsBrokenLoc]->a <<jsx>>
[{
"label": "ReactEvent.Mouse.altKey",
"kind": 12,
"tags": [],
"detail": "t => bool",
"documentation": null
}]

Complete src/CompletionFunctionArguments.res 111:27
posCursor:[111:27] posNoWhite:[111:26] Found expr:[105:3->114:4]
JSX <div:[105:3->105:6] onMouseDown[106:4->106:15]=...[106:35->113:5]> _children:114:2
posCursor:[111:27] posNoWhite:[111:26] Found expr:[106:35->113:5]
posCursor:[111:27] posNoWhite:[111:26] Found expr:[107:6->111:27]
posCursor:[111:27] posNoWhite:[111:26] Found expr:[108:6->111:27]
posCursor:[111:27] posNoWhite:[111:26] Found expr:[111:9->111:27]
Completable: Cpath Value[reassignedWorks]->a <<jsx>>
[{
"label": "ReactEvent.Mouse.altKey",
"kind": 12,
"tags": [],
"detail": "t => bool",
"documentation": null
}]