Skip to content

Commit

Permalink
Also simplify get_file_analyzer access
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Nov 11, 2024
1 parent 76d79f7 commit d43b290
Show file tree
Hide file tree
Showing 39 changed files with 88 additions and 124 deletions.
2 changes: 1 addition & 1 deletion src/analyzer/algebra_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/classlike_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/analyzer/dataflow/unused_variable_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/def_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
})
Expand Down Expand Up @@ -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))
{
Expand Down
3 changes: 1 addition & 2 deletions src/analyzer/expr/as_analyzer.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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,
)
Expand Down
37 changes: 11 additions & 26 deletions src/analyzer/expr/assignment/array_assignment_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
),
Expand Down
6 changes: 3 additions & 3 deletions src/analyzer/expr/binop/assignment_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions src/analyzer/expr/call/arguments_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -750,7 +750,7 @@ fn get_param_type(
},
file_path: Some(
&statements_analyzer
.get_file_analyzer()
.file_analyzer
.get_file_source()
.file_path,
),
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
);
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expr/call/function_call_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/analyzer/expr/call/function_call_return_type_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
),
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expr/call/instance_call_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/analyzer/expr/call/method_call_return_type_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
),
Expand Down
Loading

0 comments on commit d43b290

Please sign in to comment.