Skip to content

Commit f82ad64

Browse files
committed
Add debug for pipe internals.
1 parent 7032857 commit f82ad64

11 files changed

+104
-0
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,12 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
873873
(* by doing this ~env:envFromCompletionItem*)
874874
~env ~package ~full ~lhsLoc
875875
in
876+
if debug then
877+
if env <> envFromCompletionItem then
878+
Printf.printf "CPPipe env:%s envFromCompletionItem:%s\n"
879+
(QueryEnv.toString env)
880+
(QueryEnv.toString envFromCompletionItem)
881+
else Printf.printf "CPPipe env:%s\n" (QueryEnv.toString env);
876882
let completionPath =
877883
match typ with
878884
| Builtin (builtin, _) ->
@@ -906,6 +912,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
906912
| Tlink {desc = Tconstr (path, _typeArgs, _)}
907913
| Tsubst {desc = Tconstr (path, _typeArgs, _)}
908914
| Tpoly ({desc = Tconstr (path, _typeArgs, _)}, []) -> (
915+
if debug then Printf.printf "CPPipe type path:%s\n" (Path.name path);
909916
match Utils.expandPath path with
910917
| _ :: pathRev ->
911918
(* type path is relative to the completion environment

analysis/src/SharedTypes.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,14 @@ module QueryEnv : sig
267267
The result is A.B.C.D if D is inside C.
268268
Or A.B.D or A.D or D if it's in one of its parents. *)
269269
val pathFromEnv : t -> path -> path
270+
271+
val toString : t -> string
270272
end = struct
271273
type t = {file: File.t; exported: Exported.t; pathRev: path; parent: t option}
272274

275+
let toString {file; pathRev} =
276+
file.moduleName :: List.rev pathRev |> String.concat "."
277+
273278
let fromFile (file : File.t) =
274279
{file; exported = file.structure.exported; pathRev = []; parent = None}
275280

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Completable: Cpath Value[a]->
44
ContextPath Value[a]->
55
ContextPath Value[a]
66
Path a
7+
CPPipe env:CompletePrioritize1
8+
CPPipe type path:Test.t
79
Path Test.
810
[{
911
"label": "Test.add",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Completable: Cpath Value[ax]->
44
ContextPath Value[ax]->
55
ContextPath Value[ax]
66
Path ax
7+
CPPipe env:CompletePrioritize2
8+
CPPipe type path:Test.t
79
Path Test.
810
[{
911
"label": "Test.add",

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ posCursor:[26:13] posNoWhite:[26:12] Found expr:[26:3->26:13]
392392
Completable: Cpath array<int>->m
393393
ContextPath array<int>->m
394394
ContextPath array<int>
395+
CPPipe env:Completion
395396
Path Js.Array2.m
396397
[{
397398
"label": "Js.Array2.mapi",
@@ -412,6 +413,7 @@ posCursor:[29:13] posNoWhite:[29:12] Found expr:[29:3->29:13]
412413
Completable: Cpath string->toU
413414
ContextPath string->toU
414415
ContextPath string
416+
CPPipe env:Completion
415417
Path Js.String2.toU
416418
[{
417419
"label": "Js.String2.toUpperCase",
@@ -427,6 +429,7 @@ Completable: Cpath Value[op]->e
427429
ContextPath Value[op]->e
428430
ContextPath Value[op]
429431
Path op
432+
CPPipe env:Completion
430433
Path Belt.Option.e
431434
[{
432435
"label": "Belt.Option.eqU",
@@ -450,6 +453,8 @@ Completable: Cpath Value[fa]->
450453
ContextPath Value[fa]->
451454
ContextPath Value[fa]
452455
Path fa
456+
CPPipe env:Completion
457+
CPPipe type path:ForAuto.t
453458
Path ForAuto.
454459
[{
455460
"label": "ForAuto.abc",
@@ -1010,6 +1015,8 @@ ContextPath Value[FAO, forAutoObject]["forAutoLabel"].forAuto
10101015
ContextPath Value[FAO, forAutoObject]["forAutoLabel"]
10111016
ContextPath Value[FAO, forAutoObject]
10121017
Path FAO.forAutoObject
1018+
CPPipe env:Completion envFromCompletionItem:Completion.FAR
1019+
CPPipe type path:ForAuto.t
10131020
Path ForAuto.
10141021
[{
10151022
"label": "ForAuto.abc",
@@ -1760,6 +1767,7 @@ Raw opens: 3 Js.place holder ... Shadow.B.place holder ... Shadow.A.place holder
17601767
Resolved opens 3 Completion.res Completion.res js.ml
17611768
ContextPath array->ma
17621769
ContextPath array
1770+
CPPipe env:Completion
17631771
Path Js.Array2.ma
17641772
[{
17651773
"label": "Array2.mapi",
@@ -1906,6 +1914,7 @@ Raw opens: 2 Shadow.B.place holder ... Shadow.A.place holder
19061914
Resolved opens 2 Completion.res Completion.res
19071915
ContextPath int->t
19081916
ContextPath int
1917+
CPPipe env:Completion
19091918
Path Belt.Int.t
19101919
[{
19111920
"label": "Belt.Int.toString",
@@ -1928,6 +1937,7 @@ Raw opens: 2 Shadow.B.place holder ... Shadow.A.place holder
19281937
Resolved opens 2 Completion.res Completion.res
19291938
ContextPath float->t
19301939
ContextPath float
1940+
CPPipe env:Completion
19311941
Path Belt.Float.t
19321942
[{
19331943
"label": "Belt.Float.toInt",
@@ -1951,6 +1961,7 @@ Resolved opens 2 Completion.res Completion.res
19511961
ContextPath Value[ok]->g
19521962
ContextPath Value[ok]
19531963
Path ok
1964+
CPPipe env:Completion
19541965
Path Belt.Result.g
19551966
[{
19561967
"label": "Belt.Result.getExn",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ Completable: Cpath Value[thisGetsBrokenLoc]->a <<jsx>>
349349
ContextPath Value[thisGetsBrokenLoc]->a <<jsx>>
350350
ContextPath Value[thisGetsBrokenLoc]
351351
Path thisGetsBrokenLoc
352+
CPPipe env:CompletionFunctionArguments
353+
CPPipe type path:ReactEvent.Mouse.t
352354
Path ReactEvent.Mouse.a
353355
[{
354356
"label": "ReactEvent.Mouse.altKey",
@@ -369,6 +371,8 @@ Completable: Cpath Value[reassignedWorks]->a <<jsx>>
369371
ContextPath Value[reassignedWorks]->a <<jsx>>
370372
ContextPath Value[reassignedWorks]
371373
Path reassignedWorks
374+
CPPipe env:CompletionFunctionArguments
375+
CPPipe type path:ReactEvent.Mouse.t
372376
Path ReactEvent.Mouse.a
373377
[{
374378
"label": "ReactEvent.Mouse.altKey",

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Path aliased
77
ContextPath Value[x]
88
Path x
99
ContextPath int
10+
CPPipe env:CompletionInferValues
1011
Path Belt.Int.f
1112
[{
1213
"label": "Belt.Int.fromString",
@@ -147,6 +148,8 @@ ContextPath CArgument CArgument Value[reactEventFn]($0)($0)
147148
ContextPath CArgument Value[reactEventFn]($0)
148149
ContextPath Value[reactEventFn]
149150
Path reactEventFn
151+
CPPipe env:CompletionInferValues
152+
CPPipe type path:ReactEvent.Mouse.t
150153
Path ReactEvent.Mouse.pr
151154
[{
152155
"label": "ReactEvent.Mouse.preventDefault",
@@ -169,6 +172,8 @@ ContextPath CArgument CJsxPropValue [div] onMouseEnter($0)
169172
ContextPath CJsxPropValue [div] onMouseEnter
170173
Path ReactDOM.domProps
171174
Path JsxDOM.domProps
175+
CPPipe env:CompletionInferValues
176+
CPPipe type path:JsxEvent.Mouse.t
172177
Path JsxEvent.Mouse.pr
173178
[{
174179
"label": "JsxEvent.Mouse.preventDefault",
@@ -190,6 +195,8 @@ Path event
190195
ContextPath CArgument CJsxPropValue [Div] onMouseEnter($0)
191196
ContextPath CJsxPropValue [Div] onMouseEnter
192197
Path Div.make
198+
CPPipe env:CompletionInferValues envFromCompletionItem:CompletionInferValues.Div
199+
CPPipe type path:JsxEvent.Mouse.t
193200
Path JsxEvent.Mouse.pr
194201
[{
195202
"label": "JsxEvent.Mouse.preventDefault",
@@ -212,6 +219,7 @@ Path btn
212219
ContextPath Value[JsxEvent, Mouse, button](Nolabel)
213220
ContextPath Value[JsxEvent, Mouse, button]
214221
Path JsxEvent.Mouse.button
222+
CPPipe env:CompletionInferValues envFromCompletionItem:JsxEvent.Mouse
215223
Path Belt.Int.t
216224
[{
217225
"label": "Belt.Int.toString",
@@ -240,6 +248,7 @@ Path btn
240248
ContextPath Value[Belt, Int, toString](Nolabel)
241249
ContextPath Value[Belt, Int, toString]
242250
Path Belt.Int.toString
251+
CPPipe env:CompletionInferValues envFromCompletionItem:Belt_Int
243252
Path Js.String2.spl
244253
[{
245254
"label": "Js.String2.splitAtMost",
@@ -280,6 +289,7 @@ Path btn
280289
ContextPath Value[Js, String2, split](Nolabel, Nolabel)
281290
ContextPath Value[Js, String2, split]
282291
Path Js.String2.split
292+
CPPipe env:CompletionInferValues envFromCompletionItem:Js_string2
283293
Path Js.Array2.ma
284294
[{
285295
"label": "Js.Array2.mapi",
@@ -401,6 +411,7 @@ ContextPath Value[x]
401411
Path x
402412
ContextPath Type[someRecordWithNestedStuff]
403413
Path someRecordWithNestedStuff
414+
CPPipe env:CompletionInferValues
404415
Path Js.String2.slic
405416
[{
406417
"label": "Js.String2.sliceToEnd",
@@ -427,6 +438,7 @@ ContextPath Value[x]
427438
Path x
428439
ContextPath Type[someRecordWithNestedStuff]
429440
Path someRecordWithNestedStuff
441+
CPPipe env:CompletionInferValues
430442
Path Belt.Int.toS
431443
[{
432444
"label": "Belt.Int.toString",
@@ -450,6 +462,7 @@ ContextPath Value[x]
450462
Path x
451463
ContextPath Type[otherNestedRecord]
452464
Path otherNestedRecord
465+
CPPipe env:CompletionInferValues
453466
Path Belt.Int.toS
454467
[{
455468
"label": "Belt.Int.toString",
@@ -474,6 +487,7 @@ ContextPath Value[x]
474487
Path x
475488
ContextPath Type[otherNestedRecord]
476489
Path otherNestedRecord
490+
CPPipe env:CompletionInferValues
477491
Path Belt.Int.toS
478492
[{
479493
"label": "Belt.Int.toString",
@@ -494,6 +508,7 @@ ContextPath Value[x]
494508
Path x
495509
ContextPath Type[otherNestedRecord]
496510
Path otherNestedRecord
511+
CPPipe env:CompletionInferValues
497512
Path Js.String2.slic
498513
[{
499514
"label": "Js.String2.sliceToEnd",
@@ -520,6 +535,7 @@ ContextPath Value[x]
520535
Path x
521536
ContextPath Type[otherNestedRecord]
522537
Path otherNestedRecord
538+
CPPipe env:CompletionInferValues
523539
Path Js.String2.slic
524540
[{
525541
"label": "Js.String2.sliceToEnd",
@@ -546,6 +562,7 @@ ContextPath Value[x]
546562
Path x
547563
ContextPath Type[otherNestedRecord]
548564
Path otherNestedRecord
565+
CPPipe env:CompletionInferValues
549566
Path Js.String2.slic
550567
[{
551568
"label": "Js.String2.sliceToEnd",
@@ -597,6 +614,7 @@ Path v
597614
ContextPath Value[x]
598615
Path x
599616
ContextPath int
617+
CPPipe env:CompletionInferValues
600618
Path Belt.Int.toSt
601619
[{
602620
"label": "Belt.Int.toString",
@@ -646,6 +664,8 @@ ContextPath CArgument CArgument Value[fn2](~cb)($0)
646664
ContextPath CArgument Value[fn2](~cb)
647665
ContextPath Value[fn2]
648666
Path fn2
667+
CPPipe env:CompletionInferValues
668+
CPPipe type path:ReactDOM.Client.Root.t
649669
Path ReactDOM.Client.Root.
650670
[{
651671
"label": "ReactDOM.Client.Root.unmount",
@@ -676,6 +696,8 @@ ContextPath CArgument CArgument Value[fn3](~cb)($0)
676696
ContextPath CArgument Value[fn3](~cb)
677697
ContextPath Value[fn3]
678698
Path fn3
699+
CPPipe env:CompletionInferValues
700+
CPPipe type path:CompletionSupport.Test.t
679701
Path CompletionSupport.Test.
680702
[{
681703
"label": "CompletionSupport.Test.add",
@@ -769,6 +791,8 @@ ContextPath CArgument CArgument Value[CompletionSupport2, makeRenderer](~render)
769791
ContextPath CArgument Value[CompletionSupport2, makeRenderer](~render)
770792
ContextPath Value[CompletionSupport2, makeRenderer]
771793
Path CompletionSupport2.makeRenderer
794+
CPPipe env:CompletionInferValues envFromCompletionItem:CompletionSupport2.Internal
795+
CPPipe type path:ReactDOM.Client.Root.t
772796
Path CompletionSupport2.ReactDOM.Client.Root.
773797
[]
774798

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Completable: Cpath Value[someString]->st
44
ContextPath Value[someString]->st
55
ContextPath Value[someString]
66
Path someString
7+
CPPipe env:CompletionJsx
78
Path Js.String2.st
89
[{
910
"label": "Js.String2.startsWith",
@@ -31,6 +32,7 @@ Completable: Cpath Value[someString]->st <<jsx>>
3132
ContextPath Value[someString]->st <<jsx>>
3233
ContextPath Value[someString]
3334
Path someString
35+
CPPipe env:CompletionJsx
3436
Path Js.String2.st
3537
[{
3638
"label": "React.string",
@@ -76,6 +78,7 @@ Completable: Cpath Value[someString]->st <<jsx>>
7678
ContextPath Value[someString]->st <<jsx>>
7779
ContextPath Value[someString]
7880
Path someString
81+
CPPipe env:CompletionJsx
7982
Path Js.String2.st
8083
[{
8184
"label": "React.string",
@@ -120,6 +123,7 @@ posCursor:[20:27] posNoWhite:[20:26] Found expr:[20:10->20:27]
120123
Completable: Cpath string->st <<jsx>>
121124
ContextPath string->st <<jsx>>
122125
ContextPath string
126+
CPPipe env:CompletionJsx
123127
Path Js.String2.st
124128
[{
125129
"label": "React.string",
@@ -166,6 +170,7 @@ ContextPath Value[Js, String2, trim](Nolabel)->st <<jsx>>
166170
ContextPath Value[Js, String2, trim](Nolabel)
167171
ContextPath Value[Js, String2, trim]
168172
Path Js.String2.trim
173+
CPPipe env:CompletionJsx envFromCompletionItem:Js_string2
169174
Path Js.String2.st
170175
[{
171176
"label": "React.string",
@@ -211,6 +216,7 @@ Completable: Cpath Value[someInt]-> <<jsx>>
211216
ContextPath Value[someInt]-> <<jsx>>
212217
ContextPath Value[someInt]
213218
Path someInt
219+
CPPipe env:CompletionJsx
214220
Path Belt.Int.
215221
[{
216222
"label": "React.int",
@@ -291,6 +297,7 @@ posCursor:[26:14] posNoWhite:[26:13] Found expr:[26:10->0:-1]
291297
Completable: Cpath int-> <<jsx>>
292298
ContextPath int-> <<jsx>>
293299
ContextPath int
300+
CPPipe env:CompletionJsx
294301
Path Belt.Int.
295302
[{
296303
"label": "React.int",
@@ -372,6 +379,7 @@ Completable: Cpath Value[someArr]->a <<jsx>>
372379
ContextPath Value[someArr]->a <<jsx>>
373380
ContextPath Value[someArr]
374381
Path someArr
382+
CPPipe env:CompletionJsx
375383
Path Js.Array2.a
376384
[{
377385
"label": "React.array",

0 commit comments

Comments
 (0)