From: aclement Date: Fri, 29 Oct 2010 22:48:45 +0000 (+0000) Subject: 329111 X-Git-Tag: V1_6_11M1~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=118f91d2a1db46cf94024a76dc16ebd7a480df26;p=aspectj.git 329111 --- diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index eedffc3a2..46d4f9ad8 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -389,6 +389,10 @@ public interface IProgramElement extends Serializable { return name.startsWith("declare parents"); } + public boolean isDeclareSoft() { + return name.startsWith("declare soft"); + } + // The 4 declarations below are necessary for serialization private static int nextOrdinal = 0; private final int ordinal = nextOrdinal++; @@ -400,6 +404,7 @@ public interface IProgramElement extends Serializable { public boolean isPackageDeclaration() { return this == PACKAGE_DECLARATION; } + } public void setAnnotationStyleDeclaration(boolean b); diff --git a/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java index 7a38eafb5..2499b5159 100644 --- a/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java +++ b/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java @@ -187,26 +187,13 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); } } else if (ipe.getKind().isDeclareAnnotation()) { - // look at peer declares - int count = 1; - for (IProgramElement object : ipe.getParent().getChildren()) { - if (object.equals(ipe)) { - break; - } - if (object.getKind() == ipe.getKind()) { - if (object.getKind().toString().equals(ipe.getKind().toString())) { - String existingHandle = object.getHandleIdentifier(); - int suffixPosition = existingHandle.indexOf('!'); - if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; - } else { - if (count == 1) { - count = 2; - } - } - } - } + int count = computeCountBasedOnPeers(ipe); + if (count > 1) { + return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); } + } else if (ipe.getKind().isDeclareSoft()) { + // look at peer declares + int count = computeCountBasedOnPeers(ipe); if (count > 1) { return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); } @@ -222,22 +209,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String ipeSig = ipe.getBytecodeSignature(); // remove return type from the signature - it should not be included in the comparison int idx = 0; - if (ipeSig != null && ((idx = ipeSig.indexOf(")")) != -1)) { - ipeSig = ipeSig.substring(0, idx); - } - if (ipeSig != null) { - if (ipeSig.indexOf("Lorg/aspectj/lang") != -1) { - if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { - ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); - } - if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint;")) { - ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint;")); - } - if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { - ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); - } - } - } + ipeSig = shortenIpeSig(ipeSig); for (IProgramElement object : kids) { if (object.equals(ipe)) { break; @@ -289,22 +261,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String ipeSig = ipe.getBytecodeSignature(); // remove return type from the signature - it should not be included in the comparison int idx = 0; - if (ipeSig != null && ((idx = ipeSig.indexOf(")")) != -1)) { - ipeSig = ipeSig.substring(0, idx); - } - if (ipeSig != null) { - if (ipeSig.indexOf("Lorg/aspectj/lang") != -1) { - if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { - ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); - } - if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint;")) { - ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint;")); - } - if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { - ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); - } - } - } + ipeSig = shortenIpeSig(ipeSig); for (IProgramElement object : kids) { if (object.equals(ipe)) { break; @@ -407,6 +364,50 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { return empty; } + private String shortenIpeSig(String ipeSig) { + int idx; + if (ipeSig != null && ((idx = ipeSig.indexOf(")")) != -1)) { + ipeSig = ipeSig.substring(0, idx); + } + if (ipeSig != null) { + if (ipeSig.indexOf("Lorg/aspectj/lang") != -1) { + if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { + ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); + } + if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint;")) { + ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint;")); + } + if (ipeSig.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { + ipeSig = ipeSig.substring(0, ipeSig.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); + } + } + } + return ipeSig; + } + + private int computeCountBasedOnPeers(IProgramElement ipe) { + int count = 1; + for (IProgramElement object : ipe.getParent().getChildren()) { + if (object.equals(ipe)) { + break; + } + if (object.getKind() == ipe.getKind()) { + if (object.getKind().toString().equals(ipe.getKind().toString())) { + String existingHandle = object.getHandleIdentifier(); + int suffixPosition = existingHandle.indexOf('!'); + if (suffixPosition != -1) { + count = new Integer(existingHandle.substring(suffixPosition + 1)).intValue() + 1; + } else { + if (count == 1) { + count = 2; + } + } + } + } + } + return count; + } + /** * Only returns the count if it's not equal to 1 */