Debugging Pointcuts

Currently the pointcut evaluation follows the order of the primitive pointcuts in the advices/introductions pointcut designator. This may change in the future for optimization reasons, but by now it enables a simple debugging pointcut which is also evaluated at its usage position.

This is helpful if the reason for (missing) logic-meta variable bindings are not clear in a certain pointcut.

Consider the following mock aspect (see the examples page for details on the MockAspect). To check which bindings are achieved by which line two debug pointcuts have been added. The syntax is the following

debug("name" ,?lmv1,...)

meaning the first argument is a name followed by an arbitrary number of logic meta-variables.

public aspect MockAspect {
  ?Class around mock(?mock, ??args) :
      call(?Class.new(..)) &&
      concat(?Class, "Mock", ?mock) &&
      debug("mockClassName",?Class,?mock) &&
      class(?mock) &&
      debug("mockClassExists",?mock) &&
      args(??args)
  {
      return new ?mock(??args);
  }
}

To see the generated tracing results for the debug pointcut open the Prolog Console (via Prolog→Open Console). In the console select your project in via the Console Selector Icon drop down menu.

Type the following query in the console

  ?- logicaj_debug(_,AspectConstruct,'mockClassName',Variables).

    AspectConstruct = "aspects.MockAspect.advice:mock",
    Variables = ['html2wiki.parser.TokenMgrError', 'html2wiki.parser.TokenMgrErrorMock']

With semicolon (;) you may ask for the next result(s). You can abort the query with the a key. For the first debug point you will get a huge number of bindings since it will look up all classes in the system and concatenate “Mock” to it.

The second one is more interesting. For the LogicAJDemo project is should only retrieve two answers:

  ?- logicaj_debug(_,AspectConstruct,'mockClassExists',Variables).

     AspectConstruct = "aspects.MockAspect.advice:mock",
     Variables = ['wikiviewer.content.internal.ContentProviderMock'] ;

     AspectConstruct = "aspects.MockAspect.advice:mock",
     Variables = ['html2wiki.content.internal.ContentProviderMock'] ;

   No
Last modified: 2017/08/29 22:30
*