Skip to main content

luaur_analysis/methods/
lint_table_operations_is_length.rs

1use crate::records::lint_table_operations::LintTableOperations;
2use luaur_ast::records::ast_expr::AstExpr;
3use luaur_ast::records::ast_expr_unary::AstExprUnary;
4use luaur_ast::records::ast_node::AstNode;
5
6impl LintTableOperations {
7    pub fn is_length(&mut self, expr: *mut AstExpr, table: *mut AstExpr) -> bool {
8        let n = unsafe { luaur_ast::rtti::ast_node_as::<AstExprUnary>(expr as *mut AstNode) };
9        if n.is_null() {
10            return false;
11        }
12        let n_ref = unsafe { &*n };
13        n_ref.op == AstExprUnary::Len && crate::functions::similar::similar(n_ref.expr, table)
14    }
15}