diff --git a/src/analyzer/algebra_analyzer.rs b/src/analyzer/algebra_analyzer.rs index c82f4d7a..12fbcbcb 100644 --- a/src/analyzer/algebra_analyzer.rs +++ b/src/analyzer/algebra_analyzer.rs @@ -65,7 +65,7 @@ pub(crate) fn check_for_paradox( ), statements_analyzer.get_config(), &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path_actual, ); diff --git a/src/analyzer/classlike_analyzer.rs b/src/analyzer/classlike_analyzer.rs index 14a0faae..8afcc719 100644 --- a/src/analyzer/classlike_analyzer.rs +++ b/src/analyzer/classlike_analyzer.rs @@ -84,7 +84,7 @@ impl<'a> ClassLikeAnalyzer<'a> { let mut analysis_data = FunctionAnalysisData::new( DataFlowGraph::new(statements_analyzer.get_config().graph_kind), - statements_analyzer.get_file_analyzer().get_file_source(), + statements_analyzer.file_analyzer.get_file_source(), &statements_analyzer.comments, &statements_analyzer.get_config().all_custom_issues, None, diff --git a/src/analyzer/dataflow/unused_variable_analyzer.rs b/src/analyzer/dataflow/unused_variable_analyzer.rs index 091762e6..b9f71c73 100644 --- a/src/analyzer/dataflow/unused_variable_analyzer.rs +++ b/src/analyzer/dataflow/unused_variable_analyzer.rs @@ -19,7 +19,6 @@ use std::rc::Rc; use crate::dataflow::program_analyzer::{should_ignore_array_fetch, should_ignore_property_fetch}; use crate::function_analysis_data::FunctionAnalysisData; -use crate::scope_analyzer::ScopeAnalyzer; use crate::statements_analyzer::StatementsAnalyzer; use hakana_code_info::data_flow::graph::DataFlowGraph; use hakana_code_info::data_flow::node::DataFlowNode; @@ -386,7 +385,7 @@ pub(crate) fn add_unused_expression_replacements( let mut scanner = Scanner { unused_variable_nodes: unused_source_nodes, comments: statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .comments, in_single_block: false, diff --git a/src/analyzer/def_analyzer.rs b/src/analyzer/def_analyzer.rs index d900b248..e47f284e 100644 --- a/src/analyzer/def_analyzer.rs +++ b/src/analyzer/def_analyzer.rs @@ -28,7 +28,7 @@ pub(crate) fn analyze( hook.can_codegen_def( statements_analyzer.interner, statements_analyzer.codebase, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, def, ) }) @@ -73,7 +73,7 @@ pub(crate) fn analyze( let mut function_context = FunctionContext::new(); function_context.calling_class = Some( if let Some(resolved_name) = statements_analyzer - .get_file_analyzer() + .file_analyzer .resolved_names .get(&(boxed.name.pos().start_offset() as u32)) { diff --git a/src/analyzer/expr/as_analyzer.rs b/src/analyzer/expr/as_analyzer.rs index 2d143290..067c7530 100644 --- a/src/analyzer/expr/as_analyzer.rs +++ b/src/analyzer/expr/as_analyzer.rs @@ -1,7 +1,6 @@ use std::rc::Rc; use crate::scope::BlockContext; -use crate::scope_analyzer::ScopeAnalyzer; use crate::statements_analyzer::StatementsAnalyzer; use crate::stmt_analyzer::AnalysisError; @@ -139,7 +138,7 @@ pub(crate) fn analyze<'expr>( &hint.1, context.function_context.calling_class.as_ref(), statements_analyzer.get_type_resolution_context(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, *statements_analyzer.get_file_path(), hint.0.start_offset() as u32, ) diff --git a/src/analyzer/expr/assignment/array_assignment_analyzer.rs b/src/analyzer/expr/assignment/array_assignment_analyzer.rs index 11899f52..caad17f7 100644 --- a/src/analyzer/expr/assignment/array_assignment_analyzer.rs +++ b/src/analyzer/expr/assignment/array_assignment_analyzer.rs @@ -21,12 +21,12 @@ use oxidized::{ ast_defs::Pos, }; +use crate::expression_analyzer; use crate::{ expr::{expression_identifier, fetch::array_fetch_analyzer}, function_analysis_data::FunctionAnalysisData, stmt_analyzer::AnalysisError, }; -use crate::{expression_analyzer, scope_analyzer::ScopeAnalyzer}; use crate::{scope::BlockContext, statements_analyzer::StatementsAnalyzer}; use super::instance_property_assignment_analyzer; @@ -70,11 +70,8 @@ pub(crate) fn analyze( let root_var_id = expression_identifier::get_var_id( root_array_expr, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, - Some(( - statements_analyzer.codebase, - statements_analyzer.interner, - )), + statements_analyzer.file_analyzer.resolved_names, + Some((statements_analyzer.codebase, statements_analyzer.interner)), ); let current_dim = analyze_nested_array_assignment( @@ -693,21 +690,15 @@ pub(crate) fn analyze_nested_array_assignment<'a>( var_id_additions.push( if let Some(dim_id) = expression_identifier::get_dim_id( dim, - Some(( - statements_analyzer.codebase, - statements_analyzer.interner, - )), - statements_analyzer.get_file_analyzer().resolved_names, + Some((statements_analyzer.codebase, statements_analyzer.interner)), + statements_analyzer.file_analyzer.resolved_names, ) { format!("[{}]", dim_id) } else if let Some(dim_id) = expression_identifier::get_var_id( dim, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, - Some(( - statements_analyzer.codebase, - statements_analyzer.interner, - )), + statements_analyzer.file_analyzer.resolved_names, + Some((statements_analyzer.codebase, statements_analyzer.interner)), ) { format!("[{}]", dim_id) } else { @@ -784,11 +775,8 @@ pub(crate) fn analyze_nested_array_assignment<'a>( expression_identifier::get_var_id( array_expr.0, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, - Some(( - statements_analyzer.codebase, - statements_analyzer.interner, - )), + statements_analyzer.file_analyzer.resolved_names, + Some((statements_analyzer.codebase, statements_analyzer.interner)), ), &array_expr_offset_atomic_types, context.inside_general_use @@ -875,11 +863,8 @@ pub(crate) fn analyze_nested_array_assignment<'a>( let array_expr_id = if let Some(var_var_id) = expression_identifier::get_var_id( array_expr.0, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, - Some(( - statements_analyzer.codebase, - statements_analyzer.interner, - )), + statements_analyzer.file_analyzer.resolved_names, + Some((statements_analyzer.codebase, statements_analyzer.interner)), ) { parent_array_var_id = Some(var_var_id.clone()); Some(format!( diff --git a/src/analyzer/expr/assignment/instance_property_assignment_analyzer.rs b/src/analyzer/expr/assignment/instance_property_assignment_analyzer.rs index 3385077c..e2c2f52b 100644 --- a/src/analyzer/expr/assignment/instance_property_assignment_analyzer.rs +++ b/src/analyzer/expr/assignment/instance_property_assignment_analyzer.rs @@ -245,7 +245,7 @@ pub(crate) fn analyze_regular_assignment( let lhs_var_id = expression_identifier::get_var_id( stmt_var, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -437,7 +437,7 @@ pub(crate) fn analyze_atomic_assignment( let var_id = expression_identifier::get_var_id( expr.0, None, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -551,7 +551,7 @@ pub(crate) fn analyze_atomic_assignment( parent_class: declaring_classlike_storage.direct_parent_class.as_ref(), file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/assignment/static_property_assignment_analyzer.rs b/src/analyzer/expr/assignment/static_property_assignment_analyzer.rs index c9c07020..e0834a26 100644 --- a/src/analyzer/expr/assignment/static_property_assignment_analyzer.rs +++ b/src/analyzer/expr/assignment/static_property_assignment_analyzer.rs @@ -95,7 +95,7 @@ pub(crate) fn analyze( context.function_context.calling_class_final, codebase, &mut is_static, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, ) { name } else { @@ -184,7 +184,7 @@ pub(crate) fn analyze( parent_class: declaring_class_storage.direct_parent_class.as_ref(), file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/binop/assignment_analyzer.rs b/src/analyzer/expr/binop/assignment_analyzer.rs index 07a7be91..8dd83e7d 100644 --- a/src/analyzer/expr/binop/assignment_analyzer.rs +++ b/src/analyzer/expr/binop/assignment_analyzer.rs @@ -58,7 +58,7 @@ pub(crate) fn analyze( let var_id = get_var_id( assign_var, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -396,7 +396,7 @@ fn analyze_list_assignment( let list_var_id = expression_identifier::get_var_id( assign_var_item, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -464,7 +464,7 @@ fn analyze_list_assignment( let source_expr_id = expression_identifier::get_var_id( source_expr, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, diff --git a/src/analyzer/expr/call/arguments_analyzer.rs b/src/analyzer/expr/call/arguments_analyzer.rs index ed7f7a44..f8504814 100644 --- a/src/analyzer/expr/call/arguments_analyzer.rs +++ b/src/analyzer/expr/call/arguments_analyzer.rs @@ -77,7 +77,7 @@ pub(crate) fn check_arguments_match( &type_arg.1 .1, context.function_context.calling_class.as_ref(), statements_analyzer.get_type_resolution_context(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, *statements_analyzer.get_file_path(), type_arg.1 .0.start_offset() as u32, ) @@ -112,7 +112,7 @@ pub(crate) fn check_arguments_match( }, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), @@ -509,7 +509,7 @@ pub(crate) fn check_arguments_match( if let Some(expr_var_id) = expression_identifier::get_var_id( arg_expr, None, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -750,7 +750,7 @@ fn get_param_type( }, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), @@ -825,7 +825,7 @@ fn handle_closure_arg( let mut closure_storage = { match functionlike_analyzer::get_closure_storage( - statements_analyzer.get_file_analyzer(), + statements_analyzer.file_analyzer, closure_expr.1.start_offset(), ) { None => { @@ -993,7 +993,7 @@ pub(crate) fn evaluate_arbitrary_param( let var_id = get_var_id( expr, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -1111,7 +1111,7 @@ fn handle_possibly_matching_inout_param( }, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/call/existing_atomic_method_call_analyzer.rs b/src/analyzer/expr/call/existing_atomic_method_call_analyzer.rs index c980f8d8..005070c8 100644 --- a/src/analyzer/expr/call/existing_atomic_method_call_analyzer.rs +++ b/src/analyzer/expr/call/existing_atomic_method_call_analyzer.rs @@ -297,7 +297,7 @@ fn handle_shapes_static_method( let expr_var_id = expression_identifier::get_var_id( &call_expr.1[0].1, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -340,7 +340,7 @@ fn handle_shapes_static_method( let expr_var_id = expression_identifier::get_var_id( &call_expr.1[0].1, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -610,7 +610,7 @@ fn handle_defined_shape_idx( let expr_var_id = expression_identifier::get_var_id( &call_expr.1[0].1, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -633,7 +633,7 @@ fn handle_defined_shape_idx( ), statements_analyzer.get_config(), &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path_actual, ); diff --git a/src/analyzer/expr/call/function_call_analyzer.rs b/src/analyzer/expr/call/function_call_analyzer.rs index 9e88321d..2aa0381b 100644 --- a/src/analyzer/expr/call/function_call_analyzer.rs +++ b/src/analyzer/expr/call/function_call_analyzer.rs @@ -46,7 +46,7 @@ pub(crate) fn analyze( ) -> Result<(), AnalysisError> { let name = expr.0 .1; - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; // we special-case this because exit is used in // `as` ternaries where the positions may be fake diff --git a/src/analyzer/expr/call/function_call_return_type_fetcher.rs b/src/analyzer/expr/call/function_call_return_type_fetcher.rs index 1285b68a..549b2ad7 100644 --- a/src/analyzer/expr/call/function_call_return_type_fetcher.rs +++ b/src/analyzer/expr/call/function_call_return_type_fetcher.rs @@ -30,7 +30,6 @@ use crate::expr::binop::concat_analyzer::{analyze_concat_nodes, get_concat_nodes use crate::expr::fetch::array_fetch_analyzer::handle_array_access_on_dict; use crate::function_analysis_data::FunctionAnalysisData; use crate::scope::BlockContext; -use crate::scope_analyzer::ScopeAnalyzer; use crate::statements_analyzer::StatementsAnalyzer; use hakana_code_info::ttype::template::{TemplateBound, TemplateResult}; @@ -128,7 +127,7 @@ pub(crate) fn fetch( expand_generic: true, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/call/instance_call_analyzer.rs b/src/analyzer/expr/call/instance_call_analyzer.rs index 35fec563..32ed6e9b 100644 --- a/src/analyzer/expr/call/instance_call_analyzer.rs +++ b/src/analyzer/expr/call/instance_call_analyzer.rs @@ -44,7 +44,7 @@ pub(crate) fn analyze( let lhs_var_id = expression_identifier::get_var_id( expr.0, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, diff --git a/src/analyzer/expr/call/method_call_return_type_fetcher.rs b/src/analyzer/expr/call/method_call_return_type_fetcher.rs index 7142baee..932bc4ee 100644 --- a/src/analyzer/expr/call/method_call_return_type_fetcher.rs +++ b/src/analyzer/expr/call/method_call_return_type_fetcher.rs @@ -23,7 +23,6 @@ use oxidized::ast_defs::Pos; use crate::expr::expression_identifier::get_expr_id; use crate::function_analysis_data::FunctionAnalysisData; use crate::scope::BlockContext; -use crate::scope_analyzer::ScopeAnalyzer; use crate::statements_analyzer::StatementsAnalyzer; use hakana_code_info::functionlike_info::FunctionLikeInfo; use hakana_code_info::ttype::template::{TemplateBound, TemplateResult}; @@ -129,7 +128,7 @@ pub(crate) fn fetch( expand_generic: true, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/call/new_analyzer.rs b/src/analyzer/expr/call/new_analyzer.rs index 0fff74d6..a78293fe 100644 --- a/src/analyzer/expr/call/new_analyzer.rs +++ b/src/analyzer/expr/call/new_analyzer.rs @@ -88,7 +88,7 @@ pub(crate) fn analyze( }) } _ => { - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; let name_string = if let Some(resolved_name) = resolved_names.get(&(id.0.start_offset() as u32)) @@ -397,7 +397,7 @@ fn analyze_named_constructor( &type_arg.1 .1, context.function_context.calling_class.as_ref(), statements_analyzer.get_type_resolution_context(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, *statements_analyzer.get_file_path(), type_arg.1 .0.start_offset() as u32, ) @@ -481,7 +481,7 @@ fn analyze_named_constructor( parent_class: None, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), @@ -575,7 +575,7 @@ fn analyze_named_constructor( &type_arg.1 .1, context.function_context.calling_class.as_ref(), statements_analyzer.get_type_resolution_context(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, *statements_analyzer.get_file_path(), type_arg.1 .0.start_offset() as u32, ) @@ -599,7 +599,7 @@ fn analyze_named_constructor( parent_class: None, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/call/static_call_analyzer.rs b/src/analyzer/expr/call/static_call_analyzer.rs index b4771695..6fecceb4 100644 --- a/src/analyzer/expr/call/static_call_analyzer.rs +++ b/src/analyzer/expr/call/static_call_analyzer.rs @@ -2,7 +2,6 @@ use crate::expression_analyzer; use crate::function_analysis_data::FunctionAnalysisData; use crate::scope::control_action::ControlAction; use crate::scope::BlockContext; -use crate::scope_analyzer::ScopeAnalyzer; use crate::statements_analyzer::StatementsAnalyzer; use crate::stmt_analyzer::AnalysisError; use hakana_code_info::t_atomic::TAtomic; @@ -32,7 +31,7 @@ pub(crate) fn analyze( let mut classlike_name = None; - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; let lhs_type = match &expr.0 .2 { aast::ClassId_::CIexpr(lhs_expr) => { diff --git a/src/analyzer/expr/closure_analyzer.rs b/src/analyzer/expr/closure_analyzer.rs index bb1bf404..35159654 100644 --- a/src/analyzer/expr/closure_analyzer.rs +++ b/src/analyzer/expr/closure_analyzer.rs @@ -25,7 +25,7 @@ pub(crate) fn analyze( fun: &aast::Fun_<(), ()>, expr: &aast::Expr<(), ()>, ) -> Result<(), AnalysisError> { - let mut function_analyzer = FunctionLikeAnalyzer::new(statements_analyzer.get_file_analyzer()); + let mut function_analyzer = FunctionLikeAnalyzer::new(statements_analyzer.file_analyzer); let mut analysis_result = AnalysisResult::new(analysis_data.data_flow_graph.kind, SymbolReferences::new()); let mut lambda_storage = if let Ok(lambda_storage) = function_analyzer.analyze_lambda( diff --git a/src/analyzer/expr/const_fetch_analyzer.rs b/src/analyzer/expr/const_fetch_analyzer.rs index e142df0f..66a9f335 100644 --- a/src/analyzer/expr/const_fetch_analyzer.rs +++ b/src/analyzer/expr/const_fetch_analyzer.rs @@ -29,7 +29,7 @@ pub(crate) fn analyze( let codebase = statements_analyzer.codebase; let name = if let Some(name) = statements_analyzer - .get_file_analyzer() + .file_analyzer .resolved_names .get(&(boxed.0.start_offset() as u32)) { diff --git a/src/analyzer/expr/fetch/array_fetch_analyzer.rs b/src/analyzer/expr/fetch/array_fetch_analyzer.rs index f126692f..040c9434 100644 --- a/src/analyzer/expr/fetch/array_fetch_analyzer.rs +++ b/src/analyzer/expr/fetch/array_fetch_analyzer.rs @@ -37,7 +37,7 @@ pub(crate) fn analyze( let extended_var_id = expression_identifier::get_var_id( expr.0, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, diff --git a/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs b/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs index 936ab215..e3117cec 100644 --- a/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs +++ b/src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs @@ -233,7 +233,7 @@ fn get_class_property_type( parent_class: parent_class.as_ref(), file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), @@ -333,7 +333,7 @@ fn update_template_types( parent_class: None, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/fetch/class_constant_fetch_analyzer.rs b/src/analyzer/expr/fetch/class_constant_fetch_analyzer.rs index 3bcc09a6..b0255469 100644 --- a/src/analyzer/expr/fetch/class_constant_fetch_analyzer.rs +++ b/src/analyzer/expr/fetch/class_constant_fetch_analyzer.rs @@ -39,7 +39,7 @@ pub(crate) fn analyze( context.function_context.calling_class_final, codebase, &mut is_static, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, ) { Some(value) => value, None => return Err(AnalysisError::UserError), @@ -290,7 +290,7 @@ fn analyse_known_class_constant( parent_class: None, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/fetch/instance_property_fetch_analyzer.rs b/src/analyzer/expr/fetch/instance_property_fetch_analyzer.rs index 255a34d8..625c9330 100644 --- a/src/analyzer/expr/fetch/instance_property_fetch_analyzer.rs +++ b/src/analyzer/expr/fetch/instance_property_fetch_analyzer.rs @@ -51,7 +51,7 @@ pub(crate) fn analyze( let stmt_var_id = expression_identifier::get_var_id( expr.0, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, diff --git a/src/analyzer/expr/fetch/static_property_fetch_analyzer.rs b/src/analyzer/expr/fetch/static_property_fetch_analyzer.rs index 35c6bc3c..ee6b4984 100644 --- a/src/analyzer/expr/fetch/static_property_fetch_analyzer.rs +++ b/src/analyzer/expr/fetch/static_property_fetch_analyzer.rs @@ -44,7 +44,7 @@ pub(crate) fn analyze( context.function_context.calling_class_final, codebase, &mut is_static, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, ) { id } else { @@ -239,7 +239,7 @@ pub(crate) fn analyze( parent_class: parent_class.as_ref(), file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/expr/shape_analyzer.rs b/src/analyzer/expr/shape_analyzer.rs index b12e21de..1f6845ca 100644 --- a/src/analyzer/expr/shape_analyzer.rs +++ b/src/analyzer/expr/shape_analyzer.rs @@ -1,6 +1,5 @@ use crate::{ - expression_analyzer, function_analysis_data::FunctionAnalysisData, scope::BlockContext, - scope_analyzer::ScopeAnalyzer, statements_analyzer::StatementsAnalyzer, + expression_analyzer, function_analysis_data::FunctionAnalysisData, scope::BlockContext, statements_analyzer::StatementsAnalyzer, stmt_analyzer::AnalysisError, }; use hakana_code_info::{ @@ -57,7 +56,7 @@ pub(crate) fn analyze( ShapeFieldName::SFlitStr(name) => Some(DictKey::String(name.1.to_string())), ShapeFieldName::SFclassConst(lhs, name) => { let lhs_name = if let Some(name) = statements_analyzer - .get_file_analyzer() + .file_analyzer .resolved_names .get(&(lhs.0.start_offset() as u32)) { diff --git a/src/analyzer/expr/xml_analyzer.rs b/src/analyzer/expr/xml_analyzer.rs index f396acf0..073756e5 100644 --- a/src/analyzer/expr/xml_analyzer.rs +++ b/src/analyzer/expr/xml_analyzer.rs @@ -42,7 +42,7 @@ pub(crate) fn analyze( statements_analyzer: &StatementsAnalyzer, analysis_data: &mut FunctionAnalysisData, ) -> Result<(), AnalysisError> { - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; let xhp_class_name = if let Some(resolved_name) = resolved_names.get(&(boxed.0 .0.start_offset() as u32)) { resolved_name diff --git a/src/analyzer/expression_analyzer.rs b/src/analyzer/expression_analyzer.rs index 639a1a41..25c4102b 100644 --- a/src/analyzer/expression_analyzer.rs +++ b/src/analyzer/expression_analyzer.rs @@ -148,7 +148,7 @@ pub(crate) fn analyze( let keyed_array_var_id = expression_identifier::get_var_id( expr, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, @@ -439,7 +439,7 @@ pub(crate) fn analyze( } aast::Expr_::EnumClassLabel(boxed) => { let class_name = if let Some(id) = &boxed.0 { - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; Some( resolved_names @@ -682,7 +682,7 @@ fn analyze_function_pointer( let codebase = statements_analyzer.codebase; let id = match &boxed.0 { aast::FunctionPtrId::FPId(id) => FunctionLikeIdentifier::Function({ - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; if let Some(name) = resolved_names.get(&(id.0.start_offset() as u32)).cloned() { name @@ -694,7 +694,7 @@ fn analyze_function_pointer( } }), aast::FunctionPtrId::FPClassConst(class_id, method_name) => { - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; let calling_class = &context.function_context.calling_class; let class_name = match &class_id.2 { diff --git a/src/analyzer/file_analyzer.rs b/src/analyzer/file_analyzer.rs index 57ddab35..9593ec9f 100644 --- a/src/analyzer/file_analyzer.rs +++ b/src/analyzer/file_analyzer.rs @@ -112,7 +112,7 @@ impl<'a> FileAnalyzer<'a> { analysis_data, analysis_result, &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, false, diff --git a/src/analyzer/functionlike_analyzer.rs b/src/analyzer/functionlike_analyzer.rs index 97bd2307..71f5e7c5 100644 --- a/src/analyzer/functionlike_analyzer.rs +++ b/src/analyzer/functionlike_analyzer.rs @@ -456,7 +456,7 @@ impl<'a> FunctionLikeAnalyzer<'a> { let mut analysis_data = FunctionAnalysisData::new( DataFlowGraph::new(statements_analyzer.get_config().graph_kind), - statements_analyzer.get_file_analyzer().get_file_source(), + statements_analyzer.file_analyzer.get_file_source(), &statements_analyzer.comments, &self.get_config().all_custom_issues, if let Some(parent_analysis_data) = &parent_analysis_data { @@ -898,7 +898,7 @@ impl<'a> FunctionLikeAnalyzer<'a> { analysis_data, analysis_result, &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, functionlike_storage.ignore_taint_path, @@ -1053,7 +1053,7 @@ impl<'a> FunctionLikeAnalyzer<'a> { if let GraphKind::WholeProgram(_) = &analysis_data.data_flow_graph.kind { let calling_id = if let Some(calling_closure_id) = context.calling_closure_id { FunctionLikeIdentifier::Closure( - self.get_file_analyzer().get_file_source().file_path, + self.file_analyzer.get_file_source().file_path, calling_closure_id, ) } else { diff --git a/src/analyzer/statements_analyzer.rs b/src/analyzer/statements_analyzer.rs index e845966a..b97fce48 100644 --- a/src/analyzer/statements_analyzer.rs +++ b/src/analyzer/statements_analyzer.rs @@ -19,7 +19,7 @@ use oxidized::ast_defs::Pos; use oxidized::prim_defs::Comment; pub struct StatementsAnalyzer<'a> { - file_analyzer: &'a FileAnalyzer<'a>, + pub file_analyzer: &'a FileAnalyzer<'a>, function_info: Option<&'a FunctionLikeInfo>, pub comments: Vec<&'a (Pos, Comment)>, type_resolution_context: &'a TypeResolutionContext, @@ -122,8 +122,8 @@ impl<'a> StatementsAnalyzer<'a> { calling_functionlike_id: Option<&'a FunctionLikeIdentifier>, ) -> AssertionContext { AssertionContext { - file_source: self.get_file_analyzer().get_file_source(), - resolved_names: self.get_file_analyzer().resolved_names, + file_source: self.file_analyzer.get_file_source(), + resolved_names: self.file_analyzer.resolved_names, codebase: Some((self.codebase, self.interner)), this_class_name, type_resolution_context: self.type_resolution_context, @@ -144,11 +144,11 @@ impl<'a> StatementsAnalyzer<'a> { } pub fn get_file_path(&self) -> &FilePath { - &self.get_file_analyzer().get_file_source().file_path + &self.file_analyzer.get_file_source().file_path } pub fn get_file_path_actual(&self) -> &str { - &self.get_file_analyzer().get_file_source().file_path_actual + &self.file_analyzer.get_file_source().file_path_actual } } diff --git a/src/analyzer/stmt/else_analyzer.rs b/src/analyzer/stmt/else_analyzer.rs index 452ccad0..39ae1173 100644 --- a/src/analyzer/stmt/else_analyzer.rs +++ b/src/analyzer/stmt/else_analyzer.rs @@ -3,7 +3,6 @@ use crate::reconciler; use crate::scope::control_action::ControlAction; use crate::scope::loop_scope::LoopScope; use crate::scope::{if_scope::IfScope, BlockContext}; -use crate::scope_analyzer::ScopeAnalyzer; use crate::stmt_analyzer::AnalysisError; use crate::{ function_analysis_data::FunctionAnalysisData, statements_analyzer::StatementsAnalyzer, @@ -99,7 +98,7 @@ pub(crate) fn analyze( control_analyzer::get_control_actions( statements_analyzer.codebase, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, &stmts.0, analysis_data, Vec::new(), diff --git a/src/analyzer/stmt/foreach_analyzer.rs b/src/analyzer/stmt/foreach_analyzer.rs index e88cc3ef..132ed1c1 100644 --- a/src/analyzer/stmt/foreach_analyzer.rs +++ b/src/analyzer/stmt/foreach_analyzer.rs @@ -62,7 +62,7 @@ pub(crate) fn analyze( let var_id = expression_identifier::get_var_id( stmt.0, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, diff --git a/src/analyzer/stmt/if_analyzer.rs b/src/analyzer/stmt/if_analyzer.rs index c17a55e0..271ae938 100644 --- a/src/analyzer/stmt/if_analyzer.rs +++ b/src/analyzer/stmt/if_analyzer.rs @@ -4,7 +4,6 @@ use crate::scope::control_action::ControlAction; use crate::scope::loop_scope::LoopScope; use crate::scope::var_has_root; use crate::scope::{if_scope::IfScope, BlockContext}; -use crate::scope_analyzer::ScopeAnalyzer; use crate::stmt_analyzer::AnalysisError; use crate::{ function_analysis_data::FunctionAnalysisData, statements_analyzer::StatementsAnalyzer, @@ -114,7 +113,7 @@ pub(crate) fn analyze( let final_actions = control_analyzer::get_control_actions( codebase, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, &stmt.1 .0, analysis_data, Vec::new(), diff --git a/src/analyzer/stmt/ifelse_analyzer.rs b/src/analyzer/stmt/ifelse_analyzer.rs index 9439a92e..87414686 100644 --- a/src/analyzer/stmt/ifelse_analyzer.rs +++ b/src/analyzer/stmt/ifelse_analyzer.rs @@ -58,7 +58,7 @@ pub(crate) fn analyze( context: &mut BlockContext, loop_scope: &mut Option, ) -> Result<(), AnalysisError> { - let codebase = statements_analyzer.get_file_analyzer().codebase; + let codebase = statements_analyzer.file_analyzer.codebase; let mut if_scope = IfScope::default(); diff --git a/src/analyzer/stmt/loop_analyzer.rs b/src/analyzer/stmt/loop_analyzer.rs index 590bf070..772d2648 100644 --- a/src/analyzer/stmt/loop_analyzer.rs +++ b/src/analyzer/stmt/loop_analyzer.rs @@ -12,7 +12,6 @@ use crate::{ function_analysis_data::FunctionAnalysisData, reconciler, scope::{control_action::ControlAction, loop_scope::LoopScope, BlockContext}, - scope_analyzer::ScopeAnalyzer, statements_analyzer::StatementsAnalyzer, stmt_analyzer::AnalysisError, }; @@ -86,7 +85,7 @@ pub(crate) fn analyze<'a>( let final_actions = control_analyzer::get_control_actions( codebase, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, stmts, analysis_data, vec![], diff --git a/src/analyzer/stmt/return_analyzer.rs b/src/analyzer/stmt/return_analyzer.rs index 42fd833e..c26f1fba 100644 --- a/src/analyzer/stmt/return_analyzer.rs +++ b/src/analyzer/stmt/return_analyzer.rs @@ -165,7 +165,7 @@ pub(crate) fn analyze( }, file_path: Some( &statements_analyzer - .get_file_analyzer() + .file_analyzer .get_file_source() .file_path, ), diff --git a/src/analyzer/stmt/switch_analyzer.rs b/src/analyzer/stmt/switch_analyzer.rs index d4eedea4..f59b3541 100644 --- a/src/analyzer/stmt/switch_analyzer.rs +++ b/src/analyzer/stmt/switch_analyzer.rs @@ -12,7 +12,6 @@ use crate::{ control_action::ControlAction, loop_scope::LoopScope, switch_scope::SwitchScope, BlockContext, }, - scope_analyzer::ScopeAnalyzer, statements_analyzer::StatementsAnalyzer, stmt_analyzer::AnalysisError, }; @@ -44,7 +43,7 @@ pub(crate) fn analyze( let switch_var_id = if let Some(switch_var_id) = expression_identifier::get_var_id( stmt.0, context.function_context.calling_class.as_ref(), - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, Some(( statements_analyzer.codebase, statements_analyzer.interner, diff --git a/src/analyzer/stmt/try_analyzer.rs b/src/analyzer/stmt/try_analyzer.rs index 88c20ac7..2a52f4ed 100644 --- a/src/analyzer/stmt/try_analyzer.rs +++ b/src/analyzer/stmt/try_analyzer.rs @@ -3,8 +3,7 @@ use crate::scope::{ }; use crate::stmt_analyzer::AnalysisError; use crate::{ - function_analysis_data::FunctionAnalysisData, scope_analyzer::ScopeAnalyzer, - statements_analyzer::StatementsAnalyzer, + function_analysis_data::FunctionAnalysisData, statements_analyzer::StatementsAnalyzer, }; use hakana_code_info::data_flow::graph::GraphKind; use hakana_code_info::data_flow::node::{DataFlowNode, DataFlowNodeId, DataFlowNodeKind}; @@ -52,7 +51,7 @@ pub(crate) fn analyze( let try_block_control_actions = control_analyzer::get_control_actions( codebase, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, &stmt.0 .0, analysis_data, vec![], @@ -99,7 +98,7 @@ pub(crate) fn analyze( let mut definitely_newly_assigned_var_ids = newly_assigned_var_ids.clone(); - let resolved_names = statements_analyzer.get_file_analyzer().resolved_names; + let resolved_names = statements_analyzer.file_analyzer.resolved_names; let mut all_catches_leave = true; @@ -152,12 +151,7 @@ pub(crate) fn analyze( let new_parent_node = if analysis_data.data_flow_graph.kind == GraphKind::FunctionBody { DataFlowNode::get_for_variable_source( - VarId( - statements_analyzer - .interner - .get(catch_var_id) - .unwrap(), - ), + VarId(statements_analyzer.interner.get(catch_var_id).unwrap()), statements_analyzer.get_hpos(&catch.1 .0), false, true, @@ -166,12 +160,7 @@ pub(crate) fn analyze( ) } else { DataFlowNode::get_for_lvar( - VarId( - statements_analyzer - .interner - .get(catch_var_id) - .unwrap(), - ), + VarId(statements_analyzer.interner.get(catch_var_id).unwrap()), statements_analyzer.get_hpos(&catch.1 .0), ) }; @@ -214,7 +203,7 @@ pub(crate) fn analyze( let catch_actions = control_analyzer::get_control_actions( codebase, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, &catch.2 .0, analysis_data, vec![], @@ -328,7 +317,7 @@ pub(crate) fn analyze( let finally_actions = control_analyzer::get_control_actions( codebase, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, &stmt.2 .0, analysis_data, vec![], diff --git a/src/analyzer/stmt_analyzer.rs b/src/analyzer/stmt_analyzer.rs index cace6328..383f127d 100644 --- a/src/analyzer/stmt_analyzer.rs +++ b/src/analyzer/stmt_analyzer.rs @@ -305,7 +305,7 @@ fn detect_unused_statement_expressions( let functionlike_id = get_static_functionlike_id_from_call( boxed_call, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, ); if let Some(FunctionLikeIdentifier::Function(function_id)) = functionlike_id { @@ -394,7 +394,7 @@ fn has_unused_must_use( let functionlike_id_from_call = get_functionlike_id_from_call( boxed_call, statements_analyzer.interner, - statements_analyzer.get_file_analyzer().resolved_names, + statements_analyzer.file_analyzer.resolved_names, &analysis_data.expr_types, ); if let Some(functionlike_id) = functionlike_id_from_call {