]> source.dussan.org Git - aspectj.git/commitdiff
hopefully the last word on parameterizing pointcuts in all their various glorious...
authoracolyer <acolyer>
Thu, 24 Nov 2005 13:02:32 +0000 (13:02 +0000)
committeracolyer <acolyer>
Thu, 24 Nov 2005 13:02:32 +0000 (13:02 +0000)
weaver/src/org/aspectj/weaver/ResolvedPointcutDefinition.java
weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java

index cf3d5967ddbfa748005c9f225340fcd65a3462e8..4335957e16e63d9f2b47ee7d60019b10a4f0d013 100644 (file)
@@ -147,8 +147,8 @@ public class ResolvedPointcutDefinition extends ResolvedMemberImpl {
                ret.setSourceContext(getSourceContext());
                ret.setPosition(getStart(),getEnd());
                ret.setParameterNames(getParameterNames());
-               //return ret;
-               return this;
+               return ret;
+               //return this;
        }
        
        // for testing
index 2f2c965a4b6e6ca32abb98db441958a8e05417ff..f20223cb44fc8d130ed98c26781ee70739c1a987 100644 (file)
@@ -194,6 +194,7 @@ public class ReferencePointcut extends Pointcut {
                        return;
                }
                                
+               //if (onType == null) onType = pointcutDef.getDeclaringType();
                if (onType != null) {
                        if (onType.isParameterizedType()) {
                                // build a type map mapping type variable names in the generic type to
index d3e4cfff311486ef1ed5e2ce300bfbfdd86d3fd9..8313460bd20017134ac28bb81ced40ef8427a14c 100644 (file)
@@ -18,6 +18,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.Message;
@@ -532,8 +533,24 @@ public class WildTypePattern extends TypePattern {
        }               
 
        public TypePattern parameterizeWith(Map typeVariableMap) {
+               NamePattern[] newNamePatterns = new NamePattern[namePatterns.length];
+               for(int i=0; i<namePatterns.length;i++) { newNamePatterns[i] = namePatterns[i]; }
+               if (newNamePatterns.length == 1) {
+                       String simpleName = newNamePatterns[0].maybeGetSimpleName();
+                       if (simpleName != null) {
+                               if (typeVariableMap.containsKey(simpleName)) {
+                                       String newName = ((ReferenceType)typeVariableMap.get(simpleName)).getName().replace('$','.');
+                                       StringTokenizer strTok = new StringTokenizer(newName,".");
+                                       newNamePatterns = new NamePattern[strTok.countTokens()];
+                                       int index = 0;
+                                       while(strTok.hasMoreTokens()) {
+                                               newNamePatterns[index++] = new NamePattern(strTok.nextToken());
+                                       }
+                               }
+                       }
+               }
                WildTypePattern ret = new WildTypePattern(
-                               namePatterns,
+                               newNamePatterns,
                                includeSubtypes,
                                dim,
                                isVarArgs,