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

Method is_exported_later

codegraph-kernel/src/tsjs/extractors.rs:710–733  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

708 /// ancestor) cannot see these. One anchored regex over the file source.
709 /// Mirrors TreeSitterExtractor.isExportedLater.
710 pub(super) fn is_exported_later(&self, name: &str) -> bool {
711 if name.is_empty()
712 || !name.chars().next().map(|c| c.is_ascii_alphabetic() || c == '_' || c == '$').unwrap_or(false)
713 || !name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '$')
714 {
715 return false;
716 }
717 let n = regex::escape(name);
718 // `R` (CRLF mode): JS's multiline `^`/`$` treat `\r` as a line end as
719 // well as `\n`; `(?m)` alone sees only `\n`, and would miss `export
720 // default NAME;\r\n` on every Windows autocrlf checkout.
721 // Inside `{ … }` the name is bounded by a character that can't
722 // continue an identifier, not by `\b`, which takes a `$` for a
723 // separator. The crate has no look-around, so the bounds consume.
724 // ASCII classes, not `\w`: this crate's `\w` is Unicode, JS's is not.
725 let pattern = format!(
726 r"(?mR)^[ \t]*export\s+(?:default\s+{n}\s*;?[ \t]*$|\{{(?:[^}}]*[^0-9A-Za-z_$}}])?{n}(?:[^0-9A-Za-z_$}}][^}}]*)?\}})",
727 n = n
728 );
729 match regex::Regex::new(&pattern) {
730 Ok(re) => re.is_match(self.src),
731 Err(_) => false,
732 }
733 }
734
735 /// Returns the initializers it walked under the symbol they declare — a
736 /// constant's or a variable's (#693), a component wrapper's — whose fn-ref

Callers 1

extract_variableMethod · 0.80

Calls 4

escapeFunction · 0.85
mapMethod · 0.80
nextMethod · 0.80
allMethod · 0.65

Tested by

no test coverage detected