Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 160033 Details for
Bug 246594
[model] API request: ITypeParameter#getBoundsSignatures() or #getSignature()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated patch
patch_246594.txt (text/plain), 11.32 KB, created by
Jay Arthanareeswaran
on 2010-02-24 01:08:01 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2010-02-24 01:08:01 EST
Size:
11.32 KB
patch
obsolete
>### 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 24 Feb 2010 06:03:00 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2008 IBM Corporation and others. >+ * Copyright (c) 2004, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -42,6 +42,23 @@ > String[] getBounds() throws JavaModelException; > > /** >+ * Returns the signatures for this type parameter's bounds. The type parameter may have >+ * been declared as part of a type or a method. The signatures represent only the individual >+ * bounds and do not include the type variable name or the <code>extends</code> keyword. >+ * <p> >+ * The signatures may be either unresolved (for source types) or resolved (for binary types). >+ * See {@link Signature} for details. >+ * </p> >+ * >+ * @return the signatures for the bounds of this formal type parameter >+ * @throws JavaModelException >+ * if this element does not exist or if an exception occurs while accessing its corresponding resource. >+ * @see Signature >+ * @since 3.6 >+ */ >+ String[] getBoundsSignatures() throws JavaModelException; >+ >+ /** > * Returns the declaring member of this type parameter. This can be either an <code>IType</code> > * or an <code>IMethod</code>. > * <p> >Index: model/org/eclipse/jdt/internal/core/ClassFileInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java,v >retrieving revision 1.47 >diff -u -r1.47 ClassFileInfo.java >--- model/org/eclipse/jdt/internal/core/ClassFileInfo.java 11 Feb 2010 20:16:08 -0000 1.47 >+++ model/org/eclipse/jdt/internal/core/ClassFileInfo.java 24 Feb 2010 06:03:00 -0000 >@@ -296,16 +296,17 @@ > for (int i = 0, typeParameterCount = typeParameterSignatures.length; i < typeParameterCount; i++) { > char[] typeParameterSignature = typeParameterSignatures[i]; > char[] typeParameterName = Signature.getTypeVariable(typeParameterSignature); >+ CharOperation.replace(typeParameterSignature, '/', '.'); > char[][] typeParameterBoundSignatures = Signature.getTypeParameterBounds(typeParameterSignature); > int boundLength = typeParameterBoundSignatures.length; > char[][] typeParameterBounds = new char[boundLength][]; > for (int j = 0; j < boundLength; j++) { > typeParameterBounds[j] = Signature.toCharArray(typeParameterBoundSignatures[j]); >- CharOperation.replace(typeParameterBounds[j], '/', '.'); > } > TypeParameter typeParameter = new TypeParameter(parent, new String(typeParameterName)); > TypeParameterElementInfo info = new TypeParameterElementInfo(); > info.bounds = typeParameterBounds; >+ info.boundsSignatures = typeParameterBoundSignatures; > typeParameterHandles.add(typeParameter); > > // ensure that 2 binary methods with the same signature but with different return types have different occurence counts. >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 24 Feb 2010 06:03:00 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2009 IBM Corporation and others. >+ * Copyright (c) 2004, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -33,7 +33,35 @@ > TypeParameterElementInfo info = (TypeParameterElementInfo) getElementInfo(); > return CharOperation.toStrings(info.bounds); > } >- >+ >+ public String[] getBoundsSignatures() throws JavaModelException { >+ >+ String[] boundSignatures = null; >+ TypeParameterElementInfo info = (TypeParameterElementInfo) this.getElementInfo(); >+ >+ // For a binary type or method, the signature is already available from the .class file. >+ // No need to construct again >+ if (this.parent instanceof BinaryMember) { >+ char[][] boundsSignatures = info.boundsSignatures; >+ if (boundsSignatures == null || boundsSignatures.length == 0) { >+ return CharOperation.NO_STRINGS; >+ } >+ return CharOperation.toStrings(info.boundsSignatures); >+ } >+ >+ char[][] bounds = info.bounds; >+ if (bounds == null || bounds.length == 0) { >+ return CharOperation.NO_STRINGS; >+ } >+ >+ int boundsLength = bounds.length; >+ boundSignatures = new String[boundsLength]; >+ for (int i = 0; i < boundsLength; i++) { >+ boundSignatures[i] = new String(Signature.createCharArrayTypeSignature(bounds[i], false)); >+ } >+ return boundSignatures; >+ } >+ > public IMember getDeclaringMember() { > return (IMember) getParent(); > } >Index: model/org/eclipse/jdt/internal/core/TypeParameterElementInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeParameterElementInfo.java,v >retrieving revision 1.7 >diff -u -r1.7 TypeParameterElementInfo.java >--- model/org/eclipse/jdt/internal/core/TypeParameterElementInfo.java 7 Mar 2009 01:08:07 -0000 1.7 >+++ model/org/eclipse/jdt/internal/core/TypeParameterElementInfo.java 24 Feb 2010 06:03:00 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2009 IBM Corporation and others. >+ * Copyright (c) 2004, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -28,4 +28,9 @@ > * The bounds names of this type parameter. > */ > public char[][] bounds; >+ >+ /* >+ * The bounds' signatures for this type parameter. >+ */ >+ public char[][] boundsSignatures; > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ClassFileTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java,v >retrieving revision 1.48 >diff -u -r1.48 ClassFileTests.java >--- src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 10 Nov 2009 16:53:05 -0000 1.48 >+++ src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 24 Feb 2010 06:03:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -60,7 +60,7 @@ > " <U extends Exception> X<T> foo(X<T> x) throws RuntimeException, U {\n" + > " return null;\n" + > " }\n" + >- " <K, V> V foo(K key, V value) throws Exception {\n" + >+ " <K, V extends T> V foo(K key, V value) throws Exception {\n" + > " return value;\n" + > " }\n" + > "}", >@@ -1094,7 +1094,7 @@ > assertStringsEqual( > "Unexpected type parameters", > "K:Ljava.lang.Object;\n" + >- "V:Ljava.lang.Object;\n", >+ "V:TT;\n", > method.getTypeParameterSignatures()); > } > >@@ -1523,4 +1523,25 @@ > "Ljava.util.Collection<Ljava.lang.String;>;", > field.getTypeSignature()); > } >+ >+ public void testBug246594() throws JavaModelException { >+ IType type = this.jarRoot.getPackageFragment("generic").getClassFile( >+ "Z.class").getType(); >+ ITypeParameter typeParam = type.getTypeParameter("T"); >+ assertNotNull(typeParam); >+ assertStringsEqual("Type parameter bounds signatures", >+ "Ljava.lang.Object;\n" + >+ "Lgeneric.I<-TT;>;\n", >+ typeParam.getBoundsSignatures()); >+ } >+ >+ public void testBug246594a() throws JavaModelException { >+ IType type = this.jarRoot.getPackageFragment("generic").getClassFile( >+ "X.class").getType(); >+ IMethod method = type.getMethod("foo", new String[] { "TK;", "TV;" }); >+ ITypeParameter typeParam = method.getTypeParameter("V"); >+ assertStringsEqual("Type parameter bounds signatures", >+ "TT;\n", typeParam.getBoundsSignatures()); >+ } >+ > } >Index: src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java,v >retrieving revision 1.70 >diff -u -r1.70 CompilationUnitTests.java >--- src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 10 Nov 2009 16:53:04 -0000 1.70 >+++ src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 24 Feb 2010 06:03:25 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -2436,4 +2436,37 @@ > annotations); > } > >+public void testBug246594() throws CoreException { >+ createWorkingCopy( >+ "package p;\n" + >+ "public class Z<T extends Object & I<? super T>> {\n" + >+ "}\n" + >+ "public interface I<T> {}" >+ ); >+ IType type = this.workingCopy.getType("Z"); >+ ITypeParameter[] typeParameters = type.getTypeParameters(); >+ assertStringsEqual("Type parameter signature", "T:QObject;:QI<-QT;>;\n", type.getTypeParameterSignatures()); >+ assertStringsEqual("Type parameter bounds signatures", >+ "QObject;\n" + >+ "QI<-QT;>;\n", >+ typeParameters[0].getBoundsSignatures()); >+} >+public void testBug246594a() throws CoreException { >+ createWorkingCopy( >+ "package p;\n" + >+ "interface Collection<E> {\n" + >+ "public <T> boolean containsAll(Collection<T> c);\n" + >+ "public <T extends E & I<? super String>> boolean addAll(Collection<T> c);\n" + >+ "}" + >+ "public interface I<T> {}"); >+ IMethod[] methods = this.workingCopy.getType("Collection").getMethods();//<T:TE;> >+ ITypeParameter[] typeParameters = methods[1].getTypeParameters(); >+ assertStringsEqual("Type parameter bounds signatures", >+ "QE;\n" + >+ "QI<-QString;>;\n", >+ typeParameters[0].getBoundsSignatures()); >+ >+} >+ >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 246594
:
159088
|
159530
| 160033