From: aclement Date: Thu, 26 Jan 2006 15:32:48 +0000 (+0000) Subject: helens changes for 125295 - should keep AJDT happy. X-Git-Tag: POST_MEMORY_CHANGES~144 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7e40a6094541d2191f09d810b3330c4858ed8952;p=aspectj.git helens changes for 125295 - should keep AJDT happy. --- diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index 8223c176b..b7ef7e27f 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -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); diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index 0c7c8683c..a523b7497 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -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) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java index f096a1283..66ba3829a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java @@ -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 index 000000000..53aa6bc99 --- /dev/null +++ b/tests/bugs151/pr125295/pkg/A.aj @@ -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 index 000000000..c03c02777 --- /dev/null +++ b/tests/bugs151/pr125295/pkg/C.java @@ -0,0 +1,9 @@ +package pkg; + +public class C { + + public void foo(int i, Object o) { + + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index 12ac259bf..5dda12f07 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -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;"); } + 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); diff --git a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml index 5dffbdc04..f3d9c5b84 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml +++ b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml @@ -94,4 +94,8 @@ + + + + \ No newline at end of file