[nullsafe] get rid of Ondemand dependency

Summary: On our way to making nullsafe its own dune library.

Reviewed By: dulmarod

Differential Revision: D21351455

fbshipit-source-id: 0d621d71d
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 895811cc97
commit d369eba15e

@ -8,9 +8,10 @@
open! IStd
module ClassInfo = struct
type t = {summaries: Summary.t list; nested_anonymous_classes: anonymous_class_to_summaries}
type t =
{summaries: NullsafeSummary.t list; nested_anonymous_classes: anonymous_class_to_summaries}
and anonymous_class_to_summaries = Summary.t list JavaClassName.Map.t
and anonymous_class_to_summaries = NullsafeSummary.t list JavaClassName.Map.t
let make_empty () = {summaries= []; nested_anonymous_classes= JavaClassName.Map.empty}

@ -14,7 +14,7 @@ open! IStd
module ClassInfo : sig
type t
val get_all_summaries : t -> Summary.t list
val get_all_summaries : t -> NullsafeSummary.t list
(** List of all summaries, user-level and anonymous, combined together *)
end
@ -22,7 +22,7 @@ type t
val make_empty : unit -> t
val register_summary : JavaClassName.t -> Summary.t -> t -> t
val register_summary : JavaClassName.t -> NullsafeSummary.t -> t -> t
(** Add information about summary to the class map. Depending on if this an anonymous or
user-defined class, adds it to corresponding lists. *)

@ -177,11 +177,7 @@ let report_meta_issues tenv source_file class_name class_struct class_info issue
let current_mode = NullsafeMode.of_class tenv class_name in
let summaries = AggregatedSummaries.ClassInfo.get_all_summaries class_info in
let class_loc = get_class_loc source_file class_struct in
let all_issues =
List.map summaries ~f:(fun Summary.{payloads= {nullsafe}} ->
Option.value_map nullsafe ~f:(fun NullsafeSummary.{issues} -> issues) ~default:[] )
|> List.fold ~init:[] ~f:( @ )
in
let all_issues = List.concat_map summaries ~f:(fun {NullsafeSummary.issues} -> issues) in
let {issue_type; description; severity; meta_issue_info} =
make_meta_issue all_issues current_mode class_name
in

@ -16,12 +16,12 @@ let get_java_class_name = function
(* aggregate all of the procedures in the file env by their declaring
class. this lets us analyze each class individually *)
let aggregate_by_class procedures =
let aggregate_by_class {InterproceduralAnalysis.procedures; analyze_file_dependency; _} =
let open IOption.Let_syntax in
List.fold procedures ~init:(AggregatedSummaries.make_empty ()) ~f:(fun map_to_update procname ->
(let* class_name = Procname.get_class_type_name procname in
let* java_class_name = get_java_class_name class_name in
let* summary = Ondemand.analyze_proc_name_no_caller procname in
let* _proc_desc, summary = analyze_file_dependency procname in
return (AggregatedSummaries.register_summary java_class_name summary map_to_update))
|> Option.value ~default:map_to_update )
@ -38,8 +38,8 @@ let analyze_class tenv source_file issue_log (class_name, class_info) =
else ClassLevelAnalysis.analyze_class tenv source_file class_name class_info issue_log
let analyze_file {InterproceduralAnalysis.procedures; file_exe_env; source_file} =
let class_map = aggregate_by_class procedures in
let analyze_file ({InterproceduralAnalysis.file_exe_env; source_file} as analysis_data) =
let class_map = aggregate_by_class analysis_data in
let tenv = Exe_env.load_java_global_tenv file_exe_env in
let user_class_info = AggregatedSummaries.group_by_user_class class_map in
List.fold user_class_info ~init:IssueLog.empty ~f:(analyze_class tenv source_file)

Loading…
Cancel
Save