feat: Match more class declarations for export alias check#37
Merged
AbhiPrasad merged 2 commits intomainfrom Mar 3, 2026
Merged
feat: Match more class declarations for export alias check#37AbhiPrasad merged 2 commits intomainfrom
AbhiPrasad merged 2 commits intomainfrom
Conversation
052c33b to
4261845
Compare
timfish
approved these changes
Feb 27, 2026
Contributor
timfish
left a comment
There was a problem hiding this comment.
Looks good!
There are a couple of clippy format/style failures in CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/adkinstrumentation.AI Summary
Key changes in
src/instrumentation.rs:Support for
var/let/constclass expressions — When a class is assigned to a variable (e.g.,var X = class { ... }orvar 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 setsis_correct_classdirectly using the variable name instead.Support for assignment-based class expressions — Same logic extended to assignment expressions like
X = class { ... }.Prevent overriding
is_correct_classinvisit_mut_class_expr— Ifis_correct_classwas already set byvisit_mut_var_decl(forvar X = class Y {}patterns),visit_mut_class_exprno longer overwrites it.Tests added:
4 new test cases covering
const,let,var, and named-class-in-varexport alias patterns (each withmod.mjs,mod.rs, andtest.mjsfiles).