But this is matching all classes with a @Controller decorator, even those that also have a @RequireRole decorator.
Any help would be really appreciated!
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Your code works for me for simple examples. Can you provide a code example that exhibits the problem?
\nOne thing to watch out for: toString is abbreviated for AST nodes that would naturally consume more than 20 characters, so e.g. @RequireRole(\"Looooong\") might turn into \"@Requir ... ooong)\". If that's the problem, you may need to use getADecorator().getExpression().(InvokeExpr).getCalleeName() or similar (depending on the exact nature of the decorator) to extract the decorator's full function name.
-
|
Hi everyone, I was testing a NestJS codebase which uses a lot of different decorators to implement some logic. In particular, I wanted to build a query to get all classes with a My attempt was to do something like this: But this is matching all classes with a Any help would be really appreciated! |
Beta Was this translation helpful? Give feedback.
-
|
Your code works for me for simple examples. Can you provide a code example that exhibits the problem? One thing to watch out for: |
Beta Was this translation helpful? Give feedback.
Your code works for me for simple examples. Can you provide a code example that exhibits the problem?
One thing to watch out for:
toStringis abbreviated for AST nodes that would naturally consume more than 20 characters, so e.g.@RequireRole("Looooong")might turn into"@Requir ... ooong)". If that's the problem, you may need to usegetADecorator().getExpression().(InvokeExpr).getCalleeName()or similar (depending on the exact nature of the decorator) to extract the decorator's full function name.