feat(semantics): collect symbols used for function / class names#9872
feat(semantics): collect symbols used for function / class names#9872sapphi-red wants to merge 1 commit intomainfrom
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #9872 will not alter performanceComparing Summary
|
|
My concern about this change is that this is more semantic data that we need to keep in sync with AST changes in transformer. That's quite a struggle already! Is this necessary to achieve the |
It isn't necessary; the other option I can think of is to check the parent node in the mangler by calling |
|
i think diff --git a/crates/oxc_mangler/src/lib.rs b/crates/oxc_mangler/src/lib.rs
index d43bea1b8..adb8a087e 100644
--- a/crates/oxc_mangler/src/lib.rs
+++ b/crates/oxc_mangler/src/lib.rs
@@ -388,6 +388,14 @@ impl Mangler {
if is_special_name(scoping.symbol_name(symbol_id)) {
continue;
}
+
+ let symbol_flags: oxc_semantic::SymbolFlags = scoping.symbol_flags(symbol_id);
+
+ if self.options.keep_names.function && symbol_flags.is_function()
+ || self.options.keep_names.class && symbol_flags.is_class()
+ {
+ continue;
+ }
let index = slot;
frequencies[index].slot = slot;
frequencies[index].frequency += scoping.get_resolved_reference_ids(symbol_id).len();
should work iirc, i tried this a very long time ago and that diff seemed to have the desired effect |
I think it does not work because |
On second thought, this sounds better. Also found this code which does a similar thing. oxc/crates/oxc_linter/src/rules/eslint/func_names.rs Lines 170 to 225 in ecdfe2e |

Collect symbols that are used for function / class names so that we can use this information in the mangler.