[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] DOMs and ASTs (for metrics tool purpose)

On Thu, Mar 31, 2005 at 09:02:36AM -0800, Mik Kersten wrote:

> Nice work on figuring this out and stating your needs clearly--all of your
> conclusions are correct.  While the ASM may be a convenient way of getting
> some of your metrics, you'll need to tie into the AST visitor mechanism to
> get finer-grained information.  You can do that in the exact same way that
> the ASM does, by extending the AsmHierarchyBuilder which is a subclass of
> the ASTVisitor that we get from the JDT.  For any additional information
> that you need to collect you simply add the corresponding visit(..) method.
> For example, to collect method calls you could do the following:
> class ExtendedAsmHiearchyBuilder extends AsmHierarchyBuilder {
>     public boolean visit(MessageSend messageSend, BlockScope scope) {
> 	  // do something interesting with calls...
>     }
>     public void endVisit(MessageSend messageSend, BlockScope scope) {
>         stack.pop();
>     } 
> }
> And register your custom builder by overriding the default one: 
> AjBuildManager.setAsmHierarchyBuilder(new ExtendedAsmHierarchyBuilder());
> I've put an example test into org.aspectj/docs/sandbox/api-clients which you
> should check out as a project.  If you run
> org.aspectj.samples.AsmHierarchyBuilderExtensionTest as a JUnit test you'll
> notice that it outputs information about call sites.  

Thank you for the reply. At the moment I extracted the test case to
own project and manage to run it without all depended ajdt projects.
And it works! :)  I think this will do the work.  Thank you, again.

> Happy hacking,

:)  ...   

btw. Will ajdt be integrated with jdt java models? Many plugins
 works on it. Having ajdt extension, with small efforts those plugins
 could be extended for AspectJ support...

best regards,
Michal Stochmialek <misto@xxxxxxxxxxxxxxxx>