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

Function php_concat_parts

codegraph-kernel/src/php.rs:1702–1720  ·  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

1700/// expressions — or None when a link of its left spine lacks a side or
1701/// isn't a `.`. Walked iteratively.
1702fn php_concat_parts<'a>(expr: Node<'a>, src: &str) -> Option<Vec<Node<'a>>> {
1703 let mut parts: Vec<Node<'a>> = Vec::new();
1704 let mut cur = expr;
1705 loop {
1706 let left = cur.child_by_field_name("left")?;
1707 let right = cur.child_by_field_name("right")?;
1708 if cur.child_by_field_name("operator").is_some_and(|op| &src[op.byte_range()] != ".") {
1709 return None;
1710 }
1711 parts.push(right);
1712 if left.kind() != "binary_expression" {
1713 parts.push(left);
1714 break;
1715 }
1716 cur = left;
1717 }
1718 parts.reverse();
1719 Some(parts)
1720}
1721
1722/// One `namespace_use_declaration`'s part of phpShadowsDirname (#3298): its
1723/// 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