summaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authoraclement <aclement>2010-10-29 22:48:45 +0000
committeraclement <aclement>2010-10-29 22:48:45 +0000
commit118f91d2a1db46cf94024a76dc16ebd7a480df26 (patch)
tree4180a43b57cd37158cd648d286a7ff7d5d3c734d /asm
parent49b7bcba4455b3a8be486b28516e6cddf827aa69 (diff)
downloadaspectj-118f91d2a1db46cf94024a76dc16ebd7a480df26.tar.gz
aspectj-118f91d2a1db46cf94024a76dc16ebd7a480df26.zip
329111
Diffstat (limited to 'asm')
-rw-r--r--asm/src/org/aspectj/asm/IProgramElement.java5
-rw-r--r--asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java103
2 files changed, 57 insertions, 51 deletions
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
*/