Skip to content

Commit

Permalink
compat: provide stable utilities for pattern var access
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Feb 22, 2024
1 parent b77b724 commit be795d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/analysis/misc_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ let parenthesize_name name =
else
"(" ^ name ^ ")"
)

module Compat = struct
open Typedtree
let pat_var_id_and_loc = function
| { pat_desc = Tpat_var (id, loc); _ } -> Some (id, loc)
| _ -> None

let pat_alias_pat_id_and_loc = function
| { pat_desc = Tpat_alias (pat, id, loc); _ } -> Some (pat, id, loc)
| _ -> None
end
9 changes: 9 additions & 0 deletions src/analysis/misc_utils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ end

(* Add parenthesis to qualified operators *)
val parenthesize_name : string -> string

module Compat : sig
val pat_var_id_and_loc :
Typedtree.pattern -> (Ident.t * string Location.loc) option

val pat_alias_pat_id_and_loc
: Typedtree.pattern
-> (Typedtree.pattern * Ident.t * string Location.loc) option
end

0 comments on commit be795d0

Please sign in to comment.