Skip to content

Commit

Permalink
Simplify getting codebase/interner
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Nov 11, 2024
1 parent cd9b465 commit 76d79f7
Show file tree
Hide file tree
Showing 64 changed files with 451 additions and 501 deletions.
10 changes: 5 additions & 5 deletions src/analyzer/algebra_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub(crate) fn check_for_paradox(
})
})
{
let clause_string = formula_2_clause.to_string(statements_analyzer.get_interner());
let clause_string = formula_2_clause.to_string(statements_analyzer.interner);

analysis_data.maybe_add_issue(
Issue::new(
Expand Down Expand Up @@ -116,7 +116,7 @@ pub(crate) fn check_for_paradox(
paradox_message += "(";
paradox_message += mini_formula_2
.iter()
.map(|c| c.to_string(statements_analyzer.get_interner()))
.map(|c| c.to_string(statements_analyzer.interner))
.collect::<Vec<String>>()
.join(") && (")
.as_str();
Expand All @@ -125,19 +125,19 @@ pub(crate) fn check_for_paradox(
paradox_message += mini_formula_2
.first()
.unwrap()
.to_string(statements_analyzer.get_interner())
.to_string(statements_analyzer.interner)
.as_str();
}
} else {
paradox_message += "Condition not (";
paradox_message += negated_clause_2
.to_string(statements_analyzer.get_interner())
.to_string(statements_analyzer.interner)
.as_str();
}

paradox_message += ") contradicts a previously-established condition (";
paradox_message += clause_1
.to_string(statements_analyzer.get_interner())
.to_string(statements_analyzer.interner)
.as_str();
paradox_message += ")";

Expand Down
6 changes: 3 additions & 3 deletions src/analyzer/classlike_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a> ClassLikeAnalyzer<'a> {
));
};

let codebase = self.file_analyzer.get_codebase();
let codebase = self.file_analyzer.codebase;

