Skip to content

Commit 59d5258

Browse files
committed
example of loc being broken
1 parent 9fc87db commit 59d5258

File tree

5 files changed

+95
-2
lines changed

5 files changed

+95
-2
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ 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
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);
256259
match Hashtbl.find_opt localTables.valueTable (name, Loc.start loc) with
257260
| Some declared ->
258261
if not (Hashtbl.mem localTables.namesUsed name) then (
@@ -276,7 +279,7 @@ let processLocalValue name loc ~prefix ~exact ~env
276279
(Ctype.newconstr
277280
(Path.Pident (Ident.create "Type Not Known"))
278281
[]))
279-
:: localTables.resultRev
282+
:: localTables.resultRev)
280283

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

analysis/src/LocalTables.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ 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);
2834
Hashtbl.replace localTables.valueTable
2935
(declared.name.txt, declared.extentLoc |> Loc.start)
3036
declared)

analysis/src/ProcessExtra.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@ 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);
363368
let declared =
364369
ProcessAttributes.newDeclared ~name ~stamp ~modulePath:NotVisible
365370
~extent:pattern.pat_loc ~item:pattern.pat_type false

analysis/tests/src/CompletionFunctionArguments.res

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,28 @@ let fnTakingRecord = (r: someRecord) => {
8989

9090
// let _ = fnTakingRecord({})
9191
// ^com
92+
93+
module FineModule = {
94+
type t = {
95+
online: bool,
96+
somethingElse: string,
97+
}
98+
99+
let setToFalse = (t: t) => {
100+
...t,
101+
online: false,
102+
}
103+
}
104+
105+
let _ =
106+
<div
107+
onMouseDown={thisGetsBrokenLoc => {
108+
// ^com
109+
let reassignedWorks = thisGetsBrokenLoc
110+
ignore(reassignedWorks)
111+
// thisGetsBrokenLoc->a
112+
// ^com
113+
// reassignedWorks->a
114+
// ^com
115+
}}
116+
/>

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ 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]
56
[{
67
"label": "true",
78
"kind": 4,
@@ -20,6 +21,8 @@ Complete src/CompletionFunctionArguments.res 13:25
2021
posCursor:[13:25] posNoWhite:[13:24] Found expr:[13:11->13:26]
2122
Pexp_apply ...[13:11->13:17] (~isOn13:19->13:23=...[13:24->13:25])
2223
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]
2326
[{
2427
"label": "true",
2528
"kind": 4,
@@ -39,6 +42,7 @@ Complete src/CompletionFunctionArguments.res 16:25
3942
posCursor:[16:25] posNoWhite:[16:24] Found expr:[16:11->16:26]
4043
Pexp_apply ...[16:11->16:17] (~isOff16:19->16:24=...__ghost__[0:-1->0:-1])
4144
Completable: Cexpression CArgument Value[someFn](~isOff)
45+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
4246
[{
4347
"label": "true",
4448
"kind": 4,
@@ -61,6 +65,7 @@ posCursor:[21:27] posNoWhite:[21:26] Found expr:[21:7->21:28]
6165
posCursor:[21:27] posNoWhite:[21:26] Found expr:[21:14->21:28]
6266
Pexp_apply ...[21:14->21:20] (~isOn21:22->21:26=...__ghost__[0:-1->0:-1])
6367
Completable: Cexpression CArgument Value[someFn](~isOn)
68+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
6469
[{
6570
"label": "true",
6671
"kind": 4,
@@ -79,6 +84,8 @@ Complete src/CompletionFunctionArguments.res 34:24
7984
posCursor:[34:24] posNoWhite:[34:23] Found expr:[34:11->34:25]
8085
Pexp_apply ...[34:11->34:22] (...[34:23->34:24])
8186
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]
8289
[{
8390
"label": "false",
8491
"kind": 4,
@@ -91,6 +98,7 @@ Complete src/CompletionFunctionArguments.res 51:39
9198
posCursor:[51:39] posNoWhite:[51:38] Found expr:[51:11->51:40]
9299
Pexp_apply ...[51:11->51:30] (~config51:32->51:38=...__ghost__[0:-1->0:-1])
93100
Completable: Cexpression CArgument Value[someFnTakingVariant](~config)
101+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
94102
[{
95103
"label": "One",
96104
"kind": 4,
@@ -121,6 +129,8 @@ Complete src/CompletionFunctionArguments.res 54:40
121129
posCursor:[54:40] posNoWhite:[54:39] Found expr:[54:11->54:41]
122130
Pexp_apply ...[54:11->54:30] (~config54:32->54:38=...[54:39->54:40])
123131
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]
124134
[{
125135
"label": "One",
126136
"kind": 4,
@@ -154,6 +164,8 @@ Complete src/CompletionFunctionArguments.res 57:33
154164
posCursor:[57:33] posNoWhite:[57:32] Found expr:[57:11->57:34]
155165
Pexp_apply ...[57:11->57:30] (...[57:31->57:33])
156166
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]
157169
[{
158170
"label": "Some(_)",
159171
"kind": 4,
@@ -175,6 +187,8 @@ Complete src/CompletionFunctionArguments.res 60:44
175187
posCursor:[60:44] posNoWhite:[60:43] Found expr:[60:11->60:45]
176188
Pexp_apply ...[60:11->60:30] (~configOpt260:32->60:42=...[60:43->60:44])
177189
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]
178192
[{
179193
"label": "One",
180194
"kind": 4,
@@ -208,6 +222,7 @@ Complete src/CompletionFunctionArguments.res 63:23
208222
posCursor:[63:23] posNoWhite:[63:22] Found expr:[63:11->63:24]
209223
Pexp_apply ...[63:11->63:22] (...[63:23->63:24])
210224
Completable: Cexpression CArgument Value[someOtherFn]($0)
225+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
211226
[{
212227
"label": "true",
213228
"kind": 4,
@@ -226,6 +241,7 @@ Complete src/CompletionFunctionArguments.res 66:28
226241
posCursor:[66:28] posNoWhite:[66:27] Found expr:[66:11->66:30]
227242
Pexp_apply ...[66:11->66:22] (...[66:23->66:24], ...[66:26->66:27])
228243
Completable: Cexpression CArgument Value[someOtherFn]($2)
244+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
229245
[{
230246
"label": "true",
231247
"kind": 4,
@@ -243,6 +259,8 @@ Completable: Cexpression CArgument Value[someOtherFn]($2)
243259
Complete src/CompletionFunctionArguments.res 69:30
244260
posCursor:[69:30] posNoWhite:[69:29] Found expr:[69:11->69:31]
245261
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]
246264
[{
247265
"label": "true",
248266
"kind": 4,
@@ -262,6 +280,7 @@ Complete src/CompletionFunctionArguments.res 76:25
262280
posCursor:[76:25] posNoWhite:[76:24] Found expr:[76:11->76:26]
263281
Pexp_apply ...[76:11->76:24] (...[76:25->76:26])
264282
Completable: Cexpression CArgument Value[fnTakingTuple]($0)
283+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
265284
[{
266285
"label": "(_, _, _)",
267286
"kind": 12,
@@ -276,6 +295,7 @@ Complete src/CompletionFunctionArguments.res 89:27
276295
posCursor:[89:27] posNoWhite:[89:26] Found expr:[89:11->89:29]
277296
Pexp_apply ...[89:11->89:25] (...[89:26->89:28])
278297
Completable: Cexpression CArgument Value[fnTakingRecord]($0)->recordBody
298+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
279299
[{
280300
"label": "age",
281301
"kind": 5,
@@ -296,3 +316,37 @@ Completable: Cexpression CArgument Value[fnTakingRecord]($0)->recordBody
296316
"documentation": null
297317
}]
298318

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]
331+
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+
[]
335+
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]
343+
Completable: Cpath Value[reassignedWorks]->a <<jsx>>
344+
populaing thisGetsBrokenLoc ReactEvent.Mouse.t startPos 0:-1 full pos __ghost__[0:-1->0:-1]
345+
[{
346+
"label": "ReactEvent.Mouse.altKey",
347+
"kind": 12,
348+
"tags": [],
349+
"detail": "t => bool",
350+
"documentation": null
351+
}]
352+

0 commit comments

Comments
 (0)