@@ -167,10 +167,7 @@ let emitVariable ~id ~debug ~loc emitter =
167
167
emitter |> emitFromLoc ~loc ~type_: Variable
168
168
169
169
let emitJsxOpen ~lid ~debug ~loc emitter =
170
- emitter
171
- |> emitLongident
172
- ~pos: (Pos. ofLexing loc.Location. loc_start)
173
- ~lid ~jsx: true ~debug
170
+ emitter |> emitLongident ~pos: (Loc. start loc) ~lid ~jsx: true ~debug
174
171
175
172
let emitJsxClose ~lid ~debug ~pos emitter =
176
173
emitter |> emitLongident ~backwards: true ~pos ~lid ~jsx: true ~debug
@@ -181,21 +178,17 @@ let emitJsxTag ~debug ~name ~pos emitter =
181
178
182
179
let emitType ~lid ~debug ~loc emitter =
183
180
emitter
184
- |> emitLongident ~lower CaseToken:Token. Type
185
- ~pos: (Pos. ofLexing loc.Location. loc_start)
186
- ~lid ~debug
181
+ |> emitLongident ~lower CaseToken:Token. Type ~pos: (Loc. start loc) ~lid ~debug
187
182
188
183
let emitRecordLabel ~(label : Longident.t Location.loc ) ~debug emitter =
189
184
emitter
190
- |> emitLongident ~lower CaseToken:Token. Property
191
- ~pos: (Pos. ofLexing label.loc.loc_start)
192
- ~pos End:(Some (Pos. ofLexing label.loc.loc_end))
185
+ |> emitLongident ~lower CaseToken:Token. Property ~pos: (Loc. start label.loc)
186
+ ~pos End:(Some (Loc. end_ label.loc))
193
187
~lid: label.txt ~debug
194
188
195
189
let emitVariant ~(name : Longident.t Location.loc ) ~debug emitter =
196
190
emitter
197
- |> emitLongident ~last Token:(Some Token. EnumMember )
198
- ~pos: (Pos. ofLexing name.loc.loc_start)
191
+ |> emitLongident ~last Token:(Some Token. EnumMember ) ~pos: (Loc. start name.loc)
199
192
~lid: name.txt ~debug
200
193
201
194
let command ~debug ~emitter ~path =
@@ -243,9 +236,8 @@ let command ~debug ~emitter ~path =
243
236
| Pexp_ident {txt = lid ; loc} ->
244
237
if lid <> Lident " not" then
245
238
emitter
246
- |> emitLongident
247
- ~pos: (Pos. ofLexing loc.loc_start)
248
- ~pos End:(Some (Pos. ofLexing loc.loc_end))
239
+ |> emitLongident ~pos: (Loc. start loc)
240
+ ~pos End:(Some (Loc. end_ loc))
249
241
~lid ~debug ;
250
242
Ast_iterator. default_iterator.expr iterator e
251
243
| Pexp_apply ({pexp_desc = Pexp_ident lident; pexp_loc}, args)
@@ -261,23 +253,22 @@ let command ~debug ~emitter ~path =
261
253
emitter (* --> <div... *)
262
254
|> emitJsxTag ~debug ~name: " <"
263
255
~pos:
264
- (let pos = Pos. ofLexing e.pexp_loc.loc_start in
256
+ (let pos = Loc. start e.pexp_loc in
265
257
(fst pos, snd pos - 1 (* the AST skips the loc of < somehow *) ));
266
258
emitter |> emitJsxOpen ~lid: lident.txt ~debug ~loc: pexp_loc;
267
259
268
260
let posOfGreatherthanAfterProps =
269
261
let rec loop = function
270
- | (Asttypes. Labelled " children" , {Parsetree. pexp_loc = {loc_start}})
271
- :: _ ->
272
- Pos. ofLexing loc_start
262
+ | (Asttypes. Labelled "children" , {Parsetree. pexp_loc} ) :: _ ->
263
+ Loc. start pexp_loc
273
264
| _ :: args -> loop args
274
265
| [] -> (* should not happen *) (- 1 , - 1 )
275
266
in
276
267
277
268
loop args
278
269
in
279
270
let posOfFinalGreatherthan =
280
- let pos = Pos. ofLexing e.pexp_loc.loc_end in
271
+ let pos = Loc. end_ e.pexp_loc in
281
272
(fst pos, snd pos - 1 )
282
273
in
283
274
let selfClosing =
@@ -286,10 +277,10 @@ let command ~debug ~emitter ~path =
286
277
(* there's an off-by one somehow in the AST *)
287
278
in
288
279
(if not selfClosing then
289
- let lineStart, colStart = Pos. ofLexing pexp_loc.loc_start in
290
- let lineEnd, colEnd = Pos. ofLexing pexp_loc.loc_end in
280
+ let lineStart, colStart = Loc. start pexp_loc in
281
+ let lineEnd, colEnd = Loc. end_ pexp_loc in
291
282
let length = if lineStart = lineEnd then colEnd - colStart else 0 in
292
- let lineEndWhole, colEndWhole = Pos. ofLexing e.pexp_loc.loc_end in
283
+ let lineEndWhole, colEndWhole = Loc. end_ e.pexp_loc in
293
284
if length > 0 && colEndWhole > length then (
294
285
emitter
295
286
|> emitJsxClose ~debug ~lid: lident.txt
@@ -329,23 +320,23 @@ let command ~debug ~emitter ~path =
329
320
(me : Parsetree.module_expr ) =
330
321
match me.pmod_desc with
331
322
| Pmod_ident {txt = lid ; loc} ->
332
- emitter |> emitLongident ~pos: (Pos. ofLexing loc.loc_start ) ~lid ~debug ;
323
+ emitter |> emitLongident ~pos: (Loc. start loc) ~lid ~debug ;
333
324
Ast_iterator. default_iterator.module_expr iterator me
334
325
| _ -> Ast_iterator. default_iterator.module_expr iterator me
335
326
in
336
327
let module_binding (iterator : Ast_iterator.iterator )
337
328
(mb : Parsetree.module_binding ) =
338
329
emitter
339
330
|> emitLongident
340
- ~pos: (Pos. ofLexing mb.pmb_name.loc.loc_start )
331
+ ~pos: (Loc. start mb.pmb_name.loc)
341
332
~lid: (Longident. Lident mb.pmb_name.txt) ~debug ;
342
333
Ast_iterator. default_iterator.module_binding iterator mb
343
334
in
344
335
let module_declaration (iterator : Ast_iterator.iterator )
345
336
(md : Parsetree.module_declaration ) =
346
337
emitter
347
338
|> emitLongident
348
- ~pos: (Pos. ofLexing md.pmd_name.loc.loc_start )
339
+ ~pos: (Loc. start md.pmd_name.loc)
349
340
~lid: (Longident. Lident md.pmd_name.txt) ~debug ;
350
341
Ast_iterator. default_iterator.module_declaration iterator md
351
342
in
@@ -354,25 +345,24 @@ let command ~debug ~emitter ~path =
354
345
match mt.pmty_desc with
355
346
| Pmty_ident {txt = lid ; loc} ->
356
347
emitter
357
- |> emitLongident ~upper CaseToken:Token. Type
358
- ~pos: (Pos. ofLexing loc.loc_start)
359
- ~lid ~debug ;
348
+ |> emitLongident ~upper CaseToken:Token. Type ~pos: (Loc. start loc) ~lid
349
+ ~debug ;
360
350
Ast_iterator. default_iterator.module_type iterator mt
361
351
| _ -> Ast_iterator. default_iterator.module_type iterator mt
362
352
in
363
353
let module_type_declaration (iterator : Ast_iterator.iterator )
364
354
(mtd : Parsetree.module_type_declaration ) =
365
355
emitter
366
356
|> emitLongident ~upper CaseToken:Token. Type
367
- ~pos: (Pos. ofLexing mtd.pmtd_name.loc.loc_start )
357
+ ~pos: (Loc. start mtd.pmtd_name.loc)
368
358
~lid: (Longident. Lident mtd.pmtd_name.txt) ~debug ;
369
359
Ast_iterator. default_iterator.module_type_declaration iterator mtd
370
360
in
371
361
let open_description (iterator : Ast_iterator.iterator )
372
362
(od : Parsetree.open_description ) =
373
363
emitter
374
364
|> emitLongident
375
- ~pos: (Pos. ofLexing od.popen_lid.loc.loc_start )
365
+ ~pos: (Loc. start od.popen_lid.loc)
376
366
~lid: od.popen_lid.txt ~debug ;
377
367
Ast_iterator. default_iterator.open_description iterator od
378
368
in
0 commit comments