aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-07-20 11:11:29 +0000
committeracolyer <acolyer>2005-07-20 11:11:29 +0000
commitaaa349d1543fbad515ff4fce869799fac591118d (patch)
tree25c8c750ff64767dfca53f399f6dd5be43d05b6b /org.aspectj.ajdt.core
parent9fc901ce7a0af0fca72f266504a0a7bc637cb10a (diff)
downloadaspectj-aaa349d1543fbad515ff4fce869799fac591118d.tar.gz
aspectj-aaa349d1543fbad515ff4fce869799fac591118d.zip
changes to construction and representation of parameterized types, and enforcement of the constraint that type mungers always operate on the generic type (never raw or parameterized)
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java9
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java23
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java3
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java6
5 files changed, 32 insertions, 11 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java
index 3ea8c54a0..7b33c9ab1 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java
@@ -169,9 +169,12 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
}
//System.err.println("type: " + binding.returnType + ", " + returnType);
-
- ResolvedMember sig =
- new ResolvedMember(Member.FIELD, world.fromBinding(onTypeBinding),
+ ResolvedType declaringType = world.fromBinding(onTypeBinding).resolve(world.getWorld());
+ if (declaringType.isRawType() || declaringType.isParameterizedType()) {
+ declaringType = declaringType.getGenericType();
+ }
+ ResolvedMember sig =
+ new ResolvedMember(Member.FIELD, declaringType,
declaredModifiers, world.fromBinding(binding.returnType),
new String(declaredSelector), UnresolvedType.NONE);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
index 340a532da..5999b17b9 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
@@ -367,6 +367,8 @@ public class AjLookupEnvironment extends LookupEnvironment {
private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, Collection typeMungers,
Collection declareParents, Collection declareAnnotationOnTypes, boolean skipInners) {
ResolvedType onType = factory.fromEclipse(sourceType);
+ // AMC we shouldn't need this when generic sigs are fixed??
+ if (onType.isRawType()) onType = onType.getGenericType();
WeaverStateInfo info = onType.getWeaverState();
if (info != null && !info.isOldStyle()) {
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 8e85b0653..36d84aced 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
@@ -34,6 +34,7 @@ import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.TypeFactory;
import org.aspectj.weaver.TypeVariable;
import org.aspectj.weaver.TypeVariableReferenceType;
import org.aspectj.weaver.UnresolvedType;
@@ -212,7 +213,11 @@ public class EclipseFactory {
}
}
}
- return UnresolvedType.forParameterizedTypes(UnresolvedType.forName(getName(binding)), arguments);
+ ResolvedType baseType = UnresolvedType.forName(getName(binding)).resolve(getWorld());
+ return TypeFactory.createParameterizedType(
+ baseType,
+ arguments,
+ getWorld());
}
// Convert the source type binding for a generic type into a generic UnresolvedType
@@ -232,9 +237,9 @@ public class EclipseFactory {
//TODO asc generics - temporary guard....
if (!(binding instanceof SourceTypeBinding))
throw new RuntimeException("Cant get the generic sig for "+binding.debugName());
- return ResolvedType.forGenericType(getName(binding),tVars,
+ return UnresolvedType.forGenericType(getName(binding),tVars,
CharOperation.charToString(((SourceTypeBinding)binding).genericSignature()));
- }
+ }
return UnresolvedType.forName(getName(binding));
}
@@ -254,6 +259,7 @@ public class EclipseFactory {
superinterfaces[i] = fromBinding(aTypeVariableBinding.superInterfaces[i]);
}
TypeVariable tv = new TypeVariable(name,superclassType,superinterfaces);
+ tv.resolve(world);
ret.setTypeVariable(tv);
typeVariableBindingsInProgress.remove(aTypeVariableBinding);
return ret;
@@ -343,9 +349,12 @@ public class EclipseFactory {
public ResolvedMember makeResolvedMember(MethodBinding binding, TypeBinding declaringType) {
//System.err.println("member for: " + binding + ", " + new String(binding.declaringClass.sourceName));
+ // AMC these next two lines shouldn't be needed once we sort out generic types properly in the world map
+ ResolvedType realDeclaringType = world.resolve(fromBinding(declaringType));
+ if (realDeclaringType.isRawType()) realDeclaringType = realDeclaringType.getGenericType();
ResolvedMember ret = new ResolvedMember(
binding.isConstructor() ? Member.CONSTRUCTOR : Member.METHOD,
- world.resolve(fromBinding(declaringType)),
+ realDeclaringType,
binding.modifiers,
world.resolve(fromBinding(binding.returnType)),
new String(binding.selector),
@@ -359,9 +368,12 @@ public class EclipseFactory {
}
public ResolvedMember makeResolvedMember(FieldBinding binding, TypeBinding receiverType) {
+ // AMC these next two lines shouldn't be needed once we sort out generic types properly in the world map
+ ResolvedType realDeclaringType = world.resolve(fromBinding(receiverType));
+ if (realDeclaringType.isRawType()) realDeclaringType = realDeclaringType.getGenericType();
return new ResolvedMember(
Member.FIELD,
- world.resolve(fromBinding(receiverType)),
+ realDeclaringType,
binding.modifiers,
world.resolve(fromBinding(binding.type)),
new String(binding.name),
@@ -521,6 +533,7 @@ public class EclipseFactory {
ReferenceType complexName = new ReferenceType(complexTx,world);//getWorld().lookupOrCreateName(complexTx);
name.setGenericType(complexName);
complexName.setDelegate(t);
+ complexName.setSourceContext(t.getResolvedTypeX().getSourceContext());
}
name.setDelegate(t);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
index b8eb60b83..240d2c478 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
@@ -458,8 +458,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
}
public boolean isGeneric() {
- char[] sig = binding.genericSignature();
- return (sig==null?false:sig[0]=='<');
+ return binding.isGenericType();
}
public TypeVariable[] getTypeVariables() {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
index 98672327d..b17d21a3a 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
@@ -53,6 +53,8 @@ public class EclipseTypeMunger extends ConcreteTypeMunger {
munger.setSourceLocation(sourceLocation);
}
targetTypeX = munger.getSignature().getDeclaringType().resolve(world.getWorld());
+ // AMC, needed until generic and raw have distinct sigs...
+ if (targetTypeX.isParameterizedType() || targetTypeX.isRawType()) targetTypeX = targetTypeX.getGenericType();
//targetBinding = (ReferenceBinding)world.makeTypeBinding(targetTypeX);
}
@@ -71,7 +73,9 @@ public class EclipseTypeMunger extends ConcreteTypeMunger {
* i.e. adds Method|FieldBindings, plays with inheritance, ...
*/
public boolean munge(SourceTypeBinding sourceType) {
- if (!world.fromEclipse(sourceType).equals(targetTypeX)) return false; //??? move this test elsewhere
+ ResolvedType rt = world.fromEclipse(sourceType);
+ if (rt.isRawType() || rt.isParameterizedType()) rt = rt.getGenericType();
+ if (!rt.equals(targetTypeX)) return false; //??? move this test elsewhere
//System.out.println("munging: " + sourceType);
// System.out.println("match: " + world.fromEclipse(sourceType) +
// " with " + targetTypeX);