Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ajdt-dev] Getting all aspects in the project

Hi Irum,

 

The reason that you don’t see any crosscutting references for the pointcut is that in the AspectJ tools’ structure model pointcuts alone don’t affect the join point shadows.  Advice does.  So if you wrote an advice that used that pointcut a() in the structure model you would see the join point shadow matched by a(), i.e. all the calls to Class1 methods. 

 

Pointcuts alone don’t have a behavioral effect on the system, which is why the links for them don’t show up in the model.  This is not to say that there aren’t uses for that structure, e.g. a tool to help the programmer fine-tune a pointcut before writing advice.  Just to say that the current AspectJ structure model only shows the primary crosscutting structure of advice and the points it affects.

 

Out of curiosity: what are you using the structure model for?

 

Mik

 


From: ajdt-dev-admin@xxxxxxxxxxx [mailto:ajdt-dev-admin@xxxxxxxxxxx] On Behalf Of Irum Godil
Sent: Friday, June 25, 2004 9:55 AM
To: ajdt-dev@xxxxxxxxxxx
Subject: Re: [ajdt-dev] Getting all aspects in the project

 

Thanks for this. I tried using this code, however, following is my aspect:

public aspect Aspect1 {

pointcut a() : call(* pack.Class1.*());

}

 

Inside my program I want access to the pattern defined by the pointcut a() i.e. I want (* pack.Class1.*()). How do I get that? When I traverse through the IProgramElement, I only get the part "pointcut a()" and nothing after it.

 

thanks.

Andrew Clement <CLEMAS@xxxxxxxxxx> wrote:


Accessing the data through the visualiser is certainly one option but perhaps not the best way.

The key thing you need to know is that there is one structure model per project and there is
only one active structure model at any one time.  So if you are working in project A, you
cannot ask information about the structure model of project B.  Perhaps the better way for
you to access the data you need is by walking the hierarchy of IProgramElement nodes
that make up all the code for a particular project.

You can obtain the programElement hierarchy by making this call:

        AsmManager.getDefault().getHierarchy().getRoot()

That gives you a root IProgramElement that represents the .lst file that was used to compile
the project.  You can then walk down the hierarchy using getKind() to check what each node
is and getChildren() to navigate to the next level.  The kind of a node is of type IProgramElement.Kind
and all the kinds you need are defined POINTCUT, ASPECT, ADVICE.

There is a way to force it to switch to the structure model for a different project, other
than causing it to happen through the UI, but I can't quite remember what that is
without looking at the code.

Andy.



Irum Godil <softwarengineer2003@xxxxxxxxx>
Sent by: ajdt-dev-admin@xxxxxxxxxxx

25/06/2004 16:39

Please respond to
ajdt-dev

To

ajdt-dev@xxxxxxxxxxx

cc

 

Subject

[ajdt-dev] Getting all aspects in the project

 

 

 




Hi,
I am working on adding some features to the ajdt code base. For that, I want a list of all the aspects in the selected project with the pointcuts and warnings declared in each aspect. I tried using the following code:
 

AspectVisualiserPlugin plugin = AspectVisualiserPlugin.getDefault();

IJavaProject proj = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("newProj"));

Set set = plugin.getAllAspects(proj);

However, the above set is always empty. Can someone please tell me why is this set always empty. I tried to understand the code for StructureModelUtil's method:

public static Map getLinesToAspectMap(String sourceFilePath,boolean needIndividualNodes)

but I am not sure what is it doing.

Can someone please tell me how can I get all aspects of a project listed out, and which API to use for that purpose.

Thanks.


Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!


Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!


Back to the top