From 9940e0b50f30d89bd657ef0f9c8c5b91ea13775f Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 28 May 2009 19:24:05 +0000 Subject: [PATCH] 278255 --- asm/src/org/aspectj/asm/IProgramElement.java | 5 +++ .../asm/internal/JDTLikeHandleProvider.java | 44 +++++++++++++++---- .../aspectj/asm/internal/ProgramElement.java | 7 +-- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index 9e077cf56..b51fd1731 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -383,6 +383,10 @@ public interface IProgramElement extends Serializable { return name.startsWith("declare @"); } + public boolean isDeclareParents() { + return name.startsWith("declare parents"); + } + // The 4 declarations below are necessary for serialization private static int nextOrdinal = 0; private final int ordinal = nextOrdinal++; @@ -397,5 +401,6 @@ public interface IProgramElement extends Serializable { } public void setAnnotationStyleDeclaration(boolean b); + public boolean isAnnotationStyleDeclaration(); } \ No newline at end of file diff --git a/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java index cb63c359c..1772fbf19 100644 --- a/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java +++ b/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java @@ -158,7 +158,34 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { // TODO could optimize this code char[] byteCodeName = ipe.getBytecodeName().toCharArray(); - if (ipe.getKind().isDeclare()) { + if (ipe.getKind().isDeclareAnnotation()) { + // look at peer declares + int count = 1; + List kids = ipe.getParent().getChildren(); + int idx = 0; + for (Iterator iterator = kids.iterator(); iterator.hasNext();) { + IProgramElement object = (IProgramElement) iterator.next(); + 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; + } + } + } + } + } + if (count > 1) { + return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); + } + } else if (ipe.getKind().isDeclare()) { int index = CharOperation.lastIndexOf('_', byteCodeName); if (index != -1) { return convertCount(CharOperation.subarray(byteCodeName, index + 1, byteCodeName.length)); @@ -184,23 +211,22 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { if (sig1 != null && (idx = sig1.indexOf(")")) != -1) { sig1 = sig1.substring(0, idx); } - // this code needs a speed overhaul... and some proper tests + // this code needs a speed overhaul... and some proper tests // Two static parts because one may be enclosing jpsp (269522) - if (sig1!=null) { - if (sig1.indexOf("Lorg/aspectj/lang")!=-1) { + if (sig1 != null) { + if (sig1.indexOf("Lorg/aspectj/lang") != -1) { if (sig1.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { - sig1 = sig1.substring(0,sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); + sig1 = sig1.substring(0, sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } if (sig1.endsWith("Lorg/aspectj/lang/JoinPoint;")) { - sig1 = sig1.substring(0,sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint;")); + sig1 = sig1.substring(0, sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint;")); } if (sig1.endsWith("Lorg/aspectj/lang/JoinPoint$StaticPart;")) { - sig1 = sig1.substring(0,sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); + sig1 = sig1.substring(0, sig1.lastIndexOf("Lorg/aspectj/lang/JoinPoint$StaticPart;")); } } } - - + if (sig1 == null && ipeSig == null || (sig1 != null && sig1.equals(ipeSig))) { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index 537b8254c..8babd5df2 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -299,8 +299,9 @@ public class ProgramElement implements IProgramElement { public String getBytecodeName() { String s = (String) kvpairs.get("bytecodeName"); - if (s == null) + if (s == null) { return UNDEFINED; + } return s; } @@ -648,10 +649,10 @@ public class ProgramElement implements IProgramElement { } public boolean isAnnotationStyleDeclaration() { - return kvpairs.get("annotationStyleDeclaration")!=null; + return kvpairs.get("annotationStyleDeclaration") != null; } - public void setAnnotationStyleDeclaration(boolean b) { + public void setAnnotationStyleDeclaration(boolean b) { if (b) { if (kvpairs == Collections.EMPTY_MAP) { kvpairs = new HashMap(); -- 2.39.5