@@ -161,6 +161,33 @@ let rec exprToContextPath (e : Parsetree.expression) =
161
161
match exprToContextPath e1 with
162
162
| None -> None
163
163
| Some contexPath -> Some (CPObj (contexPath, txt)))
164
+ | Pexp_apply
165
+ ( {pexp_desc = Pexp_ident {txt = Lident " |." }},
166
+ [
167
+ (_, lhs);
168
+ (_, {pexp_desc = Pexp_apply (d, args); pexp_loc; pexp_attributes});
169
+ ] ) ->
170
+ (* Transform away pipe with apply call *)
171
+ exprToContextPath
172
+ {
173
+ pexp_desc = Pexp_apply (d, (Nolabel , lhs) :: args);
174
+ pexp_loc;
175
+ pexp_attributes;
176
+ }
177
+ | Pexp_apply
178
+ ( {pexp_desc = Pexp_ident {txt = Lident " |." }},
179
+ [(_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes})]
180
+ ) ->
181
+ (* Transform away pipe with identifier *)
182
+ exprToContextPath
183
+ {
184
+ pexp_desc =
185
+ Pexp_apply
186
+ ( {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes},
187
+ [(Nolabel , lhs)] );
188
+ pexp_loc;
189
+ pexp_attributes;
190
+ }
164
191
| Pexp_apply (e1 , args ) -> (
165
192
match exprToContextPath e1 with
166
193
| None -> None
@@ -185,33 +212,14 @@ let completePipeChain (exp : Parsetree.expression) =
185
212
Example: someArray->Js.Array2.map(v => v + 2)-> *)
186
213
| Pexp_apply
187
214
( {pexp_desc = Pexp_ident {txt = Lident " |." }},
188
- [
189
- (_, lhs);
190
- (_, {pexp_desc = Pexp_apply (d, args); pexp_loc; pexp_attributes});
191
- ] ) ->
192
- exprToContextPath
193
- {
194
- pexp_desc = Pexp_apply (d, (Nolabel , lhs) :: args);
195
- pexp_loc;
196
- pexp_attributes;
197
- }
198
- |> Option. map (fun ctxPath -> (ctxPath, d.pexp_loc))
215
+ [_; (_, {pexp_desc = Pexp_apply (d, _)})] ) ->
216
+ exprToContextPath exp |> Option. map (fun ctxPath -> (ctxPath, d.pexp_loc))
199
217
(* When the left side of the pipe we're completing is an identifier application.
200
218
Example: someArray->filterAllTheGoodStuff-> *)
201
219
| Pexp_apply
202
220
( {pexp_desc = Pexp_ident {txt = Lident " |." }},
203
- [(_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes})]
204
- ) ->
205
- exprToContextPath
206
- {
207
- pexp_desc =
208
- Pexp_apply
209
- ( {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes},
210
- [(Nolabel , lhs)] );
211
- pexp_loc;
212
- pexp_attributes;
213
- }
214
- |> Option. map (fun ctxPath -> (ctxPath, pexp_loc))
221
+ [_; (_, {pexp_desc = Pexp_ident _; pexp_loc})] ) ->
222
+ exprToContextPath exp |> Option. map (fun ctxPath -> (ctxPath, pexp_loc))
215
223
| _ -> None
216
224
217
225
let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
0 commit comments