[kotlin] add flag controlling Kotlin capture

Summary: Flag defaults to false. (For now, only the buck integration supports capturing any Kotlin.)

Reviewed By: jvillard

Differential Revision: D29388274

fbshipit-source-id: 8dbec9555
master
Nikos Gorogiannis 4 years ago committed by Facebook GitHub Bot
parent 6b67a57029
commit c7e0f092a1

@ -310,6 +310,10 @@ JAVA OPTIONS
The version of Java being used. Set it to your Java version if mvn
is failing.
--kotlin-capture
Activates: Enable Kotlin capture (experimental, do not use).
(Conversely: --no-kotlin-capture)
--no-mask-sawja-exceptions
Deactivates: Mask exceptions thrown by Sawja/Javalib during Java
capture (Conversely: --mask-sawja-exceptions)

@ -792,6 +792,10 @@ OPTIONS
Activates: Keep going when the analysis encounters a failure
(Conversely: --no-keep-going) See also infer-analyze(1).
--kotlin-capture
Activates: Enable Kotlin capture (experimental, do not use).
(Conversely: --no-kotlin-capture) See also infer-capture(1).
--linter string
From the linters available, only run this one linter. (Useful
together with --linters-developer-mode) See also infer-capture(1).

@ -792,6 +792,10 @@ OPTIONS
Activates: Keep going when the analysis encounters a failure
(Conversely: --no-keep-going) See also infer-analyze(1).
--kotlin-capture
Activates: Enable Kotlin capture (experimental, do not use).
(Conversely: --no-kotlin-capture) See also infer-capture(1).
--linter string
From the linters available, only run this one linter. (Useful
together with --linters-developer-mode) See also infer-capture(1).

@ -1635,6 +1635,12 @@ and jobs =
~meta:"int" "Run the specified number of analysis jobs simultaneously"
and kotlin_capture =
CLOpt.mk_bool ~long:"kotlin-capture" ~default:false
~in_help:InferCommand.[(Capture, manual_java)]
"Enable Kotlin capture (experimental, do not use)."
and liveness_dangerous_classes =
CLOpt.mk_json ~long:"liveness-dangerous-classes"
~in_help:InferCommand.[(Analyze, manual_clang)]
@ -3171,6 +3177,8 @@ and job_id = !job_id
and jobs = Option.fold !max_jobs ~init:!jobs ~f:min
and kotlin_capture = !kotlin_capture
and linter = !linter
and linters_def_file = RevList.to_list !linters_def_file

@ -385,6 +385,8 @@ val jobs : int
val keep_going : bool
val kotlin_capture : bool
val linter : string option
val linters_def_file : string list

@ -170,7 +170,15 @@ let to_string ?(force_relative = false) fname =
else path
let has_extension t ~ext = String.is_suffix (to_string t) ~suffix:ext
let has_extension ~ext = function
| Invalid _ ->
false
| RelativeProjectRootAndWorkspace {rel_path= path}
| HashedBuckOut path
| RelativeProjectRoot path
| Absolute path ->
String.is_suffix path ~suffix:ext
let pp fmt fname = Format.pp_print_string fmt (to_string fname)

@ -60,7 +60,7 @@ val to_string : ?force_relative:bool -> t -> string
(** convert a source file to a string WARNING: result may not be valid file path, do not use this
function to perform operations on filenames *)
val has_extension : t -> ext:string -> bool
val has_extension : ext:string -> t -> bool
(** returns whether the source file has provided extension *)
module SQLite : SqliteUtils.Data with type t = t

@ -178,7 +178,12 @@ let search_sources () =
initial_map
| Some sourcepath ->
Utils.directory_fold
(fun map p -> if Filename.check_suffix p "java" then add_source_file p map else map)
(fun map p ->
if
Filename.check_suffix p "java"
|| (Config.kotlin_capture && Filename.check_suffix p Config.kotlin_source_extension)
then add_source_file p map
else map )
initial_map sourcepath

@ -88,8 +88,10 @@ let add_edges (context : JContext.t) start_node exn_node exit_nodes method_body_
(** Add a concrete method. *)
let add_cmethod source_file program icfg cm proc_name =
let cn, _ = JBasics.cms_split cm.Javalib.cm_class_method_signature in
if SourceFile.has_extension source_file ~ext:Config.kotlin_source_extension then
ignore (JTrans.create_empty_procdesc source_file program icfg cm proc_name)
if
(not Config.kotlin_capture)
&& SourceFile.has_extension source_file ~ext:Config.kotlin_source_extension
then ignore (JTrans.create_empty_procdesc source_file program icfg cm proc_name)
else
match JTrans.create_cm_procdesc source_file program icfg cm proc_name with
| None ->

Loading…
Cancel
Save