Skip to content

Commit

Permalink
Simplify getting file_source too
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Nov 11, 2024
1 parent d43b290 commit 0edc8bd
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/analyzer/algebra_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub(crate) fn check_for_paradox(
statements_analyzer.get_config(),
&statements_analyzer
.file_analyzer
.get_file_source()
.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.file_analyzer.get_file_source(),
&statements_analyzer.file_analyzer.file_source,
&statements_analyzer.comments,
&statements_analyzer.get_config().all_custom_issues,
None,
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/dataflow/unused_variable_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ pub(crate) fn add_unused_expression_replacements(
unused_variable_nodes: unused_source_nodes,
comments: statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.comments,
in_single_block: false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ pub(crate) fn analyze_atomic_assignment(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub(crate) fn analyze(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
6 changes: 3 additions & 3 deletions src/analyzer/expr/call/arguments_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub(crate) fn check_arguments_match(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
expand_typenames: false,
Expand Down Expand Up @@ -751,7 +751,7 @@ fn get_param_type(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down Expand Up @@ -1112,7 +1112,7 @@ fn handle_possibly_matching_inout_param(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ fn handle_defined_shape_idx(
statements_analyzer.get_config(),
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path_actual,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub(crate) fn fetch(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expr/call/method_call_return_type_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub(crate) fn fetch(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/expr/call/new_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ fn analyze_named_constructor(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down Expand Up @@ -600,7 +600,7 @@ fn analyze_named_constructor(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/expr/fetch/atomic_property_fetch_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ fn get_class_property_type(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down Expand Up @@ -334,7 +334,7 @@ fn update_template_types(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expr/fetch/class_constant_fetch_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ fn analyse_known_class_constant(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/expr/fetch/static_property_fetch_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub(crate) fn analyze(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/file_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct InternalError(pub String, pub HPos);

#[derive(Clone)]
pub struct FileAnalyzer<'a> {
file_source: FileSource<'a>,
pub file_source: FileSource<'a>,
namespace_name: Option<String>,
pub resolved_names: &'a FxHashMap<u32, StrId>,
pub codebase: &'a CodebaseInfo,
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<'a> FileAnalyzer<'a> {
analysis_result,
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
false,
);
Expand Down
26 changes: 13 additions & 13 deletions src/analyzer/functionlike_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
"Cannot resolve function name".to_string(),
HPos::new(
stmt.name.pos(),
self.file_analyzer.get_file_source().file_path,
self.file_analyzer.file_source.file_path,
),
));
};
Expand All @@ -90,7 +90,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
"Cannot load function storage".to_string(),
HPos::new(
stmt.name.pos(),
self.file_analyzer.get_file_source().file_path,
self.file_analyzer.file_source.file_path,
),
));
};
Expand All @@ -99,7 +99,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
self.file_analyzer,
function_storage.type_resolution_context.as_ref().unwrap(),
self.file_analyzer
.get_file_source()
.file_source
.comments
.iter()
.filter(|c| {
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
None => {
return Err(AnalysisError::InternalError(
"Cannot get closure storage".to_string(),
HPos::new(&stmt.span, self.file_analyzer.get_file_source().file_path),
HPos::new(&stmt.span, self.file_analyzer.file_source.file_path),
));
}
Some(value) => value,
Expand All @@ -164,7 +164,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
self.file_analyzer,
lambda_storage.type_resolution_context.as_ref().unwrap(),
self.file_analyzer
.get_file_source()
.file_source
.comments
.iter()
.filter(|c| {
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
} else {
return Err(AnalysisError::InternalError(
"Cannot resolve method name".to_string(),
HPos::new(&stmt.name.0, self.file_analyzer.get_file_source().file_path),
HPos::new(&stmt.name.0, self.file_analyzer.file_source.file_path),
));
};

Expand All @@ -240,7 +240,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
} else {
return Err(AnalysisError::InternalError(
"Cannot resolve function storage".to_string(),
HPos::new(&stmt.name.0, self.file_analyzer.get_file_source().file_path),
HPos::new(&stmt.name.0, self.file_analyzer.file_source.file_path),
));
};

Expand All @@ -251,7 +251,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
.as_ref()
.unwrap(),
self.file_analyzer
.get_file_source()
.file_source
.comments
.iter()
.filter(|c| {
Expand Down Expand Up @@ -409,7 +409,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
false
},
expand_generic: true,
file_path: Some(&self.file_analyzer.get_file_source().file_path),
file_path: Some(&self.file_analyzer.file_source.file_path),

..Default::default()
},
Expand Down Expand Up @@ -456,7 +456,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {

let mut analysis_data = FunctionAnalysisData::new(
DataFlowGraph::new(statements_analyzer.get_config().graph_kind),
statements_analyzer.file_analyzer.get_file_source(),
&statements_analyzer.file_analyzer.file_source,
&statements_analyzer.comments,
&self.get_config().all_custom_issues,
if let Some(parent_analysis_data) = &parent_analysis_data {
Expand Down Expand Up @@ -899,7 +899,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
analysis_result,
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
functionlike_storage.ignore_taint_path,
);
Expand Down Expand Up @@ -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.file_analyzer.get_file_source().file_path,
self.file_analyzer.file_source.file_path,
calling_closure_id,
)
} else {
Expand Down Expand Up @@ -1544,7 +1544,7 @@ pub(crate) fn get_closure_storage(
.codebase
.functionlike_infos
.get(&(
file_analyzer.get_file_source().file_path.0,
file_analyzer.file_source.file_path.0,
StrId(offset as u32),
))
.cloned()
Expand Down
8 changes: 4 additions & 4 deletions src/analyzer/statements_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'a> StatementsAnalyzer<'a> {

#[inline]
pub fn get_hpos(&self, pos: &Pos) -> HPos {
HPos::new(pos, self.file_analyzer.get_file_source().file_path)
HPos::new(pos, self.file_analyzer.file_source.file_path)
}

#[inline]
Expand All @@ -122,7 +122,7 @@ impl<'a> StatementsAnalyzer<'a> {
calling_functionlike_id: Option<&'a FunctionLikeIdentifier>,
) -> AssertionContext {
AssertionContext {
file_source: self.file_analyzer.get_file_source(),
file_source: &self.file_analyzer.file_source,
resolved_names: self.file_analyzer.resolved_names,
codebase: Some((self.codebase, self.interner)),
this_class_name,
Expand All @@ -144,11 +144,11 @@ impl<'a> StatementsAnalyzer<'a> {
}

pub fn get_file_path(&self) -> &FilePath {
&self.file_analyzer.get_file_source().file_path
&self.file_analyzer.file_source.file_path
}

pub fn get_file_path_actual(&self) -> &str {
&self.file_analyzer.get_file_source().file_path_actual
&self.file_analyzer.file_source.file_path_actual
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/stmt/return_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub(crate) fn analyze(
file_path: Some(
&statements_analyzer
.file_analyzer
.get_file_source()
.file_source
.file_path,
),
..Default::default()
Expand Down

0 comments on commit 0edc8bd

Please sign in to comment.