Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ajdt-dev] Porting plug-in for jdt to ajdt

Hi Juergen,

In order to analyze AspectJ projects in this way, you need to be aware of
three separate layers that handle AspectJ structure:

1) Extended JDT compiler (org.aspectj.org.eclipse.jdt.. and
org.aspectj.ajdt..).  This is our *copy* of the jdt.core compiler, AST, and
parser.

2) Abstract Structure Model (org.aspectj.asm) API.  This provides the entire
containment hierarchy and crosscutting structure for the last-built project.

3) AJDT (org.eclipse.ajdt).  This provides some IJavaElement-compatible
classes for working with AspectJ elements
(org.eclipse.ajdt.core.javaelements).

Since (3) is analogous to JDT, ideally you would only ever care about that.
But the integration of AspectJ structure into the JavaCore model is not done
yet.  So things like JavaCore, JavaModelUtil and SearchUtils do not work
completely for AspectJ code, and will likely require AspectJ-aware
counterparts.  This means that you probably need to get some of the
structure you're after from (2) and (3).  Try to use (2) where possible
since it's currently the only thing considered API.  I've attached a message
that describes how to plug into the compiler (1) if you need to do that.

Cheers,

Mik

> -----Original Message-----
> From: ajdt-dev-bounces@xxxxxxxxxxx [mailto:ajdt-dev-bounces@xxxxxxxxxxx]
> On Behalf Of Juergen Graf
> Sent: Tuesday, May 24, 2005 2:06 AM
> To: Ajdt developer discussions
> Subject: [ajdt-dev] Porting plug-in for jdt to ajdt
> 
> Hi all,
> 
> at first I want to thank you for beeing very supportive to me. Now I
> could use some help again ;).
> 
> My current task is to port a plug-in that has been written for the
> analyzation of java projects (using jdt) to support and analyze AspectJ
> projects. Thus I guess I've got to use ajdt ;).
> 
> I simply started by using org.aspectj.org.eclipse.jdt.* classes
> everywhere org.eclipse.jdt.* has been used before (Hopefully that step
> has been right!?). As you may imagine I crashed into some classes and
> methods of jdt I couldn't find the equivalent class in Ajdt. As there are:
> 
> org.eclipse.jdt.launching.JavaRuntime[.resolveRuntimeClasspathEntry(..)]
> org.eclipse.jdt.internal.corext.util.JavaModelUtil
> org.eclipse.jdt.internal.corext.util.SearchUtils
> 
> Are there classes that may be used as substitution for those and how
> should I try to find them?
> Is there any documentation availiabe for porting plug-ins from jdt to
> ajdt?
> Have I done something completly stupid/wrong?
> 
> Regards,
> Juergen
> 
> _______________________________________________
> ajdt-dev mailing list
> ajdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
--- Begin Message ---
  • From: "Mik Kersten" <beatmik@xxxxxxx>
  • Date: Thu, 31 Mar 2005 10:02:36 -0700
  • Thread-index: AcU1z6CrSEUOIG5JSYGLbABGl0ypzQAQPoiw
Title: RE: [aspectj-dev] DOMs and ASTs (for metrics tool purpose)

Hi MichaƂ,

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. 

Happy hacking,

Mik

> -----Original Message-----
> From: aspectj-dev-bounces@xxxxxxxxxxx [mailto:aspectj-dev-
> bounces@xxxxxxxxxxx] On Behalf Of Michal Stochmialek
> Sent: Thursday, March 31, 2005 12:56 AM
> To: aspectj-dev@xxxxxxxxxxx
> Subject: [aspectj-dev] DOMs and ASTs (for metrics tool purpose)
>
> Hello,
>
> I'm on planning stage of development of metrics suite for aspectj
> programs. The suite will be consisted mainly of CK metrics.
> I've following requirements:
>  - suite should measure java and aj files
>  - suite should be aware of java5 new language constructs
>  - tool should be run from console (ant) without *running*
>    eclipse
>
>
> I would like to use AspectJ for this manner and I started
> look into AspectJ's source models and syntax trees.
>
> JDT provides DOM for this kind of purposes, but after a while I
> find out, that AspectJ don't inherit it, and even modified JDT
> version will reject .aj files.
>
> After digging a while in mail archives, I found out that AJDT
> provides ASM model for similar proposes. I found examples for it, and
> it looks quite nice, but... it can reach only to method/advice level.
> For computing method complexity or detecting aspect-object coupling
> this is not enough :|
>
> At the end, I looked at AJDT ASTs, which inherit JDT ASTs. From
> developer docs (btw. a good one) I know that it provides statement
> level, so its granulity is that what I need.
>
> Do you think AST will be good for my purposes?
> Where can I get some examples how to obtain AST for a file?
>
>
> best regards,
> --
> Michal Stochmialek <misto@xxxxxxxxxxxxxxxx>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev


--- End Message ---

Back to the top