MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / collect_from_statement

Function collect_from_statement

src/diagnostics/unused_variables.rs:92–129  ·  view source on GitHub ↗
(stmt: &Statement<'_>, ctx: &mut DiagnosticCtx<'_>)

Source from the content-addressed store, hash-verified

90// ─── AST walking ────────────────────────────────────────────────────────────
91
92fn collect_from_statement(stmt: &Statement<'_>, ctx: &mut DiagnosticCtx<'_>) {
93 match stmt {
94 Statement::Function(func) => {
95 let body_start = func.body.left_brace.start.offset;
96 let body_end = func.body.right_brace.end.offset;
97 let compact_vars = collect_compact_vars(func.body.statements.as_slice());
98 let scope = collect_function_scope_with_resolver(
99 &func.parameter_list,
100 func.body.statements.as_slice(),
101 body_start,
102 body_end,
103 None,
104 );
105 check_scope(&scope, ctx, None, &compact_vars);
106 }
107 Statement::Class(class) => {
108 collect_from_class_members(class.members.as_slice(), ctx);
109 }
110 Statement::Trait(tr) => {
111 collect_from_class_members(tr.members.as_slice(), ctx);
112 }
113 Statement::Enum(en) => {
114 collect_from_class_members(en.members.as_slice(), ctx);
115 }
116 Statement::Interface(_) => {
117 // Interfaces don't have method bodies.
118 }
119 Statement::Namespace(ns) => {
120 for inner in ns.statements().iter() {
121 collect_from_statement(inner, ctx);
122 }
123 }
124 _ => {
125 // Top-level code — don't diagnose (global scope has
126 // too many implicit variable definitions).
127 }
128 }
129}
130
131fn collect_from_class_members(members: &[ClassLikeMember<'_>], ctx: &mut DiagnosticCtx<'_>) {
132 for member in members.iter() {

Calls 5

collect_compact_varsFunction · 0.85
iterMethod · 0.80
check_scopeFunction · 0.70

Tested by

no test coverage detected