if self.file_analyzer.analysis_config.ast_diff
&& self.file_analyzer.codebase.safe_symbols.contains(&name)
Expand Down Expand Up @@ -244,8 +244,8 @@ fn emit_dupe_enum_case_issue(
IssueKind::DuplicateEnumValue,
format!(
"Duplicate enum value for {}, previously defined by case {}",
statements_analyzer.get_interner().lookup(&enum_name),
statements_analyzer.get_interner().lookup(existing_name)
statements_analyzer.interner.lookup(&enum_name),
statements_analyzer.interner.lookup(existing_name)
),
statements_analyzer.get_hpos(expr.pos()),
&Some(FunctionLikeIdentifier::Function(enum_name)),
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 @@ -26,8 +26,8 @@ pub(crate) fn analyze(
if statements_analyzer.get_config().in_codegen
&& !statements_analyzer.get_config().hooks.iter().any(|hook| {
hook.can_codegen_def(
statements_analyzer.get_interner(),
statements_analyzer.get_codebase(),
statements_analyzer.interner,
statements_analyzer.codebase,
statements_analyzer.get_file_analyzer().resolved_names,
def,
)
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/expr/as_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub(crate) fn analyze<'expr>(
.unwrap_or(get_mixed_any());

if ternary_type.is_mixed() {
let codebase = statements_analyzer.get_codebase();
let codebase = statements_analyzer.codebase;
let mut hint_type = get_type_from_hint(
&hint.1,
context.function_context.calling_class.as_ref(),
Expand All @@ -159,7 +159,7 @@ pub(crate) fn analyze<'expr>(
);
type_expander::expand_union(
codebase,
&Some(statements_analyzer.get_interner()),
&Some(statements_analyzer.interner),
&mut hint_type,
&TypeExpansionOptions {
self_class: context.function_context.calling_class.as_ref(),
Expand Down
30 changes: 15 additions & 15 deletions src/analyzer/expr/assignment/array_assignment_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pub(crate) fn analyze(
context.function_context.calling_class.as_ref(),
statements_analyzer.get_file_analyzer().resolved_names,
Some((
statements_analyzer.get_codebase(),
statements_analyzer.get_interner(),
statements_analyzer.codebase,
statements_analyzer.interner,
)),
);

Expand All @@ -91,7 +91,7 @@ pub(crate) fn analyze(
if analysis_data.data_flow_graph.kind == GraphKind::FunctionBody {
if let Some(root_var_id) = &root_var_id {
if let aast::Expr_::Lvar(_) = &root_array_expr.2 {
let interner = statements_analyzer.get_interner();
let interner = statements_analyzer.interner;
analysis_data
.data_flow_graph
.add_node(DataFlowNode::get_for_variable_source(
Expand Down Expand Up @@ -186,7 +186,7 @@ pub(crate) fn update_type_with_key_values(
key_type: Option<Rc<TUnion>>,
) -> TUnion {
let mut has_matching_item = false;
let codebase = statements_analyzer.get_codebase();
let codebase = statements_analyzer.codebase;

new_type.types = new_type
.types
Expand Down Expand Up @@ -390,7 +390,7 @@ fn add_array_assignment_dataflow(
}

let parent_node = if let Some(var_var_id) = var_var_id {
if let Some(var_id) = statements_analyzer.get_interner().get(&var_var_id) {
if let Some(var_id) = statements_analyzer.interner.get(&var_var_id) {
DataFlowNode::get_for_lvar(VarId(var_id), statements_analyzer.get_hpos(expr_var_pos))
} else {
DataFlowNode::get_for_array_assignment(statements_analyzer.get_hpos(expr_var_pos))
Expand Down Expand Up @@ -446,7 +446,7 @@ fn add_array_assignment_dataflow(
..
} => {
if let Some(literal_value) = statements_analyzer
.get_codebase()
.codebase
.get_classconst_literal_value(enum_name, member_name)
{
if let Some(value) = literal_value.get_literal_string_value() {
Expand Down Expand Up @@ -499,7 +499,7 @@ fn update_array_assignment_child_type(
value_type: TUnion,
root_type: TUnion,
) -> TUnion {
let codebase = statements_analyzer.get_codebase();
let codebase = statements_analyzer.codebase;
let mut collection_types = Vec::new();

if let Some(key_type) = &key_type {
Expand Down Expand Up @@ -694,8 +694,8 @@ pub(crate) fn analyze_nested_array_assignment<'a>(
if let Some(dim_id) = expression_identifier::get_dim_id(
dim,
Some((
statements_analyzer.get_codebase(),
statements_analyzer.get_interner(),
statements_analyzer.codebase,
statements_analyzer.interner,
)),
statements_analyzer.get_file_analyzer().resolved_names,
) {
Expand All @@ -705,8 +705,8 @@ pub(crate) fn analyze_nested_array_assignment<'a>(
context.function_context.calling_class.as_ref(),
statements_analyzer.get_file_analyzer().resolved_names,
Some((
statements_analyzer.get_codebase(),
statements_analyzer.get_interner(),
statements_analyzer.codebase,
statements_analyzer.interner,
)),
) {
format!("[{}]", dim_id)
Expand Down Expand Up @@ -786,8 +786,8 @@ pub(crate) fn analyze_nested_array_assignment<'a>(
context.function_context.calling_class.as_ref(),
statements_analyzer.get_file_analyzer().resolved_names,
Some((
statements_analyzer.get_codebase(),
statements_analyzer.get_interner(),
statements_analyzer.codebase,
statements_analyzer.interner,
)),
),
&array_expr_offset_atomic_types,
Expand Down Expand Up @@ -877,8 +877,8 @@ pub(crate) fn analyze_nested_array_assignment<'a>(
context.function_context.calling_class.as_ref(),
statements_analyzer.get_file_analyzer().resolved_names,
Some((
statements_analyzer.get_codebase(),
statements_analyzer.get_interner(),
statements_analyzer.codebase,
statements_analyzer.interner,
)),
) {
parent_array_var_id = Some(var_var_id.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub(crate) fn analyze(
analysis_data: &mut FunctionAnalysisData,
context: &mut BlockContext,
) -> Result<(), AnalysisError> {
let codebase = statements_analyzer.get_codebase();
let codebase = statements_analyzer.codebase;
let stmt_var = expr.0;

// TODO if ($stmt instanceof PropertyProperty) {
Expand Down Expand Up @@ -111,8 +111,8 @@ pub(crate) fn analyze(
IssueKind::UpcastAwaitable,
format!(
"{} contains Awaitable but was passed into a more general type {}",
assignment_type.get_id(Some(statements_analyzer.get_interner())),
class_property_type.get_id(Some(statements_analyzer.get_interner())),
assignment_type.get_id(Some(statements_analyzer.interner)),
class_property_type.get_id(Some(statements_analyzer.interner)),
),
statements_analyzer.get_hpos(&stmt_var.1),
&context.function_context.calling_functionlike_id,
Expand All @@ -134,8 +134,8 @@ pub(crate) fn analyze(
"{} expects {}, parent type {} provided",
var_id.clone().unwrap_or("var".to_string()),
class_property_type
.get_id(Some(statements_analyzer.get_interner())),
assignment_type.get_id(Some(statements_analyzer.get_interner())),
.get_id(Some(statements_analyzer.interner)),
assignment_type.get_id(Some(statements_analyzer.interner)),
),
statements_analyzer.get_hpos(&stmt_var.1),
&context.function_context.calling_functionlike_id,
Expand All @@ -151,8 +151,8 @@ pub(crate) fn analyze(
"{} expects {}, parent type {} provided",
var_id.clone().unwrap_or("var".to_string()),
class_property_type
.get_id(Some(statements_analyzer.get_interner())),
assignment_type.get_id(Some(statements_analyzer.get_interner())),
.get_id(Some(statements_analyzer.interner)),
assignment_type.get_id(Some(statements_analyzer.interner)),
),
statements_analyzer.get_hpos(&stmt_var.1),
&context.function_context.calling_functionlike_id,
Expand All @@ -177,7 +177,7 @@ pub(crate) fn analyze(
// }
invalid_assignment_value_types.insert(
&assigned_property.1 .1,
class_property_type.get_id(Some(statements_analyzer.get_interner())),
class_property_type.get_id(Some(statements_analyzer.interner)),
);
} else {
// has_valid_assignment_value_type = true;
Expand All @@ -192,9 +192,9 @@ pub(crate) fn analyze(
IssueKind::InvalidPropertyAssignmentValue,
format!(
"Property ${} with declared type {}, cannot be assigned type {}",
statements_analyzer.get_interner().lookup(property_id),
statements_analyzer.interner.lookup(property_id),
invalid_class_property_type,
assignment_type.get_id(Some(statements_analyzer.get_interner())),
assignment_type.get_id(Some(statements_analyzer.interner)),
),
statements_analyzer.get_hpos(&stmt_var.1),
&context.function_context.calling_functionlike_id,
Expand Down Expand Up @@ -222,7 +222,7 @@ pub(crate) fn analyze_regular_assignment(

let mut assigned_properties = Vec::new();
let mut context_type = None;
let codebase = statements_analyzer.get_codebase();
let codebase = statements_analyzer.codebase;

let was_inside_general_use = context.inside_general_use;
context.inside_general_use = true;
Expand All @@ -247,8 +247,8 @@ pub(crate) fn analyze_regular_assignment(
context.function_context.calling_class.as_ref(),
statements_analyzer.get_file_analyzer().resolved_names,
Some((
statements_analyzer.get_codebase(),
statements_analyzer.get_interner(),
statements_analyzer.codebase,
statements_analyzer.interner,
)),
);

Expand Down Expand Up @@ -369,7 +369,7 @@ pub(crate) fn analyze_atomic_assignment(
context: &mut BlockContext,
is_lhs_reference_free: bool,
) -> Option<(TUnion, (StrId, StrId), TUnion)> {
let codebase = statements_analyzer.get_codebase();
let codebase = statements_analyzer.codebase;
let fq_class_name = match lhs_type_part {
TAtomic::TNamedObject { name, .. } => *name,
TAtomic::TReference { name, .. } => {
Expand All @@ -378,7 +378,7 @@ pub(crate) fn analyze_atomic_assignment(
IssueKind::NonExistentClass,
format!(
"Undefined class {}",
statements_analyzer.get_interner().lookup(name)
statements_analyzer.interner.lookup(name)
),
statements_analyzer.get_hpos(expr.1.pos()),
&context.function_context.calling_functionlike_id,
Expand All @@ -399,15 +399,15 @@ pub(crate) fn analyze_atomic_assignment(
};

let prop_name = if let aast::Expr_::Id(id) = &expr.1 .2 {
if let Some(prop_name) = statements_analyzer.get_interner().get(&id.1) {
if let Some(prop_name) = statements_analyzer.interner.get(&id.1) {
prop_name
} else {
analysis_data.maybe_add_issue(
Issue::new(
IssueKind::NonExistentProperty,
format!(
"Undefined property {}::${}",
statements_analyzer.get_interner().lookup(&fq_class_name),
statements_analyzer.interner.lookup(&fq_class_name),
&id.1
),
statements_analyzer.get_hpos(expr.1.pos()),
Expand Down Expand Up @@ -439,8 +439,8 @@ pub(crate) fn analyze_atomic_assignment(
None,
statements_analyzer.get_file_analyzer().resolved_names,
Some((
statements_analyzer.get_codebase(),
statements_analyzer.get_interner(),
statements_analyzer.codebase,
statements_analyzer.interner,
)),
);

Expand Down Expand Up @@ -505,8 +505,8 @@ pub(crate) fn analyze_atomic_assignment(
IssueKind::ImmutablePropertyWrite,
format!(
"Property {}::${} is defined on an immutable class",
statements_analyzer.get_interner().lookup(&property_id.0),
statements_analyzer.get_interner().lookup(&property_id.1),
statements_analyzer.interner.lookup(&property_id.0),
statements_analyzer.interner.lookup(&property_id.1),
),
statements_analyzer.get_hpos(expr.1.pos()),
&context.function_context.calling_functionlike_id,
Expand Down Expand Up @@ -543,7 +543,7 @@ pub(crate) fn analyze_atomic_assignment(
if !class_property_type.is_mixed() {
type_expander::expand_union(
codebase,
&Some(statements_analyzer.get_interner()),
&Some(statements_analyzer.interner),
&mut class_property_type,
&TypeExpansionOptions {
self_class: Some(&declaring_classlike_storage.name),
Expand Down Expand Up @@ -576,8 +576,8 @@ pub(crate) fn analyze_atomic_assignment(
IssueKind::NonExistentProperty,
format!(
"Undefined property {}::${}",
statements_analyzer.get_interner().lookup(&property_id.0),
statements_analyzer.get_interner().lookup(&property_id.1),
statements_analyzer.interner.lookup(&property_id.0),
statements_analyzer.interner.lookup(&property_id.1),
),
statements_analyzer.get_hpos(expr.1.pos()),
&context.function_context.calling_functionlike_id,
Expand All @@ -602,7 +602,7 @@ fn add_instance_property_dataflow(
fq_class_name: &StrId,
property_id: &(StrId, StrId),
) {
let codebase = statements_analyzer.get_codebase();
let codebase = statements_analyzer.codebase;

if let Some(classlike_storage) = codebase.classlike_infos.get(fq_class_name) {
if classlike_storage.specialize_instance {
Expand Down
Loading

0 comments on commit 76d79f7

Please sign in to comment.