[componentkit] Break out common CK context check

Reviewed By: dulmarod

Differential Revision: D3934325

fbshipit-source-id: 0dd6b4b
master
Ryan Rhee 8 years ago committed by Facebook Github Bot
parent a1f65716b8
commit 8f731569fc

@ -10,6 +10,11 @@
open CFrontend_utils open CFrontend_utils
open !Utils open !Utils
let is_ck_context context decl =
context.CLintersContext.is_ck_translation_unit
&& Ast_utils.is_in_main_file decl
&& General_utils.is_objc_extension
(** Recursively go up the inheritance hierarchy of a given ObjCInterfaceDecl. (** Recursively go up the inheritance hierarchy of a given ObjCInterfaceDecl.
(Returns false on decls other than that one.) *) (Returns false on decls other than that one.) *)
let is_component_or_controller_if decl = let is_component_or_controller_if decl =
@ -86,9 +91,7 @@ let mutable_local_vars_advice context decl =
qt_is_const qt_is_const
| _ -> false in | _ -> false in
let is_const = qual_type.qt_is_const || is_const_ref in let is_const = qual_type.qt_is_const || is_const_ref in
let condition = context.CLintersContext.is_ck_translation_unit let condition = is_ck_context context decl
&& Ast_utils.is_in_main_file decl
&& General_utils.is_objc_extension
&& (not (Ast_utils.is_syntactically_global_var decl)) && (not (Ast_utils.is_syntactically_global_var decl))
&& (not is_const) && (not is_const)
&& not (is_of_whitelisted_type qual_type) in && not (is_of_whitelisted_type qual_type) in
@ -125,9 +128,7 @@ let component_factory_function_advice context decl =
match decl with match decl with
| Clang_ast_t.FunctionDecl (decl_info, _, (qual_type: Clang_ast_t.qual_type), _) -> | Clang_ast_t.FunctionDecl (decl_info, _, (qual_type: Clang_ast_t.qual_type), _) ->
let condition = context.CLintersContext.is_ck_translation_unit let condition = is_ck_context context decl
&& Ast_utils.is_in_main_file decl
&& General_utils.is_objc_extension
&& is_component_if (type_ptr_to_objc_if qual_type.qt_type_ptr) in && is_component_if (type_ptr_to_objc_if qual_type.qt_type_ptr) in
if condition then if condition then
Some { Some {

Loading…
Cancel
Save