Skip to content

Add pipe completions from current module #7471

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

Merged
merged 3 commits into from
May 14, 2025
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
9 changes: 8 additions & 1 deletion analysis/src/CompletionBackEnd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1173,8 +1173,15 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
~full ~rawOpens typ
else []
in
(* Add completions from the current module. *)
let currentModuleCompletions =
completionsForPipeFromCompletionPath ~envCompletionIsMadeFrom
~opens:[] ~pos ~scope ~debug ~prefix ~env ~rawOpens ~full []
|> TypeUtils.filterPipeableFunctions ~synthetic:true ~env ~full
~targetTypeId:mainTypeId
in
jsxCompletions @ pipeCompletions @ extraCompletions
@ globallyConfiguredCompletions))
@ currentModuleCompletions @ globallyConfiguredCompletions))
| CTuple ctxPaths ->
if Debug.verbose () then print_endline "[ctx_path]--> CTuple";
(* Turn a list of context paths into a list of type expressions. *)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ContextPath Value[someString]->st <<jsx>>
ContextPath Value[someString]
Path someString
Path Stdlib.String.st
Path st
[{
"label": "GenericJsx.string",
"kind": 12,
Expand Down Expand Up @@ -104,6 +105,7 @@ ContextPath Value[someString]->st <<jsx>>
ContextPath Value[someString]
Path someString
Path Stdlib.String.st
Path st
[{
"label": "string",
"kind": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module X = {
type t
}

module Y = {
open X

let z = (x: t) => ""

let a = (x:t) => {
// x.
// ^com
()
}

let b = (x:t) => 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ContextPath Value[a]
Path a
CPPipe pathFromEnv:Test found:true
Path Test.
Path
[{
"label": "Test.name",
"kind": 12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ContextPath Value[ax]
Path ax
CPPipe pathFromEnv:Test found:true
Path Test.
Path
[{
"label": "Test.add",
"kind": 12,
Expand Down
31 changes: 31 additions & 0 deletions tests/analysis_tests/tests/src/expected/Completion.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ ContextPath array<int>->m
ContextPath array<int>
Path Stdlib.Array.m
Path ArrayUtils.m
Path m
[{
"label": "Array.map",
"kind": 12,
Expand All @@ -656,6 +657,7 @@ Resolved opens 1 Stdlib
ContextPath string->toU
ContextPath string
Path Stdlib.String.toU
Path toU
[{
"label": "String.toUpperCase",
"kind": 12,
Expand All @@ -673,6 +675,7 @@ ContextPath Value[op]->e
ContextPath Value[op]
Path op
Path Stdlib.Option.e
Path e
[{
"label": "Option.equal",
"kind": 12,
Expand All @@ -693,6 +696,7 @@ ContextPath Value[fa]
Path fa
CPPipe pathFromEnv:ForAuto found:true
Path ForAuto.
Path
[{
"label": "ForAuto.abc",
"kind": 12,
Expand Down Expand Up @@ -932,6 +936,7 @@ ContextPath Value[r]
Path r
CPPipe pathFromEnv: found:true
Path Completion.
Path
[{
"label": "x",
"kind": 5,
Expand Down Expand Up @@ -960,6 +965,7 @@ ContextPath Value[Objects, Rec, recordVal]
Path Objects.Rec.recordVal
CPPipe pathFromEnv:Rec found:true
Path Objects.Rec.
Path
[{
"label": "xx",
"kind": 5,
Expand Down Expand Up @@ -1046,6 +1052,7 @@ ContextPath Value[q]
Path q
CPPipe pathFromEnv: found:true
Path Completion.aa
Path aa
ContextPath Value[q].aa->
ContextPath Value[q].aa
ContextPath Value[q]
Expand All @@ -1055,8 +1062,10 @@ ContextPath Value[q]
Path q
CPPipe pathFromEnv: found:true
Path Completion.aa
Path aa
CPPipe pathFromEnv: found:true
Path Completion.
Path
[{
"label": "x",
"kind": 5,
Expand Down Expand Up @@ -1086,6 +1095,7 @@ ContextPath Value[q]
Path q
CPPipe pathFromEnv: found:true
Path Completion.aa
Path aa
ContextPath Value[q].aa->n
ContextPath Value[q].aa
ContextPath Value[q]
Expand All @@ -1095,8 +1105,10 @@ ContextPath Value[q]
Path q
CPPipe pathFromEnv: found:true
Path Completion.aa
Path aa
CPPipe pathFromEnv: found:true
Path Completion.n
Path n
[{
"label": "name",
"kind": 5,
Expand Down Expand Up @@ -1307,6 +1319,7 @@ ContextPath Value[FAO, forAutoObject]
Path FAO.forAutoObject
CPPipe pathFromEnv:FAR found:true
Path FAR.
Path
[{
"label": "forAuto",
"kind": 5,
Expand Down Expand Up @@ -1338,8 +1351,10 @@ ContextPath Value[FAO, forAutoObject]
Path FAO.forAutoObject
CPPipe pathFromEnv:FAR found:true
Path FAR.forAuto
Path forAuto
CPPipe pathFromEnv:ForAuto found:false
Path ForAuto.
Path
[{
"label": "ForAuto.abc",
"kind": 12,
Expand All @@ -1352,6 +1367,12 @@ Path ForAuto.
"tags": [],
"detail": "(t, int) => t",
"documentation": null
}, {
"label": "myAmazingFunction",
"kind": 12,
"tags": [],
"detail": "(int, int) => int",
"documentation": null
}]

Complete src/Completion.res 230:55
Expand Down Expand Up @@ -1424,6 +1445,7 @@ ContextPath Value[_z]
Path _z
CPPipe pathFromEnv: found:true
Path Completion.
Path
[{
"label": "x",
"kind": 5,
Expand Down Expand Up @@ -1586,6 +1608,7 @@ ContextPath Value[funRecord]
Path funRecord
CPPipe pathFromEnv: found:true
Path Completion.someFun
Path someFun
Found type for function (~name: string) => unit
[{
"label": "name",
Expand All @@ -1612,6 +1635,7 @@ ContextPath Value[retAA]
Path retAA
CPPipe pathFromEnv: found:true
Path Completion.
Path
[{
"label": "x",
"kind": 5,
Expand Down Expand Up @@ -2191,6 +2215,7 @@ ContextPath Value[funRecord]
Path funRecord
CPPipe pathFromEnv: found:true
Path Completion.
Path
[{
"label": "someFun",
"kind": 5,
Expand All @@ -2217,6 +2242,7 @@ ContextPath array->ma
ContextPath array
Path Stdlib.Array.ma
Path ArrayUtils.ma
Path ma
[{
"label": "Array.map",
"kind": 12,
Expand Down Expand Up @@ -2369,6 +2395,7 @@ Resolved opens 3 Stdlib Completion Completion
ContextPath int->t
ContextPath int
Path Stdlib.Int.t
Path t
[{
"label": "Int.toStringWithRadix",
"kind": 12,
Expand Down Expand Up @@ -2440,6 +2467,7 @@ Resolved opens 3 Stdlib Completion Completion
ContextPath float->t
ContextPath float
Path Stdlib.Float.t
Path t
[{
"label": "Float.toStringWithRadix",
"kind": 12,
Expand Down Expand Up @@ -2512,6 +2540,7 @@ ContextPath Value[ok]->g
ContextPath Value[ok]
Path ok
Path Stdlib.Result.g
Path g
[{
"label": "Result.getExn",
"kind": 12,
Expand Down Expand Up @@ -2547,6 +2576,7 @@ ContextPath Value[rWithDepr]
Path rWithDepr
CPPipe pathFromEnv: found:true
Path Completion.so
Path so
[{
"label": "someInt",
"kind": 5,
Expand Down Expand Up @@ -2606,6 +2636,7 @@ ContextPath Value[uncurried](Nolabel)
ContextPath Value[uncurried]
Path uncurried
Path Stdlib.Int.toS
Path toS
[{
"label": "Int.toStringWithRadix",
"kind": 12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ContextPath Value[x]
Path x
Path Stdlib.Array.em
Path ArrayUtils.em
Path em
[{
"label": "ArrayUtils.empty",
"kind": 12,
Expand All @@ -27,6 +28,7 @@ Path fastify
CPPipe pathFromEnv:Fastify found:false
Path Fastify.doSt
Path FastifyExt.doSt
Path doSt
[{
"label": "FastifyExt.doStuff",
"kind": 12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ ContextPath Value[fff]
Path fff
CPPipe pathFromEnv: found:true
Path CompletionExpressions.someOpt
Path someOpt
[{
"label": "someOptField",
"kind": 5,
Expand Down Expand Up @@ -1486,6 +1487,7 @@ ContextPath Value[someTyp]
Path someTyp
CPPipe pathFromEnv: found:true
Path CompletionExpressions.
Path
[{
"label": "test",
"kind": 5,
Expand Down Expand Up @@ -1546,6 +1548,7 @@ ContextPath Value[someTyp]
Path someTyp
CPPipe pathFromEnv: found:true
Path CompletionExpressions.
Path
[{
"label": "test",
"kind": 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ContextPath Value[n]
Path n
CPPipe pathFromEnv:SomeModule found:true
Path SomeModule.
Path
[{
"label": "name",
"kind": 5,
Expand Down Expand Up @@ -47,6 +48,7 @@ Path nn
CPPipe pathFromEnv:SomeOtherModule found:true
Path SomeOtherModule.
Path CompletionFromModule.SomeOtherModule.
Path
[{
"label": "nname",
"kind": 5,
Expand Down Expand Up @@ -129,6 +131,7 @@ Path nnn
CPPipe pathFromEnv: found:true
Path CompletionFromModule.
Path CompletionFromModule.SomeOtherModule.
Path
[{
"label": "SomeOtherModule.getNName",
"kind": 12,
Expand All @@ -155,6 +158,7 @@ Path nnn
CPPipe pathFromEnv: found:true
Path CompletionFromModule.
Path CompletionFromModule.SomeOtherModule.
Path
[{
"label": "getNName",
"kind": 12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ContextPath Value[CompletionFromModule, n]
Path CompletionFromModule.n
CPPipe pathFromEnv:SomeModule found:true
Path CompletionFromModule.SomeModule.
Path
[{
"label": "name",
"kind": 5,
Expand Down Expand Up @@ -47,6 +48,7 @@ Path CompletionFromModule.nn
CPPipe pathFromEnv:SomeOtherModule found:true
Path CompletionFromModule.SomeOtherModule.
Path CompletionFromModule.SomeOtherModule.
Path
[{
"label": "nname",
"kind": 5,
Expand Down Expand Up @@ -114,6 +116,7 @@ Path CompletionFromModule.nnn
CPPipe pathFromEnv: found:true
Path CompletionFromModule.
Path CompletionFromModule.SomeOtherModule.
Path
[{
"label": "CompletionFromModule.SomeOtherModule.getNName",
"kind": 12,
Expand All @@ -140,6 +143,7 @@ Path CompletionFromModule.nnn
CPPipe pathFromEnv: found:true
Path CompletionFromModule.
Path CompletionFromModule.SomeOtherModule.
Path
[{
"label": "getNName",
"kind": 12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ ContextPath Value[thisGetsBrokenLoc]
Path thisGetsBrokenLoc
CPPipe pathFromEnv:JsxEvent.Mouse found:false
Path JsxEvent.Mouse.a
Path a
[{
"label": "JsxEvent.Mouse.altKey",
"kind": 12,
Expand All @@ -461,6 +462,7 @@ ContextPath Value[reassignedWorks]
Path reassignedWorks
CPPipe pathFromEnv:JsxEvent.Mouse found:false
Path JsxEvent.Mouse.a
Path a
[{
"label": "JsxEvent.Mouse.altKey",
"kind": 12,
Expand All @@ -482,6 +484,7 @@ ContextPath Value[fineModuleVal]
Path fineModuleVal
CPPipe pathFromEnv:FineModule found:true
Path FineModule.
Path
[{
"label": "FineModule.setToFalse",
"kind": 12,
Expand Down
Loading