Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ajdt-dev] Re: [aspectj-users] Finding if a selected piece of code is being affected by an advice

The AJDT tests create AspectJ projects by importing existing projects.
But if you create a Java project instead, you could just call
AspectJUIPlugin.convertToAspectJProject().

Regards,

Matt.

On 04/05/07, Fernando Calheiros <xfernando@xxxxxxxxx> wrote:
Thanks Matt, I've managed to find out how to do what I wanted. I was
developing some unit tests to see if it was ok but
AJModel.getInstance().getAllRelationships keeps returning null when running
in the tests.

The tests were using a class that created a java project where all the
classes and aspects would be created, so I thought that it would need to be
an AspectJ project for it to work correctly, so I found AJTestProject
through Krugle, but it appears to be from an old version of AJDT, is there
any place I can find a class that creates an AspectJ to be used in unit
tests?


On 5/3/07, Matt Chapman <mpchapman@xxxxxxxxx> wrote:
> Hi Fernando,
>
> If you get the PointcutElement, you can cast it to ISourceReference
> then call getSource().
> But to keep JDT happy by default "Java-compatible" contents are
> returned, not the real contents. You have to request this from the
> containing AJCompilationUnit, by calling requestOriginalContentMode(),
> and then discardOriginalContentMode() afterwards.
>
> There is an example of this in the org.eclipse.ajdt.core plugin, in
> AspectRenameParticipant.java around line 206.
>
> Regards,
>
> Matt.
>
> On 02/05/07, Fernando Calheiros <xfernando@xxxxxxxxx> wrote:
> > Hey Matt, I checked the link you gave me and used AJModel to obtain the
> > information, but from what I see there's no way to obtain more
information
> > other than the type of advice (before, after, around), its return type
and
> > parameters from an AJRelationship, isn't there a way to obtain the
pointcuts
> > used in it?
> >
> > (What I really need is to check if a within or withincode was used in
the
> > advice pointcut expression that matched a piece of code that was
selected by
> > the user)
> >
> > Thanks in advance,
> > Fernando Calheiros
> >
> >
> > On 5/2/07, Matt Chapman <mpchapman@xxxxxxxxx> wrote:
> > > This is really a question for the ajdt-dev mailing list... I think
> > > it'd be easier to get the info you need directly from the AJModel
> > > class, as described here:
> > >
> > >
> >
http://wiki.eclipse.org/index.php/Developer%27s_guide_to_building_tools_on_top_of_AJDT_and_AspectJ#Obtaining_crosscutting_relationship_information_from_AJDT
> > >
> > > --Matt
> > >
> > > On 02/05/07, Fernando Calheiros < xfernando@xxxxxxxxx> wrote:
> > > > Hi everyone, I'm trying to get some information about whether a
piece of
> > > > method code selected from the user is being affected by an advice
and if
> > the
> > > > advice uses withincode.
> > > >
> > > > Since apparently most of this information is available in the
> > > > cross-references view, I thought AJDT's visualizer content provider
> > would be
> > > > the right place to look, and just as a test I tried the following
code:
> > > >
> > > >         AJXReferenceProvider provider = new AJXReferenceProvider();
> > > >
> > > >         LinkedList<AJRelationshipType> relations = new
> > > > LinkedList<AJRelationshipType>();
> > > >
> > > >         //adding all relationship types, just to see if anything is
> > returned
> > > >         AJRelationshipType[] types =
> > > > AJRelationshipManager.getAllRelationshipTypes();
> > > >         for (AJRelationshipType type : types) {
> > > >             relations.add(type);
> > > >         }
> > > >
> > > >         //refactoringInfo.getOrigin() returns the IFile for the
.java
> > class
> > > > open in the eclipse editor
> > > >         Collection references = provider.getXReferences(JavaCore
> > > >
.createCompilationUnitFrom(refactoringInfo.getOrigin()),
> > > >                 relations);
> > > >
> > > >         //print the references
> > > >         for (Object object : references) {
> > > >             IXReference reference = (IXReference) object;
> > > >
> > > >             System.out.println(reference.getName ());
> > > >         }
> > > >
> > > > The IFile passed as parameter to create the ICompilationUnit is
being
> > > > affected by advices and inter-type declarations, which are correctly
> > > > displayed in the cross-references view, but getXReferences is
returning
> > an
> > > > empty Collection, can anyone tell me what I'm doing wrong?
> > > >
> > > > Thanks in advance,
> > > > Fernando Calheiros
> > > >
> > > > _______________________________________________
> > > > aspectj-users mailing list
> > > > aspectj-users@xxxxxxxxxxx
> > > >
https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > >
> > > >
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > >
https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > >
> >
> >
>




Back to the top