Hi all!
I need to ask what the correct approach is to analyze an anonymous class? In
my Visitor (that extends SourceVisitor), I noticed that the result from
x.getTypeDeclarationCount() (where x is of type TypeDeclaration) does not
reflect any anomyous class whereas the result from x.getTypeDeclarationCount()
(where x is of type New) does.
So in visitNew() I test if x.getTypeDeclarationCount() is > 0 and if so I
conclude that 'new' preceeds an anonymous class. In contrast, if
x.getTypeDeclarationCount() is == 0, I conclude that 'new' preceeds a
reference to a constructor. Is this approach correct or is there any better
way?
Thanks for any hints and comments!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
this approach works. Alternatively, anonymous classes do not have names, i.e.,
getName() returns null for ClassDeclarations that depict anonymous classes.
Regards,
Tobias
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all!
I need to ask what the correct approach is to analyze an anonymous class? In
my Visitor (that extends SourceVisitor), I noticed that the result from
x.getTypeDeclarationCount() (where x is of type TypeDeclaration) does not
reflect any anomyous class whereas the result from x.getTypeDeclarationCount()
(where x is of type New) does.
So in visitNew() I test if x.getTypeDeclarationCount() is > 0 and if so I
conclude that 'new' preceeds an anonymous class. In contrast, if
x.getTypeDeclarationCount() is == 0, I conclude that 'new' preceeds a
reference to a constructor. Is this approach correct or is there any better
way?
Thanks for any hints and comments!
Hej,
this approach works. Alternatively, anonymous classes do not have names, i.e.,
getName() returns null for ClassDeclarations that depict anonymous classes.
Regards,
Tobias