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 84733 Details for
Bug 209993
[1.5][search] Generic search does not get correctly type arguments from BindingKey
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v01.txt (text/plain), 11.04 KB, created by
Frederic Fusier
on 2007-12-07 09:20:37 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-12-07 09:20:37 EST
Size:
11.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java,v >retrieving revision 1.29 >diff -u -r1.29 JavaSearchPattern.java >--- search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java 5 Dec 2007 12:43:25 -0000 1.29 >+++ search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java 7 Dec 2007 14:13:49 -0000 >@@ -191,42 +191,42 @@ > * and type parameters for non-generic ones. > */ > char[][] extractMethodArguments(IMethod method) { >- String[] argumentsSignatures = null; >- BindingKey key; >- if (method.isResolved() && (key = new BindingKey(method.getKey())).isParameterizedMethod()) { >- argumentsSignatures = key.getTypeArguments(); >- } else { >- try { >- ITypeParameter[] parameters = method.getTypeParameters(); >- if (parameters != null) { >- int length = parameters.length; >- if (length > 0) { >- char[][] arguments = new char[length][]; >- for (int i=0; i<length; i++) { >- arguments[i] = Signature.createTypeSignature(parameters[i].getElementName(), false).toCharArray(); >- } >- return arguments; >+ >+ // Use bind key if the element is resolved >+ if (method.isResolved()) { >+ BindingKey bindingKey = new BindingKey(method.getKey()); >+ if (bindingKey.isParameterizedMethod()) { >+ String[] argumentsSignatures = bindingKey.getTypeArguments(); >+ int length = argumentsSignatures.length; >+ if (length > 0) { >+ char[][] methodArguments = new char[length][]; >+ for (int i=0; i<length; i++) { >+ methodArguments[i] = argumentsSignatures[i].toCharArray(); >+ CharOperation.replace(methodArguments[i], new char[] { '$', '/' }, '.'); > } >+ return methodArguments; > } > } >- catch (JavaModelException jme) { >- // do nothing >- } > return null; > } >- >- // Parameterized method >- if (argumentsSignatures != null) { >- int length = argumentsSignatures.length; >- if (length > 0) { >- char[][] methodArguments = new char[length][]; >- for (int i=0; i<length; i++) { >- methodArguments[i] = argumentsSignatures[i].toCharArray(); >- CharOperation.replace(methodArguments[i], new char[] { '$', '/' }, '.'); >+ >+ // Try to get the argument using the JavaModel info >+ try { >+ ITypeParameter[] parameters = method.getTypeParameters(); >+ if (parameters != null) { >+ int length = parameters.length; >+ if (length > 0) { >+ char[][] arguments = new char[length][]; >+ for (int i=0; i<length; i++) { >+ arguments[i] = Signature.createTypeSignature(parameters[i].getElementName(), false).toCharArray(); >+ } >+ return arguments; > } >- return methodArguments; > } > } >+ catch (JavaModelException jme) { >+ // do nothing >+ } > return null; > } > >@@ -394,46 +394,50 @@ > * and type parameters for non-generic ones > */ > void storeTypeSignaturesAndArguments(IType type) { >- BindingKey key; >- if (type.isResolved() && ((key = new BindingKey(type.getKey())).isParameterizedType() || key.isRawType())) { >- String signature = key.toSignature(); >- this.typeSignatures = Util.splitTypeLevelsSignature(signature); >- setTypeArguments(Util.getAllTypeArguments(this.typeSignatures)); >- } else { >- // Scan hierachy to store type arguments at each level >- char[][][] typeParameters = new char[10][][]; >- int ptr = -1; >- boolean hasParameters = false; >- try { >- IJavaElement parent = type; >- ITypeParameter[] parameters = null; >- while (parent != null && parent.getElementType() == IJavaElement.TYPE) { >- if (++ptr > typeParameters.length) { >- System.arraycopy(typeParameters, 0, typeParameters = new char[typeParameters.length+10][][], 0, ptr); >- } >- IType parentType = (IType) parent; >- parameters = parentType.getTypeParameters(); >- if (parameters !=null) { >- int length = parameters.length; >- if (length > 0) { >- hasParameters = true; >- typeParameters[ptr] = new char[length][]; >- for (int i=0; i<length; i++) >- typeParameters[ptr][i] = Signature.createTypeSignature(parameters[i].getElementName(), false).toCharArray(); >- } >+ if (type.isResolved()) { >+ BindingKey bindingKey = new BindingKey(type.getKey()); >+ if (bindingKey.isParameterizedType() || bindingKey.isRawType()) { >+ String signature = bindingKey.toSignature(); >+ this.typeSignatures = Util.splitTypeLevelsSignature(signature); >+ setTypeArguments(Util.getAllTypeArguments(this.typeSignatures)); >+ } >+ return; >+ } >+ >+ // Scan hierarchy to store type arguments at each level >+ char[][][] typeParameters = new char[10][][]; >+ int ptr = -1; >+ boolean hasParameters = false; >+ try { >+ IJavaElement parent = type; >+ ITypeParameter[] parameters = null; >+ while (parent != null && parent.getElementType() == IJavaElement.TYPE) { >+ if (++ptr > typeParameters.length) { >+ System.arraycopy(typeParameters, 0, typeParameters = new char[typeParameters.length+10][][], 0, ptr); >+ } >+ IType parentType = (IType) parent; >+ parameters = parentType.getTypeParameters(); >+ if (parameters !=null) { >+ int length = parameters.length; >+ if (length > 0) { >+ hasParameters = true; >+ typeParameters[ptr] = new char[length][]; >+ for (int i=0; i<length; i++) >+ typeParameters[ptr][i] = Signature.createTypeSignature(parameters[i].getElementName(), false).toCharArray(); > } >- parent = parent.getParent(); > } >+ parent = parent.getParent(); > } >- catch (JavaModelException jme) { >- return; >- } >- // Store type arguments if any >- if (hasParameters) { >- if (++ptr < typeParameters.length) >- System.arraycopy(typeParameters, 0, typeParameters = new char[ptr][][], 0, ptr); >- setTypeArguments(typeParameters); >- } >+ } >+ catch (JavaModelException jme) { >+ return; >+ } >+ >+ // Store type arguments if any >+ if (hasParameters) { >+ if (++ptr < typeParameters.length) >+ System.arraycopy(typeParameters, 0, typeParameters = new char[ptr][][], 0, ptr); >+ setTypeArguments(typeParameters); > } > } > public final String toString() { >Index: search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java,v >retrieving revision 1.40 >diff -u -r1.40 ConstructorPattern.java >--- search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java 28 Nov 2007 08:04:07 -0000 1.40 >+++ search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java 7 Dec 2007 14:13:49 -0000 >@@ -143,19 +143,19 @@ > > // Get unique key for parameterized constructors > String genericDeclaringTypeSignature = null; >- String key; >- BindingKey bindingKey; >- if (method.isResolved() && ((bindingKey = new BindingKey(key = method.getKey())).isParameterizedType() || bindingKey.isParameterizedMethod())) { >- genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key); >- } else { >- constructorParameters = true; >- } >- >- // Store type signature and arguments for declaring type >- if (genericDeclaringTypeSignature != null) { >- this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature); >- setTypeArguments(Util.getAllTypeArguments(this.typeSignatures)); >+ if (method.isResolved()) { >+ String key = method.getKey(); >+ BindingKey bindingKey = new BindingKey(key); >+ if (bindingKey.isParameterizedType()) { >+ genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key); >+ // Store type signature and arguments for declaring type >+ if (genericDeclaringTypeSignature != null) { >+ this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature); >+ setTypeArguments(Util.getAllTypeArguments(this.typeSignatures)); >+ } >+ } > } else { >+ this.constructorParameters = true; > storeTypeSignaturesAndArguments(method.getDeclaringType()); > } > >Index: search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java,v >retrieving revision 1.63 >diff -u -r1.63 MethodPattern.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java 28 Nov 2007 08:04:05 -0000 1.63 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java 7 Dec 2007 14:13:49 -0000 >@@ -158,19 +158,19 @@ > > // Get unique key for parameterized constructors > String genericDeclaringTypeSignature = null; >-// String genericSignature = null; >- String key; >- if (method.isResolved() && (new BindingKey(key = method.getKey())).isParameterizedMethod()) { >- genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key); >+ if (method.isResolved()) { >+ String key = method.getKey(); >+ BindingKey bindingKey = new BindingKey(key); >+ if (bindingKey.isParameterizedType()) { >+ genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key); >+ // Store type signature and arguments for declaring type >+ if (genericDeclaringTypeSignature != null) { >+ this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature); >+ setTypeArguments(Util.getAllTypeArguments(this.typeSignatures)); >+ } >+ } > } else { > methodParameters = true; >- } >- >- // Store type signature and arguments for declaring type >- if (genericDeclaringTypeSignature != null) { >- this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature); >- setTypeArguments(Util.getAllTypeArguments(this.typeSignatures)); >- } else { > storeTypeSignaturesAndArguments(declaringType); > } > >Index: buildnotes_jdt-core.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v >retrieving revision 1.6214 >diff -u -r1.6214 buildnotes_jdt-core.html >--- buildnotes_jdt-core.html 5 Dec 2007 12:43:25 -0000 1.6214 >+++ buildnotes_jdt-core.html 7 Dec 2007 14:13:49 -0000 >@@ -48,7 +48,11 @@ > <h2>What's new in this drop</h2> > > <h3>Problem Reports Fixed</h3> >-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=211781">211781</a> >+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=209993">209993</a> >+[1.5][search] Generic search does not work properly while using BindingKey >+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=209993">209993</a> >+[1.5][search] Generic search does not work properly while using BindingKey >+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=211781">211781</a> > [search] clarify 'ALLOCATION_EXPRESSION_TYPE_REFERENCE' > <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=211779">211779</a> > [search] better name for SUPERTYPE_TYPE_REFERENCE?
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 209993
: 84733