use super::{AnalysisContext, Scope, ScopeAnalyzer, ScopeIssue};
use crate::ast::Node;
use std::rc::Rc;
pub(super) fn handle_string(
analyzer: &ScopeAnalyzer,
value: &str,
interpolated: bool,
scope: &Rc<Scope>,
context: &AnalysisContext<'_>,
) {
if interpolated
|| value.starts_with('"')
|| value.starts_with('`')
|| value.starts_with("qq")
|| value.starts_with("qx")
{
analyzer.mark_interpolated_variables_used(value, scope, context);
}
}
pub(super) fn handle_heredoc(
analyzer: &ScopeAnalyzer,
content: &str,
interpolated: bool,
scope: &Rc<Scope>,
context: &AnalysisContext<'_>,
) {
if interpolated {
analyzer.mark_interpolated_variables_used(content, scope, context);
}
}
pub(super) fn handle_match<'a>(
analyzer: &ScopeAnalyzer,
node: &'a Node,
expr: &'a Node,
scope: &Rc<Scope>,
ancestors: &mut Vec<&'a Node>,
issues: &mut Vec<ScopeIssue>,
context: &AnalysisContext<'a>,
) {
scope.has_regex_match.set(true);
ancestors.push(node);
analyzer.analyze_node(expr, scope, ancestors, issues, context);
ancestors.pop();
}
pub(super) fn handle_substitution<'a>(
analyzer: &ScopeAnalyzer,
node: &'a Node,
expr: &'a Node,
scope: &Rc<Scope>,
ancestors: &mut Vec<&'a Node>,
issues: &mut Vec<ScopeIssue>,
context: &AnalysisContext<'a>,
) {
scope.has_regex_match.set(true);
ancestors.push(node);
analyzer.analyze_node(expr, scope, ancestors, issues, context);
ancestors.pop();
}
pub(super) fn handle_regex(scope: &Rc<Scope>) {
scope.has_regex_match.set(true);
}