]> source.dussan.org Git - aspectj.git/commitdiff
AspectJ6: picking up compiler interface changes
authoraclement <aclement>
Thu, 17 Jan 2008 00:26:02 +0000 (00:26 +0000)
committeraclement <aclement>
Thu, 17 Jan 2008 00:26:02 +0000 (00:26 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java

index 25cce19387d9d1bced68bf09819fd5e834ab5de1..697d3573073c156bcc673a043df17d606c790a05 100644 (file)
@@ -21,6 +21,8 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
+import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.IMemberFinder;
@@ -32,6 +34,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.aspectj.org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
 
 /**
  * The member finder looks after intertype declared members on a type, there is
@@ -71,7 +74,7 @@ public class InterTypeMemberFinder implements IMemberFinder {
                        if (!retField.canBeSeenBy(sourceTypeBinding, site, scope)) return field;
                }
                //XXX need dominates check on aspects
-               return new ProblemFieldBinding(retField.declaringClass, retField.name, ProblemReporter.Ambiguous);
+               return new ProblemFieldBinding(retField.declaringClass, retField.name, IProblem.AmbiguousField);//ProblemReporter.Ambiguous);
        }
 
 
@@ -264,7 +267,7 @@ public class InterTypeMemberFinder implements IMemberFinder {
                        }
                }
                
-               if (ret.isEmpty()) return SourceTypeBinding.NoMethods;
+               if (ret.isEmpty()) return Binding.NO_METHODS;
                return (MethodBinding[])ret.toArray(new MethodBinding[ret.size()]);     
        }
        
@@ -305,7 +308,7 @@ public class InterTypeMemberFinder implements IMemberFinder {
                        }
                }
                
-               if (ret.isEmpty()) return SourceTypeBinding.NoMethods;
+               if (ret.isEmpty()) return Binding.NO_METHODS;
                
 //             System.err.println("method: " + ret);
                
index e2fffe5c06006b72ae7e86cd3f56469a3498cfcb..79cd2396b40728ad2220cdde7b4c304d04d2c002 100644 (file)
@@ -13,7 +13,9 @@
 
 package org.aspectj.ajdt.internal.compiler.lookup;
 
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeDeclaration;
 import org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration;
+import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
@@ -21,10 +23,12 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
 import org.aspectj.weaver.AjcMemberMaker;
 import org.aspectj.weaver.Member;
 import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedTypeMunger;
+import org.aspectj.weaver.TypeVariable;
 import org.aspectj.weaver.UnresolvedType;
 
 /**
@@ -48,7 +52,7 @@ public class InterTypeMethodBinding extends MethodBinding {
        public AbstractMethodDeclaration sourceMethod;
        
        public InterTypeMethodBinding(EclipseFactory world, ResolvedTypeMunger munger, UnresolvedType withinType,
-                                                                       AbstractMethodDeclaration sourceMethod)
+                       AbstractMethodDeclaration sourceMethod)
        {
                super();
                ResolvedMember signature = munger.getSignature();
@@ -62,7 +66,29 @@ public class InterTypeMethodBinding extends MethodBinding {
                this.sourceMethod     = sourceMethod;           
                this.targetType       = (ReferenceBinding)world.makeTypeBinding(signature.getDeclaringType());
                this.declaringClass   = (ReferenceBinding)world.makeTypeBinding(withinType);
-               
+
+               // Ok, we need to set the typevariable declaring elements
+               // 1st set:
+               // If the typevariable is one declared on the source method, then we know we are the declaring element
+               for (int i = 0; i < typeVariables.length; i++) {
+                       TypeVariableBinding tv = typeVariables[i];
+                       String name = new String(tv.sourceName);
+                       TypeVariableBinding[] tv2 = sourceMethod.binding.typeVariables;
+                       for (int j = 0; j < tv2.length; j++) {
+                               TypeVariableBinding typeVariable = tv2[j];
+                               if (new String(tv2[j].sourceName).equals(name)) typeVariables[i].declaringElement = this;
+                       }
+               }
+               for (int i = 0; i < typeVariables.length; i++) {
+                       if (typeVariables[i].declaringElement==null) throw new RuntimeException("Declaring element not set");
+                       
+               }
+//             typeVariables[0].declaringElement=this;
+//              if (tVar.getDeclaringElement() instanceof Member) {
+//                             declaringElement = makeMethodBinding((ResolvedMember)tVar.getDeclaringElement());
+//                       } else {
+//                             declaringElement = makeTypeBinding((UnresolvedType)tVar.getDeclaringElement());
+//                       }
                if (signature.getKind() == Member.METHOD) {                     
                        syntheticMethod = 
                                world.makeMethodBinding(AjcMemberMaker.interMethodDispatcher(signature, withinType));
index 9d7b7987c2703617940eced73ac503ff5989ecdc..ecfb7df65a686db00311c2857ea01a17c916c49b 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Map;
 
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
@@ -81,15 +82,22 @@ public class InterTypeScope extends ClassScope {
                if (aliased!=-1) {
                        if (aliased>sourceType.typeVariables.length || sourceType.typeVariables.length==0) {
                                TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(),null,0);
+                               tvb.fPackage = new PackageBinding(environment());
                                return tvb;
                                // error is going to be reported by someone else!
                        }
                        TypeVariableBinding tvb = sourceType.typeVariables()[aliased];
+                       tvb.fPackage = sourceType.fPackage;
                        if (usedAliases==null) usedAliases = new HashMap();
                        usedAliases.put(tvb,variableName);
                        return tvb;
                } else {
-                   return sourceType.getTypeVariable(name);
+                   TypeVariableBinding variableBinding = sourceType.getTypeVariable(name);
+                   if (variableBinding == null) { // GENERICITDFIX
+                       // Inside generic aspect, might want the type var attached to us
+                       variableBinding = parent.findTypeVariable(name,((ClassScope) parent).referenceContext.binding);
+                   }
+                   return variableBinding;
                }
        }