A top-level binding exported by a LATER statement rather than at its declaration: `export default NAME`, `export { NAME }`, `export { NAME as default }`. The declaration's own `is_exported` (an `export_statement` ancestor) cannot see these. One anchored regex over the file source. Mirrors TreeSitterExtractor.isExportedLater.
(&self, name: &str)
| 612 | /// ancestor) cannot see these. One anchored regex over the file source. |
| 613 | /// Mirrors TreeSitterExtractor.isExportedLater. |
| 614 | pub(super) fn is_exported_later(&self, name: &str) -> bool { |
| 615 | if name.is_empty() |
| 616 | || !name.chars().next().map(|c| c.is_ascii_alphabetic() || c == '_' || c == '$').unwrap_or(false) |
| 617 | || !name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '$') |
| 618 | { |
| 619 | return false; |
| 620 | } |
| 621 | let n = regex::escape(name); |
| 622 | // `R` (CRLF mode): JS's multiline `^`/`$` treat `\r` as a line end as |
| 623 | // well as `\n`; `(?m)` alone sees only `\n`, and would miss `export |
| 624 | // default NAME;\r\n` on every Windows autocrlf checkout. |
| 625 | // Inside `{ … }` the name is bounded by a character that can't |
| 626 | // continue an identifier, not by `\b`, which takes a `$` for a |
| 627 | // separator. The crate has no look-around, so the bounds consume. |
| 628 | // ASCII classes, not `\w`: this crate's `\w` is Unicode, JS's is not. |
| 629 | let pattern = format!( |
| 630 | r"(?mR)^[ \t]*export\s+(?:default\s+{n}\s*;?[ \t]*$|\{{(?:[^}}]*[^0-9A-Za-z_$}}])?{n}(?:[^0-9A-Za-z_$}}][^}}]*)?\}})", |
| 631 | n = n |
| 632 | ); |
| 633 | match regex::Regex::new(&pattern) { |
| 634 | Ok(re) => re.is_match(self.src), |
| 635 | Err(_) => false, |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | /// Returns the initializers it walked under the symbol they declare — a |
| 640 | /// constant's or a variable's (#693), a component wrapper's — whose fn-ref |
no test coverage detected