diff options
author | aclement <aclement> | 2009-11-07 18:29:27 +0000 |
---|---|---|
committer | aclement <aclement> | 2009-11-07 18:29:27 +0000 |
commit | 65a862c8cad5b62b2b37a588f1c4db5e14340b84 (patch) | |
tree | c0fe96d5939759a86c8c6a0e18363273ab225290 /org.aspectj.matcher | |
parent | 18841492728279293ed715acf62f9197791899cf (diff) | |
download | aspectj-65a862c8cad5b62b2b37a588f1c4db5e14340b84.tar.gz aspectj-65a862c8cad5b62b2b37a588f1c4db5e14340b84.zip |
more helpers
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r-- | org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java | 99 |
1 files changed, 46 insertions, 53 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index eb001983d..20a22972b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -66,8 +66,6 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl this.world = world; } - // ---- things that don't require a world - /** * Returns an iterator through ResolvedType objects representing all the direct supertypes of this type. That is, through the * superclass, if any, and all declared interfaces. @@ -193,15 +191,10 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter(); Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { public Iterator<ResolvedType> get(ResolvedType o) { - return dupFilter.filter((o).getDirectSupertypes()); - } - }; - Iterators.Getter<ResolvedType, ResolvedMember> fieldGetter = new Iterators.Getter<ResolvedType, ResolvedMember>() { - public Iterator<ResolvedMember> get(ResolvedType o) { - return Iterators.array((o).getDeclaredFields()); + return dupFilter.filter(o.getDirectSupertypes()); } }; - return Iterators.mapOver(Iterators.recur(this, typeGetter), fieldGetter); + return Iterators.mapOver(Iterators.recur(this, typeGetter), FieldGetterInstance); } /** @@ -288,50 +281,6 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl private final static FieldGetter FieldGetterInstance = new FieldGetter(); /** - * returns an iterator through all of the methods of this type, in order for checking from JVM spec 2ed 5.4.3.3. This means that - * the order is - * <p/> - * <ul> - * <li>methods from current class</li> - * <li>recur into superclass, all the way up, not touching interfaces</li> - * <li>recur into all superinterfaces, in some unspecified order</li> - * </ul> - * <p/> - * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land. NOTE: Take a look at the javadoc on - * getMethodsWithoutIterator() to see if you are sensitive to a quirk in getMethods() - */ - public Iterator<ResolvedMember> getMethods() { - final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter(); - Iterators.Getter<ResolvedType, ResolvedType> ifaceGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { - public Iterator<ResolvedType> get(ResolvedType o) { - return dupFilter.filter(Iterators.array(o.getDeclaredInterfaces())); - } - }; - Iterators.Getter<ResolvedType, ResolvedMember> methodGetter = new Iterators.Getter<ResolvedType, ResolvedMember>() { - public Iterator<ResolvedMember> get(ResolvedType o) { - return Iterators.array((o).getDeclaredMethods()); - } - }; - return Iterators.mapOver(Iterators.append(new Iterator<ResolvedType>() { - ResolvedType curr = ResolvedType.this; - - public boolean hasNext() { - return curr != null; - } - - public ResolvedType next() { - ResolvedType ret = curr; - curr = curr.getSuperclass(); - return ret; - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }, Iterators.recur(this, ifaceGetter)), methodGetter); - } - - /** * Return an iterator over the types in this types hierarchy - starting with this type first, then all superclasses up to Object * and then all interfaces (starting with those 'nearest' this type). * @@ -481,6 +430,50 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } /** + * returns an iterator through all of the methods of this type, in order for checking from JVM spec 2ed 5.4.3.3. This means that + * the order is + * <p/> + * <ul> + * <li>methods from current class</li> + * <li>recur into superclass, all the way up, not touching interfaces</li> + * <li>recur into all superinterfaces, in some unspecified order</li> + * </ul> + * <p/> + * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land. NOTE: Take a look at the javadoc on + * getMethodsWithoutIterator() to see if you are sensitive to a quirk in getMethods() + */ + public Iterator<ResolvedMember> getMethods() { + final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter(); + Iterators.Getter<ResolvedType, ResolvedType> ifaceGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { + public Iterator<ResolvedType> get(ResolvedType o) { + return dupFilter.filter(Iterators.array(o.getDeclaredInterfaces())); + } + }; + Iterators.Getter<ResolvedType, ResolvedMember> methodGetter = new Iterators.Getter<ResolvedType, ResolvedMember>() { + public Iterator<ResolvedMember> get(ResolvedType o) { + return Iterators.array((o).getDeclaredMethods()); + } + }; + return Iterators.mapOver(Iterators.append(new Iterator<ResolvedType>() { + ResolvedType curr = ResolvedType.this; + + public boolean hasNext() { + return curr != null; + } + + public ResolvedType next() { + ResolvedType ret = curr; + curr = curr.getSuperclass(); + return ret; + } + + public void remove() { + throw new UnsupportedOperationException(); + } + }, Iterators.recur(this, ifaceGetter)), methodGetter); + } + + /** * Return a list of methods, first those declared on this class, then those declared on the superclass (recurse) and then those * declared on the superinterfaces. The getMethods() call above doesn't quite work the same as it will (through the iterator) * return methods declared on *this* class twice, once at the start and once at the end - I couldn't debug that problem, so |