Skip to content

Commit b4386bc

Browse files
cristianocclaude
andauthored
Reformat for OCamlFormat 0.29
Formatting-only: the rebase onto master (which upgraded OCamlFormat from 0.27 to 0.29 in #8591) left the files this branch touches formatted with the old version. Signed-Off-By: Cristiano Calcagno <ccrisccris@gmail.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PCtQiaDijUqA2fujQXvKUw
1 parent 520f91a commit b4386bc

2 files changed

Lines changed: 76 additions & 82 deletions

File tree

analysis/src/semantic_tokens.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@ let command ~debug ~emitter ~source ~kind_file =
361361
| Pexp_object_literal fields ->
362362
fields
363363
|> List.iter (fun ((s : string Asttypes.loc), _) ->
364-
if not (Utils.is_first_char_uppercase s.txt) then
365-
emitter
366-
|> emit_record_label
367-
~label:{Asttypes.txt = Longident.Lident s.txt; loc = s.loc}
368-
~debug);
364+
if not (Utils.is_first_char_uppercase s.txt) then
365+
emitter
366+
|> emit_record_label
367+
~label:{Asttypes.txt = Longident.Lident s.txt; loc = s.loc}
368+
~debug);
369369
Ast_iterator.default_iterator.expr iterator e
370370
| Pexp_record (cases, _) ->
371371
Ext_list.filter_map cases (fun {lid} ->

compiler/gentype/translate_type_expr_from_types.ml

Lines changed: 71 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ let translate_obj_type closed_flag fields_translations =
3030
let fields =
3131
fields_translations
3232
|> List.map (fun (name, mutable_, {type_ = t}) ->
33-
let optional, type_ =
34-
match t with
35-
| Option t -> (Optional, t)
36-
| _ -> (Mandatory, t)
37-
in
38-
{
39-
mutable_;
40-
name_js = name;
41-
optional;
42-
type_;
43-
doc_string = Doc_string.empty;
44-
})
33+
let optional, type_ =
34+
match t with
35+
| Option t -> (Optional, t)
36+
| _ -> (Mandatory, t)
37+
in
38+
{
39+
mutable_;
40+
name_js = name;
41+
optional;
42+
type_;
43+
doc_string = Doc_string.empty;
44+
})
4545
in
4646
let type_ = Object (closed_flag, fields) in
4747
{dependencies; type_}
@@ -551,11 +551,10 @@ and translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
551551
let no_payloads =
552552
no_payloads
553553
|> List.map (fun label ->
554-
{
555-
label_js =
556-
(if is_number label then IntLabel label
557-
else StringLabel label);
558-
})
554+
{
555+
label_js =
556+
(if is_number label then IntLabel label else StringLabel label);
557+
})
559558
in
560559
let type_ =
561560
create_variant ~inherits:[] ~no_payloads ~payloads:[] ~polymorphic:true
@@ -572,15 +571,14 @@ and translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
572571
let payload_translations =
573572
payloads
574573
|> List.map (fun (label, payload) ->
575-
( label,
576-
payload
577-
|> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
578-
))
574+
( label,
575+
payload
576+
|> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env ))
579577
in
580578
let payloads =
581579
payload_translations
582580
|> List.map (fun (label, translation) ->
583-
{case = {label_js = StringLabel label}; t = translation.type_})
581+
{case = {label_js = StringLabel label}; t = translation.type_})
584582
in
585583
let type_ =
586584
create_variant ~inherits:[] ~no_payloads ~payloads ~polymorphic:true
@@ -599,10 +597,9 @@ and translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
599597
let type_equations_translation =
600598
(List.combine ids types [@doesNotRaise])
601599
|> List.map (fun (x, t) ->
602-
( x,
603-
t
604-
|> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
605-
))
600+
( x,
601+
t |> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
602+
))
606603
in
607604
let type_equations =
608605
type_equations_translation
@@ -638,53 +635,50 @@ and signature_to_module_runtime_representation ~config ~type_vars_gen ~type_env
638635
let dependencies_and_fields =
639636
signature
640637
|> List.map (fun signature_item ->
641-
match signature_item with
642-
| Types.Sig_value (_id, {val_kind = Val_prim _}) -> ([], [])
643-
| Types.Sig_value (id, {val_type = type_expr; val_attributes}) ->
644-
let {dependencies; type_} =
645-
type_expr
646-
|> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
647-
in
648-
let field =
649-
{
650-
mutable_ = Immutable;
651-
name_js = id |> Ident.name;
652-
optional = Mandatory;
653-
type_;
654-
doc_string = Annotation.doc_string_from_attrs val_attributes;
655-
}
656-
in
657-
(dependencies, [field])
658-
| Types.Sig_module (id, module_declaration, _recStatus) ->
659-
let type_env1 =
660-
match
661-
type_env |> Type_env.get_module ~name:(id |> Ident.name)
662-
with
663-
| Some type_env1 -> type_env1
664-
| None -> type_env
665-
in
666-
let dependencies, type_ =
667-
match module_declaration.md_type with
668-
| Mty_signature signature ->
669-
signature
670-
|> signature_to_module_runtime_representation ~config
671-
~type_vars_gen ~type_env:type_env1
672-
| Mty_ident _ | Mty_functor _ | Mty_alias _ -> ([], unknown)
673-
in
674-
let field =
675-
{
676-
mutable_ = Immutable;
677-
name_js = id |> Ident.name;
678-
optional = Mandatory;
679-
type_;
680-
doc_string =
681-
Annotation.doc_string_from_attrs
682-
module_declaration.md_attributes;
683-
}
684-
in
685-
(dependencies, [field])
686-
| Types.Sig_type _ | Types.Sig_typext _ | Types.Sig_modtype _ ->
687-
([], []))
638+
match signature_item with
639+
| Types.Sig_value (_id, {val_kind = Val_prim _}) -> ([], [])
640+
| Types.Sig_value (id, {val_type = type_expr; val_attributes}) ->
641+
let {dependencies; type_} =
642+
type_expr
643+
|> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env
644+
in
645+
let field =
646+
{
647+
mutable_ = Immutable;
648+
name_js = id |> Ident.name;
649+
optional = Mandatory;
650+
type_;
651+
doc_string = Annotation.doc_string_from_attrs val_attributes;
652+
}
653+
in
654+
(dependencies, [field])
655+
| Types.Sig_module (id, module_declaration, _recStatus) ->
656+
let type_env1 =
657+
match type_env |> Type_env.get_module ~name:(id |> Ident.name) with
658+
| Some type_env1 -> type_env1
659+
| None -> type_env
660+
in
661+
let dependencies, type_ =
662+
match module_declaration.md_type with
663+
| Mty_signature signature ->
664+
signature
665+
|> signature_to_module_runtime_representation ~config
666+
~type_vars_gen ~type_env:type_env1
667+
| Mty_ident _ | Mty_functor _ | Mty_alias _ -> ([], unknown)
668+
in
669+
let field =
670+
{
671+
mutable_ = Immutable;
672+
name_js = id |> Ident.name;
673+
optional = Mandatory;
674+
type_;
675+
doc_string =
676+
Annotation.doc_string_from_attrs
677+
module_declaration.md_attributes;
678+
}
679+
in
680+
(dependencies, [field])
681+
| Types.Sig_type _ | Types.Sig_typext _ | Types.Sig_modtype _ -> ([], []))
688682
in
689683
let dependencies, fields =
690684
let dl, fl = dependencies_and_fields |> List.split in
@@ -700,7 +694,7 @@ let translate_type_expr_from_types ~config ~type_env type_expr =
700694
if !Debug.dependencies then
701695
translation.dependencies
702696
|> List.iter (fun dep ->
703-
Log_.item "Dependency: %s\n" (dep |> dep_to_string));
697+
Log_.item "Dependency: %s\n" (dep |> dep_to_string));
704698
translation
705699

706700
let translate_type_exprs_from_types ~config ~type_env type_exprs =
@@ -711,7 +705,7 @@ let translate_type_exprs_from_types ~config ~type_env type_exprs =
711705
if !Debug.dependencies then
712706
translations
713707
|> List.iter (fun translation ->
714-
translation.dependencies
715-
|> List.iter (fun dep ->
716-
Log_.item "Dependency: %s\n" (dep |> dep_to_string)));
708+
translation.dependencies
709+
|> List.iter (fun dep ->
710+
Log_.item "Dependency: %s\n" (dep |> dep_to_string)));
717711
translations

0 commit comments

Comments
 (0)