### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/ITypeParameter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeParameter.java,v retrieving revision 1.10 diff -u -r1.10 ITypeParameter.java --- model/org/eclipse/jdt/core/ITypeParameter.java 27 Jun 2008 16:04:01 -0000 1.10 +++ model/org/eclipse/jdt/core/ITypeParameter.java 15 Feb 2010 06:11:42 -0000 @@ -42,6 +42,35 @@ String[] getBounds() throws JavaModelException; /** + * Returns the signature for this type parameter. The signature may either + * be unresolved (for source types) or resolved (for binary types). + * + * @return the signature for this formal type parameter + * @throws JavaModelException if this element doesn't exist or if an exception + * occurs while accessing its corresponding resource. + * @see Signature + * @since 3.6 + */ + String getSignature() throws JavaModelException; + + /** + * Returns the signatures for the bounds of this type parameter. If this + * type has no bounds, returns an empty String + *

+ * The bounds signatures may be either unresolved (for source types) or + * resolved (for binary types). See {@link Signature} for details. + *

+ * + * @return the bounds signatures of this type parameter in the order + * declared in the source or class file, an empty array if none + * @exception JavaModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource. + * @see Signature + * @since 3.6 + */ + String[] getBoundsSignature() throws JavaModelException; + + /** * Returns the declaring member of this type parameter. This can be either an IType * or an IMethod. *

Index: model/org/eclipse/jdt/internal/core/TypeParameter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeParameter.java,v retrieving revision 1.15 diff -u -r1.15 TypeParameter.java --- model/org/eclipse/jdt/internal/core/TypeParameter.java 27 Aug 2009 15:27:02 -0000 1.15 +++ model/org/eclipse/jdt/internal/core/TypeParameter.java 15 Feb 2010 06:11:42 -0000 @@ -10,7 +10,13 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; -import org.eclipse.jdt.core.*; +import org.eclipse.jdt.core.IClassFile; +import org.eclipse.jdt.core.IMember; +import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.ITypeParameter; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.Signature; +import org.eclipse.jdt.core.SourceRange; import org.eclipse.jdt.core.compiler.CharOperation; public class TypeParameter extends SourceRefElement implements ITypeParameter { @@ -18,12 +24,18 @@ static final ITypeParameter[] NO_TYPE_PARAMETERS = new ITypeParameter[0]; protected String name; - + protected String signature; + public TypeParameter(JavaElement parent, String name) { super(parent); this.name = name; } - + + public TypeParameter(JavaElement parent, String name, String signature) { + this(parent, name); + this.signature = signature; + } + public boolean equals(Object o) { if (!(o instanceof TypeParameter)) return false; return super.equals(o); @@ -33,6 +45,31 @@ TypeParameterElementInfo info = (TypeParameterElementInfo) getElementInfo(); return CharOperation.toStrings(info.bounds); } + + public String[] getBoundsSignature() throws JavaModelException { + + String[] boundSignatures = null; + boolean isResolved = (this.parent instanceof BinaryMember); + + TypeParameterElementInfo info = (TypeParameterElementInfo) this.getElementInfo(); + char[][] bounds = info.bounds; + + if (bounds == null) { + boundSignatures = CharOperation.NO_STRINGS; + } else { + int boundsLength = bounds.length; + boundSignatures = new String[boundsLength]; + for (int j = 0; j < boundsLength; j++) { + boundSignatures[j] = new String(Signature.createCharArrayTypeSignature(bounds[j], isResolved)); + } + } + return boundSignatures; + } + + + public String getSignature() throws JavaModelException { + return new String(Signature.createTypeParameterSignature(this.getElementName(), getBoundsSignature())); + } public IMember getDeclaringMember() { return (IMember) getParent();