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 111685 Details for
Bug 207657
[search] Exception when refactoring member type to top-level.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v03.txt (text/plain), 8.77 KB, created by
Frederic Fusier
on 2008-09-04 12:37:44 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2008-09-04 12:37:44 EDT
Size:
8.77 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java,v >retrieving revision 1.83 >diff -u -r1.83 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 27 Jun 2008 16:04:00 -0000 1.83 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 4 Sep 2008 14:27:04 -0000 >@@ -21,7 +21,6 @@ > import org.eclipse.jdt.internal.compiler.env.IBinaryType; > import org.eclipse.jdt.internal.compiler.lookup.*; > import org.eclipse.jdt.internal.compiler.util.SimpleSet; >-import org.eclipse.jdt.internal.core.JavaElement; > import org.eclipse.jdt.internal.core.search.BasicSearchEngine; > > public class MethodLocator extends PatternLocator { >@@ -498,12 +497,11 @@ > IType type = locator.lookupType(declaringClass); > if (type == null) return; // case of a secondary type > >- char[] bindingSelector = methodBinding.selector; >- boolean isBinary = type.isBinary(); >- IMethod method = null; >- TypeBinding[] parameters = methodBinding.original().parameters; >- int parameterLength = parameters.length; >- if (isBinary) { >+ // Report match for binary >+ if (type.isBinary()) { >+ IMethod method = null; >+ TypeBinding[] parameters = methodBinding.original().parameters; >+ int parameterLength = parameters.length; > char[][] parameterTypes = new char[parameterLength][]; > for (int i = 0; i<parameterLength; i++) { > char[] typeName = parameters[i].qualifiedSourceName(); >@@ -513,48 +511,41 @@ > parameterTypes[i] = typeName; > } > method = locator.createBinaryMethodHandle(type, methodBinding.selector, parameterTypes); >- } else { >- String[] parameterTypes = new String[parameterLength]; >- for (int i = 0; i < parameterLength; i++) { >- char[] typeName = parameters[i].shortReadableName(); >- if (parameters[i].isMemberType()) { >- typeName = CharOperation.subarray(typeName, CharOperation.indexOf('.', typeName)+1, typeName.length); >- } >- parameterTypes[i] = Signature.createTypeSignature(typeName, false); >- } >- method = type.getMethod(new String(bindingSelector), parameterTypes); >- } >- if (method == null || knownMethods.addIfNotIncluded(method) == null) return; >- >- IResource resource = type.getResource(); >- IBinaryType info = null; >- if (isBinary) { >+ if (method == null || knownMethods.addIfNotIncluded(method) == null) return; >+ >+ IResource resource = type.getResource(); > if (resource == null) > resource = type.getJavaProject().getProject(); >- info = locator.getBinaryInfo((org.eclipse.jdt.internal.core.ClassFile)type.getClassFile(), resource); >+ IBinaryType info = locator.getBinaryInfo((org.eclipse.jdt.internal.core.ClassFile)type.getClassFile(), resource); > locator.reportBinaryMemberDeclaration(resource, method, methodBinding, info, SearchMatch.A_ACCURATE); >- } else { >- if (declaringClass instanceof ParameterizedTypeBinding) >- declaringClass = ((ParameterizedTypeBinding) declaringClass).genericType(); >- ClassScope scope = ((SourceTypeBinding) declaringClass).scope; >- if (scope != null) { >- TypeDeclaration typeDecl = scope.referenceContext; >- AbstractMethodDeclaration methodDecl = null; >- AbstractMethodDeclaration[] methodDecls = typeDecl.methods; >- for (int i = 0, length = methodDecls.length; i < length; i++) { >- if (CharOperation.equals(bindingSelector, methodDecls[i].selector)) { >- methodDecl = methodDecls[i]; >- break; >- } >- } >- if (methodDecl != null) { >- int offset = methodDecl.sourceStart; >- Binding binding = methodDecl.binding; >- if (binding != null) >- method = (IMethod) ((JavaElement) method).resolved(binding); >- this.match = new MethodDeclarationMatch(method, SearchMatch.A_ACCURATE, offset, methodDecl.sourceEnd-offset+1, locator.getParticipant(), resource); >- locator.report(this.match); >- } >+ return; >+ } >+ >+ // When source is available, report match if method is found in the declaring type >+ IResource resource = type.getResource(); >+ if (declaringClass instanceof ParameterizedTypeBinding) >+ declaringClass = ((ParameterizedTypeBinding) declaringClass).genericType(); >+ ClassScope scope = ((SourceTypeBinding) declaringClass).scope; >+ if (scope != null) { >+ TypeDeclaration typeDecl = scope.referenceContext; >+ AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(methodBinding.original()); >+ if (methodDecl != null) { >+ // Create method handle from method declaration >+ String methodName = new String(methodBinding.selector); >+ Argument[] arguments = methodDecl.arguments; >+ int length = arguments == null ? 0 : arguments.length; >+ String[] parameterTypes = new String[length]; >+ for (int i = 0; i < length; i++) { >+ char[][] typeName = arguments[i].type.getParameterizedTypeName(); >+ parameterTypes[i] = Signature.createTypeSignature(CharOperation.concatWith(typeName, '.'), false); >+ } >+ IMethod method = type.getMethod(methodName, parameterTypes); >+ if (method == null || knownMethods.addIfNotIncluded(method) == null) return; >+ >+ // Create and report corresponding match >+ int offset = methodDecl.sourceStart; >+ this.match = new MethodDeclarationMatch(method, SearchMatch.A_ACCURATE, offset, methodDecl.sourceEnd-offset+1, locator.getParticipant(), resource); >+ locator.report(this.match); > } > } > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java,v >retrieving revision 1.177 >diff -u -r1.177 JavaSearchTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 27 Jun 2008 16:02:37 -0000 1.177 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 4 Sep 2008 14:27:09 -0000 >@@ -508,7 +508,7 @@ > "src/p/X.java void p.X.foo(int, String, X) [foo(int i, String s, X x)]\n" + > "src/p/Y.java void p.Y.bar() [bar()]\n" + > "src/p/Z.java void p.Z.foo(int, String, X) [foo(int i, String s, X x)]\n" + >- "src/p/A.java void p.A.foo(int, String, X) [foo()]", >+ "src/p/A.java void p.A.foo(int, String, X) [foo(int i, String s, X x)]", > this.resultCollector); > } > >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.153 >diff -u -r1.153 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 27 Jun 2008 16:02:40 -0000 1.153 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 4 Sep 2008 14:27:08 -0000 >@@ -9189,6 +9189,44 @@ > } > > /** >+ * @bug 207657: [search] Exception when refactoring member type to top-level. >+ * @test Ensure that searching method reference does not find wrong interface call >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=207657" >+ */ >+public void testBug207657() throws CoreException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Relationship.java", >+ "package test;\n" + >+ "public class Relationship {\n" + >+ " static public class End extends ConnectionEnd<Visitor> {\n" + >+ " public void accept(Visitor visitor) {\n" + >+ " visitor.visitRelationshipEnd(this);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" + >+ "interface Visitor {\n" + >+ " boolean visitRelationshipEnd(Relationship.End end);\n" + >+ " boolean visitAssociationEnd(Association.End end);\n" + >+ "}\n" + >+ "abstract class ConnectionEnd<V extends Visitor> {\n" + >+ " public abstract void accept( V visitor );\n" + >+ "}\n" + >+ "class Association extends Relationship {\n" + >+ " static public class RelEnd extends Relationship.End {\n" + >+ " public void accept(Visitor visitor) {\n" + >+ " visitor.visitAssociationEnd(this);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+ IType type = this.workingCopies[0].getType("Relationship").getType("End"); >+ searchDeclarationsOfSentMessages(type, this.resultCollector); >+ assertSearchResults( >+ "src/test/Relationship.java boolean test.Visitor.visitRelationshipEnd(Relationship.End) [visitRelationshipEnd(Relationship.End end)] EXACT_MATCH" >+ ); >+} >+ >+/** > * @bug 209054: [search] for references to method finds wrong interface call > * @test Ensure that searching method reference does not find wrong interface call > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209054"
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 207657
:
81605
| 111685