Skip to content

Commit 13f1878

Browse files
committed
fix issue with function arg missing type information by using the loc from the name instead of the declared when adding values to local tables
1 parent 59d5258 commit 13f1878

File tree

5 files changed

+24
-61
lines changed

5 files changed

+24
-61
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,7 @@ let findAllCompletions ~(env : QueryEnv.t) ~prefix ~exact ~namesUsed
252252

253253
let processLocalValue name loc ~prefix ~exact ~env
254254
~(localTables : LocalTables.t) =
255-
if Utils.checkName name ~prefix ~exact then (
256-
if name = "thisGetsBrokenLoc" then
257-
Printf.printf "looking for %s startPos %s\n" name
258-
(loc |> Loc.start |> Pos.toString);
255+
if Utils.checkName name ~prefix ~exact then
259256
match Hashtbl.find_opt localTables.valueTable (name, Loc.start loc) with
260257
| Some declared ->
261258
if not (Hashtbl.mem localTables.namesUsed name) then (
@@ -279,7 +276,7 @@ let processLocalValue name loc ~prefix ~exact ~env
279276
(Ctype.newconstr
280277
(Path.Pident (Ident.create "Type Not Known"))
281278
[]))
282-
:: localTables.resultRev)
279+
:: localTables.resultRev
283280

284281
let processLocalConstructor name loc ~prefix ~exact ~env
285282
~(localTables : LocalTables.t) =

analysis/src/LocalTables.ml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ let create () =
2525
let populateValues ~env localTables =
2626
env.QueryEnv.file.stamps
2727
|> Stamps.iterValues (fun _ declared ->
28-
if declared.name.txt = "thisGetsBrokenLoc" then
29-
Printf.printf "populaing %s %s startPos %s full pos %s\n"
30-
declared.name.txt
31-
(Shared.typeToString declared.item)
32-
(declared.extentLoc |> Loc.start |> Pos.toString)
33-
(declared.extentLoc |> Loc.toString);
3428
Hashtbl.replace localTables.valueTable
35-
(declared.name.txt, declared.extentLoc |> Loc.start)
29+
(declared.name.txt, declared.name.loc |> Loc.start)
3630
declared)
3731

3832
let populateConstructors ~env localTables =

