]> source.dussan.org Git - aspectj.git/commitdiff
helens changes for 125295 - should keep AJDT happy.
authoraclement <aclement>
Thu, 26 Jan 2006 15:32:48 +0000 (15:32 +0000)
committeraclement <aclement>
Thu, 26 Jan 2006 15:32:48 +0000 (15:32 +0000)
asm/src/org/aspectj/asm/IProgramElement.java
asm/src/org/aspectj/asm/internal/ProgramElement.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
tests/bugs151/pr125295/pkg/A.aj [new file with mode: 0644]
tests/bugs151/pr125295/pkg/C.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java
tests/src/org/aspectj/systemtest/ajc151/ajc151.xml

index 8223c176bd28dae45a2ce646ebcb82bbdb05ac03..b7ef7e27f42fe94c5bd9f8877c5aab9ad7903ad7 100644 (file)
@@ -79,6 +79,7 @@ public interface IProgramElement extends Serializable {
        public String getCorrespondingType(boolean getFullyQualifiedType);
        
        public String toSignatureString();
+       public String toSignatureString(boolean getFullyQualifiedArgTypes);
        
        public void setRunnable(boolean value);
        public boolean isRunnable();
@@ -107,11 +108,13 @@ public interface IProgramElement extends Serializable {
         * Includes information about the origin of the node.
         */
        public String toLinkLabelString();
+       public String toLinkLabelString(boolean getFullyQualifiedArgTypes);
 
        /**
         * Includes name, parameter types (if any) and details (if any).
         */
        public String toLabelString();
+       public String toLabelString(boolean getFullyQualifiedArgTypes);
 
        public List getParameterTypes();
        public void setParameterTypes(List list);
index 0c7c8683cdbe698122388341ee42d06a04590838..a523b749719ec94017f99ba8a668875d9afbe7ed 100644 (file)
@@ -387,21 +387,34 @@ public class ProgramElement implements IProgramElement {
        }
 
        public String toSignatureString() {
+               return toSignatureString(true);
+       }
+
+       public String toSignatureString(boolean getFullyQualifiedArgTypes) {
                StringBuffer sb = new StringBuffer();
                sb.append(name);
                
                if (parameterTypes != null ) {
                        sb.append('('); 
                        for (Iterator it = parameterTypes.iterator(); it.hasNext(); ) {
-                               sb.append((String)it.next());
+                               String arg = (String)it.next();
+                               if (getFullyQualifiedArgTypes) {
+                                       sb.append(arg);
+                               } else {
+                                       int index = arg.lastIndexOf(".");
+                                       if (index != -1) {
+                                               sb.append(arg.substring(index + 1));
+                                       } else {
+                                               sb.append(arg);
+                                       }
+                               }
                                if (it.hasNext()) sb.append(", ");
                        }
                        sb.append(')');
                }
                
-               return sb.toString();
+               return sb.toString();           
        }
-
        
        public static boolean shortITDNames = true;
        
@@ -409,6 +422,10 @@ public class ProgramElement implements IProgramElement {
         * TODO: move the "parent != null"==>injar heuristic to more explicit 
         */
        public String toLinkLabelString() {
+               return toLinkLabelString(true);
+       }
+
+       public String toLinkLabelString(boolean getFullyQualifiedArgTypes) {
                String label;
                if (kind == Kind.CODE || kind == Kind.INITIALIZER) {
                        label = parent.getParent().getName() + ": ";
@@ -435,18 +452,22 @@ public class ProgramElement implements IProgramElement {
                                label = "injar aspect: ";  
                        }
                }
-               label += toLabelString();
+               label += toLabelString(getFullyQualifiedArgTypes);
                return label;
        }
-
+       
        public String toLabelString() {
-               String label = toSignatureString();
+               return toLabelString(true);
+       }
+
+       public String toLabelString(boolean getFullyQualifiedArgTypes) {
+               String label = toSignatureString(getFullyQualifiedArgTypes);
                if (details != null) {
                        label += ": " + details;
                } 
                return label;
        }
-
+       
        private String handle = null;
        public String getHandleIdentifier() {
            if (null == handle) {
index f096a12830434aa0264c7994475afcb43c21184a..66ba3829a2a2eff39c36a6124bed4f79bc318f09 100644 (file)
@@ -293,7 +293,7 @@ public class AsmElementFormatter {
                for (int i = 0; i < argArray.length; i++) {
                        String argName = new String(argArray[i].name);
                        String argType = argArray[i].type.resolvedType.debugName();
-                       if (acceptArgument(argName, argType)) { 
+                       if (acceptArgument(argName, argArray[i].type.toString())) { 
                                names.add(argName);
                                types.add(argType);
                        }   
diff --git a/tests/bugs151/pr125295/pkg/A.aj b/tests/bugs151/pr125295/pkg/A.aj
new file mode 100644 (file)
index 0000000..53aa6bc
--- /dev/null
@@ -0,0 +1,18 @@
+package pkg;
+
+import org.aspectj.lang.JoinPoint;
+
+public aspect A {
+
+       pointcut p() : within(C) && execution(* *(..));
+       
+       before() : p() {
+       }
+       
+       after(): execution(void printParameters(..)) {
+       }
+       
+       static private void printParameters(JoinPoint jp) {
+       }
+       
+}
diff --git a/tests/bugs151/pr125295/pkg/C.java b/tests/bugs151/pr125295/pkg/C.java
new file mode 100644 (file)
index 0000000..c03c027
--- /dev/null
@@ -0,0 +1,9 @@
+package pkg;
+
+public class C {
+
+       public void foo(int i, Object o) {
+               
+       }
+
+}
index 12ac259bfa02b815d74a0314e27e82908376a5ad..5dda12f07bc6082dbc9350e2cba15c0e11b0535c 100644 (file)
@@ -14,6 +14,9 @@ import java.io.File;
 
 import junit.framework.Test;
 
+import org.aspectj.asm.AsmManager;
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.IProgramElement;
 import org.aspectj.systemtest.ajc150.GenericsTests;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
@@ -45,6 +48,27 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          GenericsTests.verifyClassSignature(ajc,"ConcreteAspect","LAbstractAspect<LStudent;>;");
   }
   
+  public void testIProgramElementMethods_pr125295() {
+         runTest("new IProgramElement methods");  
+         IHierarchy top = AsmManager.getDefault().getHierarchy();
+
+         IProgramElement pe = top.findElementForType("pkg","foo");
+         assertNotNull("Couldn't find 'foo' element in the tree",pe);
+         // check that the defaults return the fully qualified arg
+         assertEquals("foo(int, java.lang.Object)",pe.toLabelString());
+         assertEquals("C.foo(int, java.lang.Object)",pe.toLinkLabelString());
+         assertEquals("foo(int, java.lang.Object)",pe.toSignatureString());
+         // check that can get hold of the non qualified args
+         assertEquals("foo(int, Object)",pe.toLabelString(false));
+         assertEquals("C.foo(int, Object)",pe.toLinkLabelString(false));
+         assertEquals("foo(int, Object)",pe.toSignatureString(false));
+
+         IProgramElement pe2 = top.findElementForType("pkg","printParameters");
+         assertNotNull("Couldn't find 'printParameters' element in the tree",pe2);
+         // the argument is org.aspectj.lang.JoinPoint, check that this is added
+         assertFalse("printParameters method should have arguments",pe2.getParameterTypes().isEmpty());          
+  }
+  
   /////////////////////////////////////////
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Ajc151Tests.class);
index 5dffbdc04ce8a58dd05cfbece0c121661e66e51b..f3d9c5b845f3737530b807b4fde68982965362fc 100644 (file)
@@ -94,4 +94,8 @@
         <run class="ConcreteAspect"/>
     </ajc-test>
 
+    <ajc-test dir="bugs151/pr125295" title="new IProgramElement methods">
+        <compile files="pkg/C.java,pkg/A.aj" options="-emacssym"/>
+    </ajc-test>
+
 </suite>
\ No newline at end of file