Skip to content

Commit

Permalink
Add easier means of deriving fn migration-worthiness
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jun 23, 2024
1 parent 5e38a89 commit c3003bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/analyzer/custom_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct FunctionLikeParamData<'a> {
pub param_node: &'a aast::FunParam<(), ()>,
pub codebase: &'a CodebaseInfo,
pub interner: &'a Interner,
pub in_migratable_function: bool,
}

pub struct AfterArgAnalysisData<'a> {
Expand Down
17 changes: 17 additions & 0 deletions src/analyzer/functionlike_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,22 @@ impl<'a> FunctionLikeAnalyzer<'a> {
) -> Result<(Option<TUnion>, u8), AnalysisError> {
context.inside_async = functionlike_storage.is_async;

statements_analyzer.in_migratable_function =
if !self.file_analyzer.get_config().migration_symbols.is_empty() {
let calling_functionlike_id_str = context
.function_context
.calling_functionlike_id
.unwrap()
.to_string(&self.file_analyzer.interner);

self.file_analyzer
.get_config()
.migration_symbols
.contains_key(&calling_functionlike_id_str)
} else {
false
};

let mut analysis_data = FunctionAnalysisData::new(
DataFlowGraph::new(statements_analyzer.get_config().graph_kind),
statements_analyzer.get_file_analyzer().get_file_source(),
Expand Down Expand Up @@ -1154,6 +1170,7 @@ impl<'a> FunctionLikeAnalyzer<'a> {
param_node,
codebase: statements_analyzer.get_codebase(),
interner: statements_analyzer.get_interner(),
in_migratable_function: statements_analyzer.in_migratable_function,
},
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/analyzer/statements_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct StatementsAnalyzer<'a> {
function_info: Option<&'a FunctionLikeInfo>,
pub comments: Vec<&'a (Pos, Comment)>,
type_resolution_context: &'a TypeResolutionContext,
pub in_migratable_function: bool,
}

impl<'a> StatementsAnalyzer<'a> {
Expand All @@ -36,6 +37,7 @@ impl<'a> StatementsAnalyzer<'a> {
function_info: None,
comments,
type_resolution_context,
in_migratable_function: false,
}
}

Expand Down

0 comments on commit c3003bb

Please sign in to comment.