mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-18 13:53:01 +08:00
fix(js,ts): find a store exported by an export { } list when its name starts or ends with $ (#2384)
TreeSitterExtractor.isExportedLater and its kernel mirror is_exported_later
bounded the name in the `export { ... }` branch with `\b`, which takes a `$`
for a separator. It never fires beside a leading or trailing `$`, so
`const items$ = create(...)` + `export { items$ };` (or `export { $items as
default };` for a `$items` store) never matched, and the store's actions
were not extracted on either engine. It also matched inside a longer name:
`export { useStore$ }` or `export { $useStore }` counted as exporting a
store named `useStore`.
The clause branch now bounds the name with a character that can't continue
an identifier. The regex crate has no look-around, so the bounds consume,
and both sides spell the class in ASCII, since the crate's `\w` is Unicode
while JS's is ASCII. Plain names decide as before apart from the two false
positives. A non-ASCII letter written against the name (`export {
éuseStore }`) used to split the engines (the kernel's Unicode `\b` said not
exported, the wasm path exported); both now give the wasm answer.
Adds kernel/wasm parity cases (ts/tsx/js/jsx) inside 'a store exported by a
later statement', and the same cases in store-exported-later.test.ts, for
`items$`, `$items as default` and both false-positive shapes. They fail with
the unfixed kernel and with the unfixed TS on the wasm path, and pass with
both fixes.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -366,8 +366,12 @@ impl<'t> Walker<'t> {
|
||||
// `R` (CRLF mode): JS's multiline `^`/`$` treat `\r` as a line end as
|
||||
// well as `\n`; `(?m)` alone sees only `\n`, and would miss `export
|
||||
// default NAME;\r\n` on every Windows autocrlf checkout.
|
||||
// Inside `{ … }` the name is bounded by a character that can't
|
||||
// continue an identifier, not by `\b`, which takes a `$` for a
|
||||
// separator. The crate has no look-around, so the bounds consume.
|
||||
// ASCII classes, not `\w`: this crate's `\w` is Unicode, JS's is not.
|
||||
let pattern = format!(
|
||||
r"(?mR)^[ \t]*export\s+(?:default\s+{n}\s*;?[ \t]*$|\{{[^}}]*\b{n}\b[^}}]*\}})",
|
||||
r"(?mR)^[ \t]*export\s+(?:default\s+{n}\s*;?[ \t]*$|\{{(?:[^}}]*[^0-9A-Za-z_$}}])?{n}(?:[^0-9A-Za-z_$}}][^}}]*)?\}})",
|
||||
n = n
|
||||
);
|
||||
match regex::Regex::new(&pattern) {
|
||||
|
||||
Reference in New Issue
Block a user