analysis/src/ProcessExtra.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,6 @@ let pat ~(file : File.t) ~env ~extra (iter : Tast_iterator.iterator)
360360
(pattern : Typedtree.pattern) =
361361
let addForPattern stamp name =
362362
if Stamps.findValue file.stamps stamp = None then (
363-
(* This is where the broken loc is found/added *)
364-
if false && name.Location.txt = "thisGetsBrokenLoc" then
365-
Printf.printf "this loc is broken and would need to work %s %s\n"
366-
name.Location.txt
367-
(pattern.pat_loc |> Loc.toString);
368363
let declared =
369364
ProcessAttributes.newDeclared ~name ~stamp ~modulePath:NotVisible
370365
~extent:pattern.pat_loc ~item:pattern.pat_type false

analysis/tests/src/CompletionFunctionArguments.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ module FineModule = {
105105
let _ =
106106
<div
107107
onMouseDown={thisGetsBrokenLoc => {
108-
// ^com
109108
let reassignedWorks = thisGetsBrokenLoc
110109
ignore(reassignedWorks)
111110
// thisGetsBrokenLoc->a

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

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Complete src/CompletionFunctionArguments.res 10:24
22
posCursor:[10:24] posNoWhite:[10:23] Found expr:[10:11->10:25]
33
Pexp_apply ...[10:11->10:17] (~isOn10:19->10:23=...__ghost__[0:-1->0:-1])
44
Completable: Cexpression CArgument Value[someFn](~isOn)
5-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
65
[{
76
"label": "true",
87
"kind": 4,
@@ -21,8 +20,6 @@ Complete src/CompletionFunctionArguments.res 13:25
2120
posCursor:[13:25] posNoWhite:[13:24] Found expr:[13:11->13:26]
2221
Pexp_apply ...[13:11->13:17] (~isOn13:19->13:23=...[13:24->13:25])
2322
Completable: Cexpression CArgument Value[someFn](~isOn)=t
24-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
25-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
2623
[{
2724
"label": "true",
2825
"kind": 4,
@@ -42,7 +39,6 @@ Complete src/CompletionFunctionArguments.res 16:25
4239
posCursor:[16:25] posNoWhite:[16:24] Found expr:[16:11->16:26]
4340
Pexp_apply ...[16:11->16:17] (~isOff16:19->16:24=...__ghost__[0:-1->0:-1])
4441
Completable: Cexpression CArgument Value[someFn](~isOff)
45-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
4642
[{
4743
"label": "true",
4844
"kind": 4,
@@ -65,7 +61,6 @@ posCursor:[21:27] posNoWhite:[21:26] Found expr:[21:7->21:28]
6561
posCursor:[21:27] posNoWhite:[21:26] Found expr:[21:14->21:28]
6662
Pexp_apply ...[21:14->21:20] (~isOn21:22->21:26=...__ghost__[0:-1->0:-1])
6763
Completable: Cexpression CArgument Value[someFn](~isOn)
68-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
6964
[{
7065
"label": "true",
7166
"kind": 4,
@@ -84,8 +79,6 @@ Complete src/CompletionFunctionArguments.res 34:24
8479
posCursor:[34:24] posNoWhite:[34:23] Found expr:[34:11->34:25]
8580
Pexp_apply ...[34:11->34:22] (...[34:23->34:24])
8681
Completable: Cexpression CArgument Value[someOtherFn]($0)=f
87-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
88-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
8982
[{
9083
"label": "false",
9184
"kind": 4,
@@ -98,7 +91,6 @@ Complete src/CompletionFunctionArguments.res 51:39
9891
posCursor:[51:39] posNoWhite:[51:38] Found expr:[51:11->51:40]
9992
Pexp_apply ...[51:11->51:30] (~config51:32->51:38=...__ghost__[0:-1->0:-1])
10093
Completable: Cexpression CArgument Value[someFnTakingVariant](~config)
101-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
10294
[{
10395
"label": "One",
10496
"kind": 4,
@@ -129,8 +121,6 @@ Complete src/CompletionFunctionArguments.res 54:40
129121
posCursor:[54:40] posNoWhite:[54:39] Found expr:[54:11->54:41]
130122
Pexp_apply ...[54:11->54:30] (~config54:32->54:38=...[54:39->54:40])
131123
Completable: Cexpression CArgument Value[someFnTakingVariant](~config)=O
132-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
133-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
134124
[{
135125
"label": "One",
136126
"kind": 4,
@@ -164,8 +154,6 @@ Complete src/CompletionFunctionArguments.res 57:33
164154
posCursor:[57:33] posNoWhite:[57:32] Found expr:[57:11->57:34]
165155
Pexp_apply ...[57:11->57:30] (...[57:31->57:33])
166156
Completable: Cexpression CArgument Value[someFnTakingVariant]($0)=So
167-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
168-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
169157
[{
170158
"label": "Some(_)",
171159
"kind": 4,
@@ -187,8 +175,6 @@ Complete src/CompletionFunctionArguments.res 60:44
187175
posCursor:[60:44] posNoWhite:[60:43] Found expr:[60:11->60:45]
188176
Pexp_apply ...[60:11->60:30] (~configOpt260:32->60:42=...[60:43->60:44])
189177
Completable: Cexpression CArgument Value[someFnTakingVariant](~configOpt2)=O
190-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
191-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
192178
[{
193179
"label": "One",
194180
"kind": 4,
@@ -222,7 +208,6 @@ Complete src/CompletionFunctionArguments.res 63:23
222208
posCursor:[63:23] posNoWhite:[63:22] Found expr:[63:11->63:24]
223209
Pexp_apply ...[63:11->63:22] (...[63:23->63:24])
224210
Completable: Cexpression CArgument Value[someOtherFn]($0)
225-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
226211
[{
227212
"label": "true",
228213
"kind": 4,
@@ -241,7 +226,6 @@ Complete src/CompletionFunctionArguments.res 66:28
241226
posCursor:[66:28] posNoWhite:[66:27] Found expr:[66:11->66:30]
242227
Pexp_apply ...[66:11->66:22] (...[66:23->66:24], ...[66:26->66:27])
243228
Completable: Cexpression CArgument Value[someOtherFn]($2)
244-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
245229
[{
246230
"label": "true",
247231
"kind": 4,
@@ -259,8 +243,6 @@ populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[
259243
Complete src/CompletionFunctionArguments.res 69:30
260244
posCursor:[69:30] posNoWhite:[69:29] Found expr:[69:11->69:31]
261245
Completable: Cexpression CArgument Value[someOtherFn]($2)=t
262-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
263-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
264246
[{
265247
"label": "true",
266248
"kind": 4,
@@ -280,7 +262,6 @@ Complete src/CompletionFunctionArguments.res 76:25
280262
posCursor:[76:25] posNoWhite:[76:24] Found expr:[76:11->76:26]
281263
Pexp_apply ...[76:11->76:24] (...[76:25->76:26])
282264
Completable: Cexpression CArgument Value[fnTakingTuple]($0)
283-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
284265
[{
285266
"label": "(_, _, _)",
286267
"kind": 12,
@@ -295,7 +276,6 @@ Complete src/CompletionFunctionArguments.res 89:27
295276
posCursor:[89:27] posNoWhite:[89:26] Found expr:[89:11->89:29]
296277
Pexp_apply ...[89:11->89:25] (...[89:26->89:28])
297278
Completable: Cexpression CArgument Value[fnTakingRecord]($0)->recordBody
298-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
299279
[{
300280
"label": "age",
301281
"kind": 5,
@@ -316,32 +296,30 @@ populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[
316296
"documentation": null
317297
}]
318298

319-
Complete src/CompletionFunctionArguments.res 106:33
320-
posCursor:[106:33] posNoWhite:[106:32] Found expr:[105:3->115:4]
321-
JSX <div:[105:3->105:6] onMouseDown[106:4->106:15]=...[106:35->114:5]> _children:115:2
322-
[]
323-
324-
Complete src/CompletionFunctionArguments.res 110:29
325-
posCursor:[110:29] posNoWhite:[110:28] Found expr:[105:3->115:4]
326-
JSX <div:[105:3->105:6] onMouseDown[106:4->106:15]=...[106:35->114:5]> _children:115:2
327-
posCursor:[110:29] posNoWhite:[110:28] Found expr:[106:35->114:5]
328-
posCursor:[110:29] posNoWhite:[110:28] Found expr:[108:6->110:29]
329-
posCursor:[110:29] posNoWhite:[110:28] Found expr:[109:6->110:29]
330-
posCursor:[110:29] posNoWhite:[110:28] Found expr:[110:9->110:29]
299+
Complete src/CompletionFunctionArguments.res 109:29
300+
posCursor:[109:29] posNoWhite:[109:28] Found expr:[105:3->114:4]
301+
JSX <div:[105:3->105:6] onMouseDown[106:4->106:15]=...[106:35->113:5]> _children:114:2
302+
posCursor:[109:29] posNoWhite:[109:28] Found expr:[106:35->113:5]
303+
posCursor:[109:29] posNoWhite:[109:28] Found expr:[107:6->109:29]
304+
posCursor:[109:29] posNoWhite:[109:28] Found expr:[108:6->109:29]
305+
posCursor:[109:29] posNoWhite:[109:28] Found expr:[109:9->109:29]
331306
Completable: Cpath Value[thisGetsBrokenLoc]->a <<jsx>>
332-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
333-
looking for thisGetsBrokenLoc startPos 106:16
334-
[]
307+
[{
308+
"label": "ReactEvent.Mouse.altKey",
309+
"kind": 12,
310+
"tags": [],
311+
"detail": "t => bool",
312+
"documentation": null
313+
}]
335314

336-
Complete src/CompletionFunctionArguments.res 112:27
337-
posCursor:[112:27] posNoWhite:[112:26] Found expr:[105:3->115:4]
338-
JSX <div:[105:3->105:6] onMouseDown[106:4->106:15]=...[106:35->114:5]> _children:115:2
339-
posCursor:[112:27] posNoWhite:[112:26] Found expr:[106:35->114:5]
340-
posCursor:[112:27] posNoWhite:[112:26] Found expr:[108:6->112:27]
341-
posCursor:[112:27] posNoWhite:[112:26] Found expr:[109:6->112:27]
342-
posCursor:[112:27] posNoWhite:[112:26] Found expr:[112:9->112:27]
315+
Complete src/CompletionFunctionArguments.res 111:27
316+
posCursor:[111:27] posNoWhite:[111:26] Found expr:[105:3->114:4]
317+
JSX <div:[105:3->105:6] onMouseDown[106:4->106:15]=...[106:35->113:5]> _children:114:2
318+
posCursor:[111:27] posNoWhite:[111:26] Found expr:[106:35->113:5]
319+
posCursor:[111:27] posNoWhite:[111:26] Found expr:[107:6->111:27]
320+
posCursor:[111:27] posNoWhite:[111:26] Found expr:[108:6->111:27]
321+
posCursor:[111:27] posNoWhite:[111:26] Found expr:[111:9->111:27]
343322
Completable: Cpath Value[reassignedWorks]->a <<jsx>>
344-
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
345323
[{
346324
"label": "ReactEvent.Mouse.altKey",
347325
"kind": 12,

0 commit comments

Comments
 (0)