aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-04-20 19:24:30 +0000
committeracolyer <acolyer>2005-04-20 19:24:30 +0000
commit7a639d019a9b04b3eb7af97a7a2975cbbf72e0cf (patch)
tree8bd9464cb6c1df486ab5e84d301cf82bc11fbdcb /org.aspectj.ajdt.core
parent1e6fae862407f7c0b49321a6c452774f91f3cd04 (diff)
downloadaspectj-7a639d019a9b04b3eb7af97a7a2975cbbf72e0cf.tar.gz
aspectj-7a639d019a9b04b3eb7af97a7a2975cbbf72e0cf.zip
this set of commits teaches the TypeX world about parameterized types. it handles passing of parameterized types into the weaver from Eclipse, and back out again. Fixes the ITD and parameterized types issue that shows up in the examples. Much more work to be done in this area of course before M3.
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java48
1 files changed, 37 insertions, 11 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index 5aeedd62e..931c7db15 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -47,11 +47,13 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BaseTypes;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
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.org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
/**
* @author Jim Hugunin
@@ -165,6 +167,19 @@ public class EclipseFactory {
TypeVariableBinding tvb = (TypeVariableBinding) binding;
return TypeX.forName(getName(tvb.firstBound)); // XXX needs more investigation as to whether this is correct in all cases
}
+ if (binding instanceof ParameterizedTypeBinding) {
+ ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) binding;
+ String[] arguments = new String[ptb.arguments.length];
+ for (int i = 0; i < arguments.length; i++) {
+ if (ptb.arguments[i] instanceof WildcardBinding) {
+ WildcardBinding wcb = (WildcardBinding) ptb.arguments[i];
+ arguments[i] = getName(((TypeVariableBinding)wcb.typeVariable()).firstBound);
+ } else {
+ arguments[i] = getName(ptb.arguments[i]);
+ }
+ }
+ return TypeX.forParameterizedTypeNames(getName(binding), arguments);
+ }
return TypeX.forName(getName(binding));
}
@@ -307,21 +322,32 @@ public class EclipseFactory {
typeX = typeX.getComponentType();
}
return lookupEnvironment.createArrayType(makeTypeBinding(typeX), dim);
+ } else if (typeX.isParameterized()){
+ TypeX[] typeParameters = typeX.getTypeParameters();
+ ReferenceBinding baseTypeBinding = lookupBinding(typeX.getBaseName());
+ ReferenceBinding[] argumentBindings = new ReferenceBinding[typeParameters.length];
+ for (int i = 0; i < argumentBindings.length; i++) {
+ argumentBindings[i] = lookupBinding(typeParameters[i].getName());
+ }
+ ParameterizedTypeBinding ptb =
+ lookupEnvironment.createParameterizedType(baseTypeBinding,argumentBindings,baseTypeBinding.enclosingType());
+ return ptb;
} else {
- String n = typeX.getName();
- char[][] name = CharOperation.splitOn('.', n.toCharArray());
- ReferenceBinding rb = lookupEnvironment.getType(name);
- // XXX We do this because the pertypewithin aspectOf(Class) generated method needs it. Without this
- // we don't get a 'rawtype' as the argument type for a messagesend to aspectOf() and this leads to
- // a compile error if some client class calls aspectOf(A.class) or similar as it says Class<A> isn't
- // compatible with Class<T>
- if (n.equals("java.lang.Class"))
- rb = lookupEnvironment.createRawType(rb,rb.enclosingType());
- return rb;
+ return lookupBinding(typeX.getName());
}
}
-
+ private ReferenceBinding lookupBinding(String sname) {
+ char[][] name = CharOperation.splitOn('.', sname.toCharArray());
+ ReferenceBinding rb = lookupEnvironment.getType(name);
+ // XXX We do this because the pertypewithin aspectOf(Class) generated method needs it. Without this
+ // we don't get a 'rawtype' as the argument type for a messagesend to aspectOf() and this leads to
+ // a compile error if some client class calls aspectOf(A.class) or similar as it says Class<A> isn't
+ // compatible with Class<T>
+ if (sname.equals("java.lang.Class"))
+ rb = lookupEnvironment.createRawType(rb,rb.enclosingType());
+ return rb;
+ }
public TypeBinding[] makeTypeBindings(TypeX[] types) {
int len = types.length;