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 115025 Details for
Bug 249567
Incorrect behavior of Util.getUnresolvedJavaElement(...) method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Improved fix and more tests
249567.txt (text/plain), 6.56 KB, created by
Jerome Lanneluc
on 2008-10-14 08:58:30 EDT
(
hide
)
Description:
Improved fix and more tests
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-10-14 08:58:30 EDT
Size:
6.56 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java,v >retrieving revision 1.59 >diff -u -r1.59 ASTModelBridgeTests.java >--- src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 27 Jun 2008 16:02:37 -0000 1.59 >+++ src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 14 Oct 2008 12:57:57 -0000 >@@ -1728,6 +1728,110 @@ > element > ); > } >+ >+ /* >+ * Ensures that the IJavaElement of an IBinding representing a method is correct. >+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=249567 ) >+ */ >+ public void testMethod12() throws Exception { >+ try { >+ createFolder("/P/src/p1"); >+ createFile( >+ "/P/src/p1/X249567.java", >+ "package p1;\n" + >+ "public class X249567 {}" >+ ); >+ createFolder("/P/src/p2"); >+ createFile( >+ "/P/src/p2/X249567.java", >+ "package p2;\n" + >+ "public class X249567 {}" >+ ); >+ ASTNode node = buildAST( >+ "public class X {\n" + >+ " void foo(p1.X249567 x) {\n" + >+ " }\n" + >+ " /*start*/void foo(p2.X249567 x) {\n" + >+ " }/*end*/\n" + >+ "}" >+ ); >+ IBinding binding = ((MethodDeclaration) node).resolveBinding(); >+ IJavaElement element = binding.getJavaElement(); >+ assertElementEquals( >+ "Unexpected Java element", >+ "foo(p2.X249567) [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]", >+ element >+ ); >+ } finally { >+ deleteFolder("/P/src/p1"); >+ deleteFolder("/P/src/p2"); >+ } >+ } >+ >+ /* >+ * Ensures that the IJavaElement of an IBinding representing a method is correct. >+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=249567 ) >+ */ >+ public void testMethod13() throws Exception { >+ try { >+ createFolder("/P/src/p1"); >+ createFile( >+ "/P/src/p1/X249567.java", >+ "package p1;\n" + >+ "public class X249567 {\n" + >+ " public class Member {}\n" + >+ "}" >+ ); >+ ASTNode node = buildAST( >+ "public class X {\n" + >+ " /*start*/void foo(p1.X249567.Member x) {\n" + >+ " }/*end*/\n" + >+ "}" >+ ); >+ IBinding binding = ((MethodDeclaration) node).resolveBinding(); >+ IJavaElement element = binding.getJavaElement(); >+ assertElementEquals( >+ "Unexpected Java element", >+ "foo(p1.X249567.Member) [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]", >+ element >+ ); >+ } finally { >+ deleteFolder("/P/src/p1"); >+ } >+ } >+ >+ /* >+ * Ensures that the IJavaElement of an IBinding representing a method is correct. >+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=249567 ) >+ */ >+ public void testMethod14() throws Exception { >+ try { >+ createFolder("/P/src/p1"); >+ createFile( >+ "/P/src/p1/X249567.java", >+ "package p1;\n" + >+ "public class X249567 {\n" + >+ " public class Member<T> {}\n" + >+ "}" >+ ); >+ ASTNode node = buildAST( >+ "public class X {\n" + >+ " /*start*/void foo(p1.X249567.Member<java.lang.String> x) {\n" + >+ " }/*end*/\n" + >+ "}" >+ ); >+ IBinding binding = ((MethodDeclaration) node).resolveBinding(); >+ IJavaElement element = binding.getJavaElement(); >+ assertElementEquals( >+ "Unexpected Java element", >+ "foo(p1.X249567.Member<java.lang.String>) [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]", >+ element >+ ); >+ } finally { >+ deleteFolder("/P/src/p1"); >+ } >+ } >+ > /* > * Ensures that the IJavaElement of an IBinding representing a package is correct. > */ >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java,v >retrieving revision 1.123 >diff -u -r1.123 Util.java >--- model/org/eclipse/jdt/internal/core/util/Util.java 12 Sep 2008 11:46:24 -0000 1.123 >+++ model/org/eclipse/jdt/internal/core/util/Util.java 14 Oct 2008 12:57:59 -0000 >@@ -1365,11 +1365,19 @@ > if (isInnerBinaryTypeConstructor) > parameterSignatures[0] = new String(enclosingType.genericTypeSignature()).replace('/', '.'); > for (int i = 0; i < length; i++) { >- parameterSignatures[declaringIndex + i] = new String(parameters[i].genericTypeSignature()).replace('/', '.'); >+ char[] signature = parameters[i].genericTypeSignature(); >+ if (isBinary) { >+ signature = CharOperation.replaceOnCopy(signature, '/', '.'); >+ } else { >+ signature = toUnresolvedTypeSignature(signature); >+ } >+ parameterSignatures[declaringIndex + i] = new String(signature); > } > IMethod result = declaringType.getMethod(selector, parameterSignatures); > if (isBinary) > return (JavaElement) result; >+ if (result.exists()) // if perfect match (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=249567 ) >+ return (JavaElement) result; > IMethod[] methods = null; > try { > methods = declaringType.getMethods(); >@@ -2347,6 +2355,44 @@ > } > return result; > } >+ private static char[] toUnresolvedTypeSignature(char[] signature) { >+ int length = signature.length; >+ if (length <= 1) >+ return signature; >+ StringBuffer buffer = new StringBuffer(length); >+ toUnresolvedTypeSignature(signature, 0, length, buffer); >+ int bufferLength = buffer.length(); >+ char[] result = new char[bufferLength]; >+ buffer.getChars(0, bufferLength, result, 0); >+ return result; >+ } >+ >+ private static int toUnresolvedTypeSignature(char[] signature, int start, int length, StringBuffer buffer) { >+ if (signature[start] == Signature.C_RESOLVED) >+ buffer.append(Signature.C_UNRESOLVED); >+ else >+ buffer.append(signature[start]); >+ for (int i = start+1; i < length; i++) { >+ char c = signature[i]; >+ switch (c) { >+ case '/': >+ case Signature.C_DOLLAR: >+ buffer.append(Signature.C_DOT); >+ break; >+ case Signature.C_GENERIC_START: >+ buffer.append(Signature.C_GENERIC_START); >+ i = toUnresolvedTypeSignature(signature, i+1, length, buffer); >+ break; >+ case Signature.C_GENERIC_END: >+ buffer.append(Signature.C_GENERIC_END); >+ return i; >+ default: >+ buffer.append(c); >+ break; >+ } >+ } >+ return length; >+ } > private static void appendArrayTypeSignature(char[] string, int start, StringBuffer buffer, boolean compact) { > int length = string.length; > // need a minimum 2 char
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 249567
:
114960
| 115025