Skip to content

feat: Match more class declarations for export alias check#37

Merged
AbhiPrasad merged 2 commits intomainfrom
abhi-match-more-class-method-export-alias
Mar 3, 2026
Merged

feat: Match more class declarations for export alias check#37
AbhiPrasad merged 2 commits intomainfrom
abhi-match-more-class-method-export-alias

Conversation

@AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Feb 27, 2026

In #29 I added support for export alias matching, allowing for orchestrion to instrument minified classes/functions as long as they were exported with a proper name.

This PR matches more class declarations for the export alias check, which was needed for the @google/adk instrumentation.

AI Summary

Key changes in src/instrumentation.rs:

  1. Support for var/let/const class expressions — When a class is assigned to a variable (e.g., var X = class { ... } or var X = class Y { ... }), the instrumentor now propagates the variable name to the class expression so it can be matched for tracing. For named class expressions (class Y), it sets is_correct_class directly using the variable name instead.

  2. Support for assignment-based class expressions — Same logic extended to assignment expressions like X = class { ... }.

  3. Prevent overriding is_correct_class in visit_mut_class_expr — If is_correct_class was already set by visit_mut_var_decl (for var X = class Y {} patterns), visit_mut_class_expr no longer overwrites it.

Tests added:

4 new test cases covering const, let, var, and named-class-in-var export alias patterns (each with mod.mjs, mod.rs, and test.mjs files).

@AbhiPrasad AbhiPrasad self-assigned this Feb 27, 2026
@AbhiPrasad AbhiPrasad force-pushed the abhi-match-more-class-method-export-alias branch from 052c33b to 4261845 Compare February 27, 2026 17:42
Copy link
Contributor

@timfish timfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

There are a couple of clippy format/style failures in CI.

@AbhiPrasad AbhiPrasad merged commit 804a9c6 into main Mar 3, 2026
1 check passed
@jsumners-nr jsumners-nr deleted the abhi-match-more-class-method-export-alias branch March 3, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants