Exposing java_typ_to_string

Reviewed By: jeremydubreil

Differential Revision: D2879758

fb-gh-sync-id: 87152f0
master
Sam Blackshear 9 years ago committed by facebook-github-bot-1
parent 14e934205f
commit be86e5d15d

@ -91,26 +91,30 @@ let method_kind_compare k0 k1 =
| Non_Static, _ -> -1 | Non_Static, _ -> -1
(** A type is a pair (package, type_name) that is translated in a string package.type_name *) (** A type is a pair (package, type_name) that is translated in a string package.type_name *)
let java_type_to_string p verbosity = let java_type_to_string_verbosity p verbosity =
match p with match p with
| (None, typ) -> typ | (None, typ) -> typ
| (Some p, cls) -> | (Some p, cls) ->
if is_verbose verbosity then p ^ "." ^ cls if is_verbose verbosity then p ^ "." ^ cls
else cls else cls
let java_type_to_string p =
java_type_to_string_verbosity p Verbose
(** Given a list of types, it creates a unique string of types separated by commas *) (** Given a list of types, it creates a unique string of types separated by commas *)
let rec java_param_list_to_string inputList verbosity = let rec java_param_list_to_string inputList verbosity =
match inputList with match inputList with
| [] -> "" | [] -> ""
| [head] -> java_type_to_string head verbosity | [head] -> java_type_to_string_verbosity head verbosity
| head :: rest -> (java_type_to_string head verbosity) ^ "," ^ (java_param_list_to_string rest verbosity) | head :: rest ->
(java_type_to_string_verbosity head verbosity) ^ "," ^ (java_param_list_to_string rest verbosity)
(** It is the same as java_type_to_string, but Java return types are optional because of constructors without type *) (** It is the same as java_type_to_string, but Java return types are optional because of constructors without type *)
let java_return_type_to_string j verbosity = let java_return_type_to_string j verbosity =
match j.return_type with match j.return_type with
| None -> "" | None -> ""
| Some typ -> | Some typ ->
java_type_to_string typ verbosity java_type_to_string_verbosity typ verbosity
let java_type_compare (p1, c1) (p2, c2) = let java_type_compare (p1, c1) (p2, c2) =
string_compare c1 c2 |> next mangled_compare p1 p2 string_compare c1 c2 |> next mangled_compare p1 p2
@ -211,7 +215,7 @@ let c_get_class t =
(** Return the package.classname of a java procname. *) (** Return the package.classname of a java procname. *)
let java_get_class = function let java_get_class = function
| Java_method j -> java_type_to_string j.class_name Verbose | Java_method j -> java_type_to_string j.class_name
| _ -> assert false | _ -> assert false
(** Return path components of a java class name *) (** Return path components of a java class name *)
@ -267,7 +271,8 @@ let java_get_parameters = function
(** Return the parameters of a java procname as strings. *) (** Return the parameters of a java procname as strings. *)
let java_get_parameters_as_strings = function let java_get_parameters_as_strings = function
| Java_method j -> IList.map (fun param -> java_type_to_string param Verbose) j.parameters | Java_method j ->
IList.map (fun param -> java_type_to_string param) j.parameters
| _ -> assert false | _ -> assert false
(** Return true if the java procedure is static *) (** Return true if the java procedure is static *)
@ -284,7 +289,7 @@ let java_to_string ?(withclass = false) j verbosity =
verbose is used for example to create unique filenames, non_verbose to create reports *) verbose is used for example to create unique filenames, non_verbose to create reports *)
let return_type = java_return_type_to_string j verbosity in let return_type = java_return_type_to_string j verbosity in
let params = java_param_list_to_string j.parameters verbosity in let params = java_param_list_to_string j.parameters verbosity in
let class_name = java_type_to_string j.class_name verbosity in let class_name = java_type_to_string_verbosity j.class_name verbosity in
let separator = let separator =
match j.return_type, verbosity with match j.return_type, verbosity with
| (None, _) -> "" | (None, _) -> ""
@ -296,7 +301,7 @@ let java_to_string ?(withclass = false) j verbosity =
| Simple -> (* methodname(...) or without ... if there are no parameters *) | Simple -> (* methodname(...) or without ... if there are no parameters *)
let cls_prefix = let cls_prefix =
if withclass then if withclass then
java_type_to_string j.class_name verbosity ^ "." java_type_to_string_verbosity j.class_name verbosity ^ "."
else "" in else "" in
let params = let params =
match j.parameters with match j.parameters with

@ -156,6 +156,8 @@ val to_simplified_string : ?withclass: bool -> t -> string
(** Convert a proc name into a unique identifier *) (** Convert a proc name into a unique identifier *)
val to_unique_id : t -> string val to_unique_id : t -> string
val java_type_to_string : java_type -> string
(** Convert a proc name to a filename *) (** Convert a proc name to a filename *)
val to_filename : t -> string val to_filename : t -> string

Loading…
Cancel
Save