]> source.dussan.org Git - aspectj.git/commitdiff
Ensures on multiple compiles the method generated for a declare statement always...
authoraclement <aclement>
Fri, 11 Mar 2005 12:25:29 +0000 (12:25 +0000)
committeraclement <aclement>
Fri, 11 Mar 2005 12:25:29 +0000 (12:25 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java

index a2f8fb22b439d2f1f484ac4122f10cbcb61935d8..31eb13fe5a87f82e1ad304726eb6cc74e9aa1ebf 100644 (file)
@@ -57,7 +57,8 @@ public class AspectDeclaration extends TypeDeclaration {
        public EclipseFactory factory;  //??? should use this consistently
 
     public int adviceCounter = 1; // Used as a part of the generated name for advice methods
-
+    public int declareCounter= 1; // Used as a part of the generated name for methods representing declares
+       
        // for better error messages in 1.0 to 1.1 transition
        public TypePattern dominatesPattern;
 
index 158228a4c189628624659614f053da263c25638d..d7da525e5997c9d2b07a877a68d8031baf75497c 100644 (file)
@@ -15,6 +15,7 @@ package org.aspectj.ajdt.internal.compiler.ast;
 
 import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowInfo;
 import org.aspectj.org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
@@ -32,7 +33,7 @@ public class DeclareAnnotationDeclaration extends DeclareDeclaration {
          addAnnotation(annotation);
          if (symbolicDeclare==null) return; // there is an error that will already be getting reported (e.g. incorrect pattern on decaf/decac)
          symbolicDeclare.setAnnotationString(annotation.toString());
-         symbolicDeclare.setAnnotationMethod(new String(selector));
+         
    }
    
    public void analyseCode(ClassScope classScope,
@@ -76,5 +77,10 @@ public class DeclareAnnotationDeclaration extends DeclareDeclaration {
        }
        this.annotations[0] = ann;
    }
+   
+       public void postParse(TypeDeclaration typeDec) {
+               super.postParse(typeDec);
+           ((DeclareAnnotation)declareDecl).setAnnotationMethod(new String(selector));
+       }
        
 }
index 990b3daaa4134b319c8e50b8bb50303b954a6daa..a34a36a616ac1077de28e8baa3a77d7b323c59be 100644 (file)
@@ -19,6 +19,7 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
 import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser;
@@ -33,9 +34,9 @@ public class DeclareDeclaration extends AjMethodDeclaration {
        /**
         * Constructor for IntraTypeDeclaration.
         */
-       static int counter = 0; //XXX evil
        public DeclareDeclaration(CompilationResult result, Declare symbolicDeclare) {
                super(result);
+               
                this.declareDecl = symbolicDeclare;
                if (declareDecl != null) {
                        // AMC added init of declarationSourceXXX fields which are used
@@ -44,22 +45,7 @@ public class DeclareDeclaration extends AjMethodDeclaration {
                        declarationSourceEnd = sourceEnd = declareDecl.getEnd();
                }
                //??? we might need to set parameters to be empty
-               this.returnType = TypeReference.baseTypeReference(T_void, 0);
-               
-        StringBuffer sb = new StringBuffer();
-        sb.append("ajc$declare");
-        // Declares can choose to provide a piece of the name - to enable
-        // them to be easily distinguised at weave time (e.g. see declare annotation)
-        if (symbolicDeclare!=null) {
-          String suffix = symbolicDeclare.getNameSuffix();
-          if (suffix.length()!=0) {
-               sb.append("_");
-               sb.append(suffix);
-          }
-        }
-        sb.append("_");
-        sb.append(counter++);
-        this.selector = sb.toString().toCharArray();
+               this.returnType = TypeReference.baseTypeReference(T_void, 0);       
        }
 
 
@@ -132,4 +118,23 @@ public class DeclareDeclaration extends AjMethodDeclaration {
                return super.generateInfoAttributes(classFile,true);
        }
 
+       public void postParse(TypeDeclaration typeDec) {
+               super.postParse(typeDec);
+               int declareSequenceNumberInType = ((AspectDeclaration)typeDec).declareCounter++;
+               //FIXME asc the name should perhaps include the hashcode of the pattern (type/sig) for binary compatibility reasons!
+               StringBuffer sb = new StringBuffer();
+           sb.append("ajc$declare");
+        // Declares can choose to provide a piece of the name - to enable
+        // them to be easily distinguised at weave time (e.g. see declare annotation)
+        if (declareDecl!=null) {
+          String suffix = declareDecl.getNameSuffix();
+          if (suffix.length()!=0) {
+               sb.append("_");
+               sb.append(suffix);
+          }
+        }
+        sb.append("_");
+        sb.append(declareSequenceNumberInType);
+        this.selector = sb.toString().toCharArray();
+       }
 }