Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Declare error on missing advice

I'm afraid I don't think you can do that.  You could possibly process
the weaving messages with your own message handler (not too tough) -
but it probably wouldn't be very pretty.  If you could design a nice
syntax, we could have an enhancement request, but I don't see this
coming up very often so it wouldn't be high on the priority list I'm
afraid.

Hmmm, maybe you could do something with an annotation - just thinking
out loud here (and only if your 'defined to be undoable' locations are
execution join points)

aspect Undo {
 ...
}

aspect MissingUndoDetector {
  declare warning: undoable() && !execution(@Undoable * *(..)): "You
need to think about Undo here, go see the Undo aspect";
}

On compiling with that aspect, if they haven't thought about undo, it
will fire, forcing them to go see the aspect.  Where they write some
advice on the new location that should be affected, *and* a declare
@method to tag the site indicating they have thought about it:

  // tag it to indicate we've thought about Undo here
  declare @method: * ThatType.someMethod(..): @Undoable;
  before(): execution(* ThatType.someMethod(..)) {
     ... undo support...
  }

they could cheat the system by declaring @Undoable when writing their
code, but I think if they forget to implement Undo support, they are
likely to forget the annotation too...

Andy

On 5 March 2010 14:40, remiller <remiller@xxxxxxxxxxx> wrote:
>
> Hi,
>
> I need to make a pointcut that matches locations that do not have advice
> applied to them.
>
> Some context: I'm working on a large software system for simplifying game
> scripting for non-programmers ( http://www.cs.ualberta.ca/~script ). Since
> it's designed to be used as a development tool, we need an undo/redo system.
>
> I'm trying to use AspectJ to implement that undo system. I've got some
> pointcuts that locate state-changing methods, and the advice is the undo
> logic. That all works fine.
>
> What I wanted to do was enforce style guidelines by using the "declare
> error/warning" statements that force programmers to implement undo advice
> when they write new state-changing methods. To put it to code, what I want
> is something along the lines of:
>
> declare error: undefinedModification():  "Undo Aspect: Method in
> undo-sensitive class does not have an undo operation defined in Undo.aj.";
>
> where undefinedModification is a pointcut that matches all locations that
> are:
> 1. defined to be undoable by the convention I'm enforcing
> 2. does not already have advice from the Undo aspect applied to it.
>
> So far, I haven't found any truly similar situations in the mailing list
> archives. I have found a feature request
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=292264) which asks for the
> ability to use Type Patterns in declare statements, but I don't know if that
> would solve my issue or not.
>
> So, to make a very long post short: Can I make a pointcut that matches
> locations that do not have advice applied to them? Is this beyond the
> capabilities of AspectJ? If so, then will it ever be possible?
>
> Ordinarily I wouldn't try so hard to get this semantic enforced, but since
> this software has its primary developer change every 16 months
> (undergraduate internships) such restrictions gain incredible value. I think
> I can set up a more kludgy solution where it throws a runtime exception, but
> we all know it's better to be compile-time when possible.
>
> - Robin Miller
> ScriptEase IIP Programmer Analyst
> --
> View this message in context: http://old.nabble.com/Declare-error-on-missing-advice-tp27797268p27797268.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top