123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131openPpxlibtypeattributesPartition={arityAttrs:attributes;docAttrs:attributes;stdAttrs:attributes;jsxAttrs:attributes;stylisticAttrs:attributes;uncurried:bool}(** Kinds of attributes *)(** Partition attributes into kinds *)letrecpartitionAttributes?(partDoc=false)?(allowUncurry=true)attrs:attributesPartition=matchattrswith|[]->{arityAttrs=[];docAttrs=[];stdAttrs=[];jsxAttrs=[];stylisticAttrs=[];uncurried=false}|({attr_name={txt="u"|"bs";_};attr_payload=PStr[];_}asattr)::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlinifallowUncurrythen{partitionwithuncurried=true}else{partitionwithstdAttrs=attr::partition.stdAttrs}|({attr_name={txt="JSX";_};_}asjsx)::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithjsxAttrs=jsx::partition.jsxAttrs}|({attr_name={txt="explicit_arity";_};_}asarity_attr)::atTl|({attr_name={txt="implicit_arity";_};_}asarity_attr)::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwitharityAttrs=arity_attr::partition.arityAttrs}|({attr_name={txt="ocaml.text";_};_}asdoc)::atTlwhenpartDoc=true->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithdocAttrs=doc::partition.docAttrs}|({attr_name={txt="ocaml.doc"|"ocaml.text";_};_}asdoc)::atTlwhenpartDoc=true->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithdocAttrs=doc::partition.docAttrs}|({attr_name={txt="reason.raw_literal";_};_}asattr)::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithstylisticAttrs=attr::partition.stylisticAttrs}|({attr_name={txt="reason.preserve_braces";_};_}asattr)::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithstylisticAttrs=attr::partition.stylisticAttrs}|({attr_name={txt="reason.openSyntaxNotation";_};_}asattr)::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithstylisticAttrs=attr::partition.stylisticAttrs}|({attr_name={txt="reason.quoted_extension";_};_}asattr)::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithstylisticAttrs=attr::partition.stylisticAttrs}|atHd::atTl->letpartition=partitionAttributes~partDoc~allowUncurryatTlin{partitionwithstdAttrs=atHd::partition.stdAttrs}letextractStdAttrsattrs=(partitionAttributesattrs).stdAttrsletextract_raw_literalattrs=letrecloopacc=function|{attr_name={txt="reason.raw_literal";_};attr_payload=PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant(Pconst_string(text,_,None));_},_);_}];_}::rest->Sometext,List.rev_appendaccrest|[]->None,List.revacc|attr::rest->loop(attr::acc)restinloop[]attrsletwithout_stylistic_attrsattrs=letrecloopacc=function|attr::restwhen(partitionAttributes[attr]).stylisticAttrs!=[]->loopaccrest|[]->List.revacc|attr::rest->loop(attr::acc)restinloop[]attrs(* TODO: Make this fast and not filter *)lethas_jsx_attributes=letis_jsx_attribute{attr_name={txt;_};_}=txt="JSX"infunattrs->List.existsis_jsx_attributeattrslethas_preserve_braces_attrs=letis_preserve_braces_attr{attr_name={txt;_};_}=txt="reason.preserve_braces"infunstylisticAttrs->List.existsis_preserve_braces_attrstylisticAttrslethas_quoted_extension_attrs=letis_quoted_extension_attr{attr_name={txt;_};_}=txt="reason.quoted_extension"infunstylisticAttrs->List.existsis_quoted_extension_attrstylisticAttrsletmaybe_remove_stylistic_attrsattrs~should_preserve=ifshould_preservethenattrselseList.filter(function|{attr_name={txt="reason.raw_literal";_};_}->true|_->false)attrslethas_open_notation_attr=letis_open_notation_attr{attr_name={txt;_};_}=txt="reason.openSyntaxNotation"infunstylisticAttrs->List.existsis_open_notation_attrstylisticAttrs