File tree Expand file tree Collapse file tree 14 files changed +56
-29
lines changed Expand file tree Collapse file tree 14 files changed +56
-29
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ let transform ~path ~pos ~debug ~typ ~hint =
19
19
let cases =
20
20
collectPatterns pattern
21
21
|> List. map (fun (p : Parsetree.pattern ) ->
22
- Ast_helper.Exp. case p (TypeUtils.Codegen. mkFailWithExp () ))
22
+ Ast_helper.Exp. case p.ppat_loc p
23
+ (TypeUtils.Codegen. mkFailWithExp () ))
23
24
in
24
25
let result = ref None in
25
26
let mkIterator ~pos ~result =
Original file line number Diff line number Diff line change @@ -1044,7 +1044,7 @@ module Codegen = struct
1044
1044
Some
1045
1045
(patterns
1046
1046
|> List. map (fun (pat : Parsetree.pattern ) ->
1047
- Ast_helper.Exp. case pat (mkFailWithExp () )))
1047
+ Ast_helper.Exp. case pat.ppat_loc pat (mkFailWithExp () )))
1048
1048
end
1049
1049
1050
1050
let getModulePathRelativeToEnv ~debug ~(env : QueryEnv.t ) ~envFromItem path =
Original file line number Diff line number Diff line change @@ -105,8 +105,13 @@ module IfThenElse = struct
105
105
let mkMatch ~arg ~pat =
106
106
let cases =
107
107
[
108
- Ast_helper.Exp. case pat e1;
109
- Ast_helper.Exp. case (Ast_helper.Pat. any () ) e2;
108
+ Ast_helper.Exp. case
109
+ {
110
+ pat.Parsetree. ppat_loc with
111
+ Location. loc_end = e1.pexp_loc.loc_end;
112
+ }
113
+ pat e1;
114
+ Ast_helper.Exp. case e2.pexp_loc (Ast_helper.Pat. any () ) e2;
110
115
]
111
116
in
112
117
Ast_helper.Exp. match_ ~loc: e.pexp_loc ~attrs: e.pexp_attributes arg
Original file line number Diff line number Diff line change @@ -539,9 +539,9 @@ let default_mapper =
539
539
~attrs: (this.attributes this pld_attributes));
540
540
cases = (fun this l -> List. map (this.case this) l);
541
541
case =
542
- (fun this {pc_bar ; pc_lhs; pc_guard; pc_rhs} ->
542
+ (fun this {pc_loc ; pc_lhs; pc_guard; pc_rhs} ->
543
543
{
544
- pc_bar ;
544
+ pc_loc = this.location this pc_loc ;
545
545
pc_lhs = this.pat this pc_lhs;
546
546
pc_guard = map_opt (this.expr this) pc_guard;
547
547
pc_rhs = this.expr this pc_rhs;
Original file line number Diff line number Diff line change @@ -167,7 +167,15 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
167
167
pexp_desc =
168
168
Pexp_match
169
169
( pvb_expr,
170
- [{pc_bar = None ; pc_lhs = p; pc_guard = None ; pc_rhs = body}] );
170
+ [
171
+ {
172
+ pc_loc =
173
+ {p.ppat_loc with Location. loc_end = body.pexp_loc.loc_end};
174
+ pc_lhs = p;
175
+ pc_guard = None ;
176
+ pc_rhs = body;
177
+ };
178
+ ] );
171
179
pexp_attributes = e.pexp_attributes @ pvb_attributes;
172
180
})
173
181
(* let [@warning "a"] {a;b} = c in body
Original file line number Diff line number Diff line change @@ -208,8 +208,8 @@ module Exp = struct
208
208
jsx_container_element_closing_tag = e;
209
209
}))
210
210
211
- let case ? bar lhs ?guard rhs =
212
- {pc_bar = bar ; pc_lhs = lhs; pc_guard = guard; pc_rhs = rhs}
211
+ let case loc lhs ?guard rhs =
212
+ {pc_loc = loc ; pc_lhs = lhs; pc_guard = guard; pc_rhs = rhs}
213
213
214
214
let make_list_expression loc seq ext_opt =
215
215
let rec handle_seq = function
Original file line number Diff line number Diff line change @@ -231,8 +231,7 @@ module Exp : sig
231
231
Parsetree .jsx_closing_container_tag option ->
232
232
expression
233
233
234
- val case :
235
- ?bar : Lexing .position -> pattern -> ?guard : expression -> expression -> case
234
+ val case : Location .t -> pattern -> ?guard : expression -> expression -> case
236
235
val await : ?loc : loc -> ?attrs : attrs -> expression -> expression
237
236
238
237
val make_list_expression :
Original file line number Diff line number Diff line change @@ -488,9 +488,9 @@ let default_mapper =
488
488
~attrs: (this.attributes this pld_attributes));
489
489
cases = (fun this l -> List. map (this.case this) l);
490
490
case =
491
- (fun this {pc_bar ; pc_lhs; pc_guard; pc_rhs} ->
491
+ (fun this {pc_loc ; pc_lhs; pc_guard; pc_rhs} ->
492
492
{
493
- pc_bar ;
493
+ pc_loc = this.location this pc_loc ;
494
494
pc_lhs = this.pat this pc_lhs;
495
495
pc_guard = map_opt (this.expr this) pc_guard;
496
496
pc_rhs = this.expr this pc_rhs;
Original file line number Diff line number Diff line change @@ -665,7 +665,9 @@ let default_mapper =
665
665
case =
666
666
(fun this {pc_lhs; pc_guard; pc_rhs} ->
667
667
{
668
- pc_bar = None ;
668
+ pc_loc =
669
+ this.location this
670
+ {pc_lhs.ppat_loc with Location. loc_end = pc_rhs.pexp_loc.loc_end};
669
671
pc_lhs = this.pat this pc_lhs;
670
672
pc_guard = map_opt (this.expr this) pc_guard;
671
673
pc_rhs = this.expr this pc_rhs;
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ and jsx_closing_container_tag = {
381
381
382
382
and case = {
383
383
(* (P -> E) or (P when E0 -> E) *)
384
- pc_bar : Lexing .position option ;
384
+ pc_loc : Location .t ;
385
385
pc_lhs : pattern ;
386
386
pc_guard : expression option ;
387
387
pc_rhs : expression ;
You can’t perform that action at this time.
0 commit comments