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

Function collect_spans_from_expression

src/selection_range.rs:558–854  ·  view source on GitHub ↗
(expr: &Expression<'_>, offset: u32, spans: &mut Vec<(u32, u32)>)

Source from the content-addressed store, hash-verified

556// ─── Expression walker ──────────────────────────────────────────────────────
557
558fn collect_spans_from_expression(expr: &Expression<'_>, offset: u32, spans: &mut Vec<(u32, u32)>) {
559 let expr_span = expr.span();
560 if !push_if_contains(expr_span, offset, spans) {
561 return;
562 }
563
564 match expr {
565 Expression::Binary(bin) => {
566 collect_spans_from_expression(bin.lhs, offset, spans);
567 collect_spans_from_expression(bin.rhs, offset, spans);
568 }
569
570 Expression::UnaryPrefix(unary) => {
571 collect_spans_from_expression(unary.operand, offset, spans);
572 }
573
574 Expression::UnaryPostfix(unary) => {
575 collect_spans_from_expression(unary.operand, offset, spans);
576 }
577
578 Expression::Parenthesized(paren) => {
579 collect_spans_from_expression(paren.expression, offset, spans);
580 }
581
582 Expression::Assignment(assign) => {
583 collect_spans_from_expression(assign.lhs, offset, spans);
584 collect_spans_from_expression(assign.rhs, offset, spans);
585 }
586
587 Expression::Conditional(cond) => {
588 collect_spans_from_expression(cond.condition, offset, spans);
589 if let Some(then_expr) = cond.then {
590 collect_spans_from_expression(then_expr, offset, spans);
591 }
592 collect_spans_from_expression(cond.r#else, offset, spans);
593 }
594
595 Expression::Call(call) => {
596 match call {
597 Call::Function(func_call) => {
598 collect_spans_from_expression(func_call.function, offset, spans);
599 collect_spans_from_argument_list(&func_call.argument_list, offset, spans);
600 }
601 Call::Method(method_call) => {
602 collect_spans_from_expression(method_call.object, offset, spans);
603 // method selector
604 let sel_span = method_call.method.span();
605 let _ = push_if_contains(sel_span, offset, spans);
606 collect_spans_from_argument_list(&method_call.argument_list, offset, spans);
607 }
608 Call::NullSafeMethod(method_call) => {
609 collect_spans_from_expression(method_call.object, offset, spans);
610 let sel_span = method_call.method.span();
611 let _ = push_if_contains(sel_span, offset, spans);
612 collect_spans_from_argument_list(&method_call.argument_list, offset, spans);
613 }
614 Call::StaticMethod(static_call) => {
615 collect_spans_from_expression(static_call.class, offset, spans);

Calls 9

push_if_containsFunction · 0.85
push_paren_pairFunction · 0.85
push_blockFunction · 0.85
push_brace_pairFunction · 0.85
iterMethod · 0.80

Tested by

no test coverage detected