(content: &'a [u8], i: &mut usize)
| 1683 | /// anonymous class expressions (`new class extends Foo {}`). |
| 1684 | #[inline] |
| 1685 | fn read_name<'a>(content: &'a [u8], i: &mut usize) -> Option<&'a str> { |
| 1686 | let len = content.len(); |
| 1687 | |
| 1688 | // Skip whitespace |
| 1689 | while *i < len && content[*i].is_ascii_whitespace() { |
| 1690 | *i += 1; |
| 1691 | } |
| 1692 | |
| 1693 | let start = *i; |
| 1694 | |
| 1695 | // Read identifier characters |
| 1696 | while *i < len { |
| 1697 | let c = content[*i]; |
| 1698 | if c.is_ascii_alphanumeric() || c == b'_' { |
| 1699 | *i += 1; |
| 1700 | } else { |
| 1701 | break; |
| 1702 | } |
| 1703 | } |
| 1704 | |
| 1705 | if *i == start { |
| 1706 | return None; |
| 1707 | } |
| 1708 | |
| 1709 | let name = &content[start..*i]; |
| 1710 | |
| 1711 | // Skip keywords that appear in anonymous class expressions |
| 1712 | if name == b"extends" || name == b"implements" { |
| 1713 | return None; |
| 1714 | } |
| 1715 | |
| 1716 | std::str::from_utf8(name).ok() |
| 1717 | } |
| 1718 | |
| 1719 | /// Normalise a PSR-4 prefix: ensure it ends with `\`. |
| 1720 | fn normalise_prefix(prefix: &str) -> String { |
no outgoing calls
no test coverage detected