]> source.dussan.org Git - aspectj.git/commitdiff
278255
authoraclement <aclement>
Thu, 28 May 2009 19:24:05 +0000 (19:24 +0000)
committeraclement <aclement>
Thu, 28 May 2009 19:24:05 +0000 (19:24 +0000)
asm/src/org/aspectj/asm/IProgramElement.java
asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java
asm/src/org/aspectj/asm/internal/ProgramElement.java

index 9e077cf56ab8c5d065dc6bd36c75044d8830364c..b51fd173161af0f810f2221d7e32fc50b62c5860 100644 (file)
@@ -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
index cb63c359caa8cf9d7f5778da1effcc9edd564097..1772fbf19b0ee148632c742dc4632b3747777ace 100644 (file)
@@ -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('!');
index 537b8254c1cb3ed9c5f960fab9a17193c96b356d..8babd5df202b1bbe4ba1bd3e4303ac6433d0f455 100644 (file)
@@ -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();