Skip to content

Commit ddedba2

Browse files
committed
Add pipe completions from current module
1 parent 3c4b033 commit ddedba2

26 files changed

+357
-2
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,15 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
11731173
~full ~rawOpens typ
11741174
else []
11751175
in
1176+
(* Add completions from the current module. *)
1177+
let currentModuleCompletions =
1178+
completionsForPipeFromCompletionPath ~envCompletionIsMadeFrom
1179+
~opens:[] ~pos ~scope ~debug ~prefix ~env ~rawOpens ~full []
1180+
|> TypeUtils.filterPipeableFunctions ~synthetic:true ~env ~full
1181+
~targetTypeId:mainTypeId
1182+
in
11761183
jsxCompletions @ pipeCompletions @ extraCompletions
1177-
@ globallyConfiguredCompletions))
1184+
@ currentModuleCompletions @ globallyConfiguredCompletions))
11781185
| CTuple ctxPaths ->
11791186
if Debug.verbose () then print_endline "[ctx_path]--> CTuple";
11801187
(* Turn a list of context paths into a list of type expressions. *)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module X = {
2+
type t
3+
}
4+
5+
module Y = {
6+
open X
7+
8+
let z = (x: t) => ""
9+
10+
let a = (x:t) => {
11+
// x.
12+
// ^com
13+
()
14+
}
15+
16+
let b = (x:t) => 4
17+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ContextPath Value[a]
88
Path a
99
CPPipe pathFromEnv:Test found:true
1010
Path Test.
11+
Path
1112
[{
1213
"label": "Test.name",
1314
"kind": 12,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ContextPath Value[ax]
88
Path ax
99
CPPipe pathFromEnv:Test found:true
1010
Path Test.
11+
Path
1112
[{
1213
"label": "Test.add",
1314
"kind": 12,

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

Lines changed: 32 additions & 1 deletion
Large diffs are not rendered by default.

tests/analysis_tests/tests/src/expected/CompletionConfiguredBuiltins.res.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ContextPath Value[x]
88
Path x
99
Path Stdlib.Array.em
1010
Path ArrayUtils.em
11+
Path em
1112
[{
1213
"label": "ArrayUtils.empty",
1314
"kind": 12,
@@ -27,6 +28,7 @@ Path fastify
2728
CPPipe pathFromEnv:Fastify found:false
2829
Path Fastify.doSt
2930
Path FastifyExt.doSt
31+
Path doSt
3032
[{
3133
"label": "FastifyExt.doStuff",
3234
"kind": 12,

tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ ContextPath Value[fff]
10121012
Path fff
10131013
CPPipe pathFromEnv: found:true
10141014
Path CompletionExpressions.someOpt
1015+
Path someOpt
10151016
[{
10161017
"label": "someOptField",
10171018
"kind": 5,
@@ -1486,6 +1487,7 @@ ContextPath Value[someTyp]
14861487
Path someTyp
14871488
CPPipe pathFromEnv: found:true
14881489
Path CompletionExpressions.
1490+
Path
14891491
[{
14901492
"label": "test",
14911493
"kind": 5,
@@ -1546,6 +1548,7 @@ ContextPath Value[someTyp]
15461548
Path someTyp
15471549
CPPipe pathFromEnv: found:true
15481550
Path CompletionExpressions.
1551+
Path
15491552
[{
15501553
"label": "test",
15511554
"kind": 5,

tests/analysis_tests/tests/src/expected/CompletionFromModule.res.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ContextPath Value[n]
1212
Path n
1313
CPPipe pathFromEnv:SomeModule found:true
1414
Path SomeModule.
15+
Path
1516
[{
1617
"label": "name",
1718
"kind": 5,
@@ -47,6 +48,7 @@ Path nn
4748
CPPipe pathFromEnv:SomeOtherModule found:true
4849
Path SomeOtherModule.
4950
Path CompletionFromModule.SomeOtherModule.
51+
Path
5052
[{
5153
"label": "nname",
5254
"kind": 5,
@@ -129,6 +131,7 @@ Path nnn
129131
CPPipe pathFromEnv: found:true
130132
Path CompletionFromModule.
131133
Path CompletionFromModule.SomeOtherModule.
134+
Path
132135
[{
133136
"label": "SomeOtherModule.getNName",
134137
"kind": 12,
@@ -155,6 +158,7 @@ Path nnn
155158
CPPipe pathFromEnv: found:true
156159
Path CompletionFromModule.
157160
Path CompletionFromModule.SomeOtherModule.
161+
Path
158162
[{
159163
"label": "getNName",
160164
"kind": 12,

tests/analysis_tests/tests/src/expected/CompletionFromModule2.res.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ContextPath Value[CompletionFromModule, n]
1212
Path CompletionFromModule.n
1313
CPPipe pathFromEnv:SomeModule found:true
1414
Path CompletionFromModule.SomeModule.
15+
Path
1516
[{
1617
"label": "name",
1718
"kind": 5,
@@ -47,6 +48,7 @@ Path CompletionFromModule.nn
4748
CPPipe pathFromEnv:SomeOtherModule found:true
4849
Path CompletionFromModule.SomeOtherModule.
4950
Path CompletionFromModule.SomeOtherModule.
51+
Path
5052
[{
5153
"label": "nname",
5254
"kind": 5,
@@ -114,6 +116,7 @@ Path CompletionFromModule.nnn
114116
CPPipe pathFromEnv: found:true
115117
Path CompletionFromModule.
116118
Path CompletionFromModule.SomeOtherModule.
119+
Path
117120
[{
118121
"label": "CompletionFromModule.SomeOtherModule.getNName",
119122
"kind": 12,
@@ -140,6 +143,7 @@ Path CompletionFromModule.nnn
140143
CPPipe pathFromEnv: found:true
141144
Path CompletionFromModule.
142145
Path CompletionFromModule.SomeOtherModule.
146+
Path
143147
[{
144148
"label": "getNName",
145149
"kind": 12,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ ContextPath Value[thisGetsBrokenLoc]
438438
Path thisGetsBrokenLoc
439439
CPPipe pathFromEnv:JsxEvent.Mouse found:false
440440
Path JsxEvent.Mouse.a
441+
Path a
441442
[{
442443
"label": "JsxEvent.Mouse.altKey",
443444
"kind": 12,
@@ -461,6 +462,7 @@ ContextPath Value[reassignedWorks]
461462
Path reassignedWorks
462463
CPPipe pathFromEnv:JsxEvent.Mouse found:false
463464
Path JsxEvent.Mouse.a
465+
Path a
464466
[{
465467
"label": "JsxEvent.Mouse.altKey",
466468
"kind": 12,
@@ -482,6 +484,7 @@ ContextPath Value[fineModuleVal]
482484
Path fineModuleVal
483485
CPPipe pathFromEnv:FineModule found:true
484486
Path FineModule.
487+
Path
485488
[{
486489
"label": "FineModule.setToFalse",
487490
"kind": 12,

0 commit comments

Comments
 (0)