Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to get the pointcut from an AdviceElement ?

Also, this code might do it for you:

ISourceRange range = adviceElement.getSourceRange();
AJCompilationUnit unit = (AJCompilationUnit) adviceElement.getCompilationUnit();
unit.requestOriginalContentMode();  // get actual AJ contents of file
(transformed Java-like syntax)
String contents = new String (unit.getContents());
unit.discardOriginalContentMode();  // return to transformed Java-like syntax
String advice = contents.substring(range.getOffset(),
range.getOffset()+range.getLength());
String pcd = advice.substring(advice.indexOf(':'+1), advice.indexOf('{'));


On Fri, Feb 6, 2009 at 12:09 PM, Andrew Eisenberg <andrew@xxxxxxxxxxxx> wrote:
> Yes, please create a feature request.
>
> On Fri, Feb 6, 2009 at 9:41 AM, Johan Fabry <jfabry@xxxxxxxxxxxxx> wrote:
>> :-(
>>
>> That code is not going to be very clean. Should this info not be available
>> in the AdviceElement? Would it make sense for me to add a feature request to
>> bugzilla?
>>
>> On 06 Feb 2009, at 14:22, Andrew Eisenberg wrote:
>>
>>> Unfortunately, this has not been implemented directly.  I think the
>>> best that you can do is locate the start and end points for the advice
>>> declaration in the text and extract directly from the text.
>>
>> --
>> Johan Fabry
>> jfabry@xxxxxxxxxxxxx - http://dcc.uchile.cl/~jfabry
>> PLEIAD Lab - Computer Science Department (DCC) - University of Chile
>>
>>
>>
>>
>


Back to the top