MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / php_concat_parts

Function php_concat_parts

codegraph-kernel/src/php.rs:1670–1688  ·  view source on GitHub ↗

phpConcatParts (languages/php.ts): the parts of a `.` concatenation, left to right — `__DIR__ . '/inc/' . 'a.php'` is a left-nested tree of binary expressions — or None when a link of its left spine lacks a side or isn't a `.`. Walked iteratively.

(expr: Node<'a>, src: &str)

Source from the content-addressed store, hash-verified

1668/// expressions — or None when a link of its left spine lacks a side or
1669/// isn't a `.`. Walked iteratively.
1670fn php_concat_parts<'a>(expr: Node<'a>, src: &str) -> Option<Vec<Node<'a>>> {
1671 let mut parts: Vec<Node<'a>> = Vec::new();
1672 let mut cur = expr;
1673 loop {
1674 let left = cur.child_by_field_name("left")?;
1675 let right = cur.child_by_field_name("right")?;
1676 if cur.child_by_field_name("operator").is_some_and(|op| &src[op.byte_range()] != ".") {
1677 return None;
1678 }
1679 parts.push(right);
1680 if left.kind() != "binary_expression" {
1681 parts.push(left);
1682 break;
1683 }
1684 cur = left;
1685 }
1686 parts.reverse();
1687 Some(parts)
1688}
1689
1690/// One `namespace_use_declaration`'s part of phpShadowsDirname (#3298): its
1691/// text with JS whitespace runs collapsed to one space, the space beside

Callers 1

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected