public Object visit(ASTArgParameter node, Object data) {
//TODO we are not doing any hierarchical test when the arg is bound
// => args(e) and before(Exception e) will not mathch on catch(SubException e) ..
// is that required ? how AJ syntax behaves ?
TypePattern typePattern = node.getTypePattern();
TypePattern realPattern = typePattern;
// check if the arg is in the pointcut signature. In such a case, use the declared type
//TODO can we improve that with a lazy attach of the realTypePattern to the node
// and a method that always return the real pattern
// It must be lazy since args are not added at info ctor time [can be refactored..]
// do some filtering first to avoid unnecessary map lookup
int pointcutArgIndex = -1;
if (typePattern.getPattern().indexOf(".") < 0) {
String boundedType = m_expressionInfo.getArgumentType(typePattern.getPattern());
if (boundedType != null) {
pointcutArgIndex = m_expressionInfo.getArgumentIndex(typePattern.getPattern());
realPattern = TypePattern.compileTypePattern(boundedType, SubtypePatternType.NOT_HIERARCHICAL);
}
}
// grab parameter from context
ExpressionContext ctx = (ExpressionContext) data;
ClassInfo argInfo = null;
try {
if (ctx.getReflectionInfo() instanceof MethodInfo) {
argInfo = ((MethodInfo) ctx.getReflectionInfo()).getParameterTypes()[ctx.getCurrentTargetArgsIndex()];
} else if (ctx.getReflectionInfo() instanceof ConstructorInfo) {
argInfo = ((ConstructorInfo) ctx.getReflectionInfo()).getParameterTypes()[ctx
.getCurrentTargetArgsIndex()];
} else if (ctx.getReflectionInfo() instanceof FieldInfo) {
argInfo = ((FieldInfo) ctx.getReflectionInfo()).getType();
} else if (ctx.getPointcutType().equals(PointcutType.HANDLER) && ctx.getReflectionInfo() instanceof ClassInfo) {
argInfo = (ClassInfo) ctx.getReflectionInfo();
}
} catch (ArrayIndexOutOfBoundsException e) {
// ExpressionContext args are exhausted
return Boolean.FALSE;
}
if (realPattern.matchType(argInfo)) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
}