- Revision
- 1299
- Author
- rfscholte
- Date
- 2011-08-20 10:04:34 -0500 (Sat, 20 Aug 2011)
Log Message
Hopefully one step closer to refactor the resolveMethods. Still some generics issues to solve...
Modified Paths
- trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractBaseMethod.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java
Diff
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -37,7 +37,9 @@ import com.thoughtworks.qdox.model.DefaultJavaSource; import com.thoughtworks.qdox.model.DocletTag; import com.thoughtworks.qdox.model.DocletTagFactory; +import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaClassParent; +import com.thoughtworks.qdox.model.JavaGenericDeclaration; import com.thoughtworks.qdox.model.JavaParameter; import com.thoughtworks.qdox.model.JavaSource; import com.thoughtworks.qdox.model.Type; @@ -138,9 +140,9 @@ // typeParameters if (def.getTypeParameters() != null) { - List<TypeVariable> typeParams = new LinkedList<TypeVariable>(); + List<TypeVariable<?>> typeParams = new LinkedList<TypeVariable<?>>(); for(TypeVariableDef typeVariableDef : def.getTypeParameters()) { - typeParams.add(createTypeVariable(typeVariableDef)); + typeParams.add(createTypeVariable(typeVariableDef, newClass)); } newClass.setTypeParameters(typeParams); } @@ -227,9 +229,9 @@ // typeParameters if (def.getTypeParams() != null) { - List<TypeVariable> typeParams = new LinkedList<TypeVariable>(); + List<TypeVariable<?>> typeParams = new LinkedList<TypeVariable<?>>(); for(TypeVariableDef typeVariableDef : def.getTypeParams()) { - typeParams.add(createTypeVariable(typeVariableDef)); + typeParams.add(createTypeVariable(typeVariableDef, currentConstructor)); } currentConstructor.setTypeParameters(typeParams); } @@ -275,9 +277,9 @@ // typeParameters if (def.getTypeParams() != null) { - List<TypeVariable> typeParams = new LinkedList<TypeVariable>(); + List<TypeVariable<?>> typeParams = new LinkedList<TypeVariable<?>>(); for(TypeVariableDef typeVariableDef : def.getTypeParams()) { - typeParams.add(createTypeVariable(typeVariableDef)); + typeParams.add(createTypeVariable(typeVariableDef, currentMethod)); } currentMethod.setTypeParameters(typeParams); } @@ -300,14 +302,13 @@ currentMethod.setSourceCode(def.getBody()); } - private TypeVariable createTypeVariable( TypeVariableDef typeVariableDef ) + private TypeVariable<?> createTypeVariable( TypeVariableDef typeVariableDef, JavaGenericDeclaration<?> genericDeclaration ) { if ( typeVariableDef == null ) { return null; } - JavaClassParent context = classStack.isEmpty() ? source : classStack.getFirst(); - TypeVariable result = new TypeVariable( null, typeVariableDef.getName(), context ); + TypeVariable<?> result = new TypeVariable( null, typeVariableDef.getName(), genericDeclaration ); if ( typeVariableDef.getBounds() != null && !typeVariableDef.getBounds().isEmpty() ) {
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractBaseMethod.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractBaseMethod.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractBaseMethod.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -14,7 +14,7 @@ extends AbstractInheritableJavaEntity { - private List<TypeVariable> typeParameters = Collections.emptyList(); + private List<TypeVariable<?>> typeParameters = Collections.emptyList(); private List<JavaParameter> parameters = Collections.emptyList(); private List<Type> exceptions = Collections.emptyList(); private boolean varArgs; @@ -111,12 +111,12 @@ return result; } - public void setTypeParameters( List<TypeVariable> typeParameters ) + public void setTypeParameters( List<TypeVariable<?>> typeParameters ) { this.typeParameters = typeParameters; } - public List<TypeVariable> getTypeParameters() + public List<TypeVariable<?>> getTypeParameters() { return typeParameters; }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -45,7 +45,7 @@ private Type superClass; private List<Type> implementz = new LinkedList<Type>(); - private List<TypeVariable> typeParameters = new LinkedList<TypeVariable>(); + private List<TypeVariable<?>> typeParameters = new LinkedList<TypeVariable<?>>(); //sourceless class can use this property private JavaPackage javaPackage; @@ -225,12 +225,12 @@ /* (non-Javadoc) * @see com.thoughtworks.qdox.model.JavaClass#getTypeParameters() */ - public List<TypeVariable> getTypeParameters() + public List<TypeVariable<?>> getTypeParameters() { return typeParameters; } - public void setTypeParameters( List<TypeVariable> typeParameters ) + public void setTypeParameters( List<TypeVariable<?>> typeParameters ) { this.typeParameters = typeParameters; } @@ -808,6 +808,11 @@ } return result; } + + public JavaClass getDeclaringClass() + { + return getParentClass(); + } /* (non-Javadoc) * @see com.thoughtworks.qdox.model.JavaClass#getTagsByName(java.lang.String, boolean)
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -89,8 +89,6 @@ String getCodeBlock(); - List<TypeVariable> getTypeParameters(); - JavaSource getParentSource(); /**
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -28,12 +28,14 @@ * @author Robert Scholte * @since 2.0 */ -public interface JavaGenericDeclaration +public interface JavaGenericDeclaration<D> { /** * Equivalent of {@link java.lang.reflect.GenericDeclaration#getTypeParameters()} * * @return a list of typeParameters, never <code>null</code> */ - List<TypeVariable> getTypeParameters(); + List<TypeVariable<?>> getTypeParameters(); + + JavaClass getDeclaringClass(); }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -129,7 +129,7 @@ */ String getSourceCode(); - List<TypeVariable> getTypeParameters(); + List<TypeVariable<?>> getTypeParameters(); /** * Equivalent of java.lang.reflect.Method.getGenericReturnType()
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -206,7 +206,7 @@ return originalMethod.getTagsByName( name ); } - public List<TypeVariable> getTypeParameters() + public List<TypeVariable<?>> getTypeParameters() { return originalMethod.getTypeParameters(); }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -167,7 +167,7 @@ return result.toString(); } - protected String getGenericValue( List<TypeVariable> typeVariableList ) + protected String getGenericValue( List<TypeVariable<?>> typeVariableList ) { StringBuffer result = new StringBuffer( getResolvedValue( typeVariableList ) ); for ( Iterator<Type> iter = actualArgumentTypes.iterator(); iter.hasNext(); ) @@ -181,10 +181,10 @@ return result.toString(); } - protected String getResolvedValue( List<TypeVariable> typeParameters ) + protected String getResolvedValue( List<TypeVariable<?>> typeParameters ) { String result = getValue(); - for ( TypeVariable typeParameter : typeParameters ) + for ( TypeVariable<?> typeParameter : typeParameters ) { if ( typeParameter.getName().equals( getValue() ) ) { @@ -195,11 +195,11 @@ return result; } - protected TypeVariable resolve( List<TypeVariable> typeParameters ) + protected TypeVariable<?> resolve( List<TypeVariable<?>> typeParameters ) { - TypeVariable result = null; + TypeVariable<?> result = null; // String result = getGenericValue(typeParameters); - for ( TypeVariable typeParameter : typeParameters ) + for ( TypeVariable<?> typeParameter : typeParameters ) { if ( typeParameter.getName().equals( getValue() ) ) { @@ -468,10 +468,10 @@ private static int getTypeVariableIndex( JavaClass declaringClass, String fqn ) { int typeIndex = -1; - for ( TypeVariable typeVariable : declaringClass.getTypeParameters() ) + for ( Object typeVariable : declaringClass.getTypeParameters() ) { typeIndex++; - if ( typeVariable.getFullyQualifiedName().equals( fqn ) ) + if ( ((TypeVariable<?>) typeVariable).getFullyQualifiedName().equals( fqn ) ) { return typeIndex; } @@ -506,10 +506,10 @@ return result.toString(); } - public String getResolvedGenericValue( List<TypeVariable> typeParameters ) + public String getResolvedGenericValue( List<TypeVariable<?>> typeParameters ) { StringBuffer result = new StringBuffer(); - TypeVariable variable = resolve( typeParameters ); + TypeVariable<?> variable = resolve( typeParameters ); result.append( variable == null ? getValue() : variable.getBounds().get(0).getValue() ); if ( !actualArgumentTypes.isEmpty() ) { @@ -531,10 +531,10 @@ return result.toString(); } - protected String getResolvedGenericFullyQualifiedName( List<TypeVariable> typeParameters ) + protected String getResolvedGenericFullyQualifiedName( List<TypeVariable<?>> typeParameters ) { StringBuffer result = new StringBuffer(); - TypeVariable variable = resolve( typeParameters ); + TypeVariable<?> variable = resolve( typeParameters ); result.append( variable == null ? getFullyQualifiedName() : variable.getBounds().get(0).getFullyQualifiedName() ); if ( !actualArgumentTypes.isEmpty() ) { @@ -556,9 +556,9 @@ return result.toString(); } - protected String getResolvedFullyQualifiedName( List<TypeVariable> typeParameters ) + protected String getResolvedFullyQualifiedName( List<TypeVariable<?>> typeParameters ) { - TypeVariable variable = resolve( typeParameters ); + TypeVariable<?> variable = resolve( typeParameters ); return (variable == null ? getFullyQualifiedName() : variable.getBounds().get(0).getFullyQualifiedName() ); } @@ -648,7 +648,7 @@ return resolveRealClass().getCodeBlock(); } - public List<TypeVariable> getTypeParameters() + public List<TypeVariable<?>> getTypeParameters() { return resolveRealClass().getTypeParameters(); } @@ -818,6 +818,11 @@ { return resolveRealClass().getDerivedClasses(); } + + public JavaClass getDeclaringClass() + { + return resolveRealClass().getDeclaringClass(); + } public List<DocletTag> getTagsByName( String name, boolean superclasses ) {
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java (1298 => 1299)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java 2011-08-16 09:59:59 UTC (rev 1298) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java 2011-08-20 15:04:34 UTC (rev 1299) @@ -26,15 +26,18 @@ * @author Robert Scholte * @since 1.10 */ -public class TypeVariable +public class TypeVariable<D extends JavaGenericDeclaration> extends Type { private List<Type> bounds; + + private D genericDeclaration; - public TypeVariable( String fullName, String name, JavaClassParent context ) + public TypeVariable( String fullName, String name, D genericDeclaration ) { - super( fullName, name, 0, context ); + super( fullName, name, 0, genericDeclaration.getDeclaringClass() ); + this.genericDeclaration = genericDeclaration; } /** @@ -52,6 +55,11 @@ { this.bounds = bounds; } + + public D getGenericDeclaration() + { + return genericDeclaration; + } @Override public String getFullyQualifiedName()
To unsubscribe from this list please visit:
