Community
Participate
Working Groups
Build ID: 3.3RC4 I20070608-1718 In the following piece of code: public class Test { void doLoad() { } void call() { doLoad(); } } 1. place the cursor on the call to doLoad() between the 'd' and the 'o' 2. press F3 3. The definition of doLoad is not found, an error message appears 'Current text selection does not resolve to a Java element' 4. any other position of the cursor and pressing F3 succeeds in locating the definition of doLoad()
reproduced in 3.3 RC4. ICompilationUnit.codeResolve is called with the offset 'o' in doLoad();. No result returned.
This is a regression added by the fix for bug 161400. The problem is caused by SelectionEngine#checkSelection(). To reproduce the problem the cursor must be inside an identifier. A part of the identifier must correspond to a keyword and the cursor must be just before the last character of the keyword. eg. d|oLoad fo|rmat This is not a common case but this is a regression. We should fix this bug for 3.3.1.
Created attachment 71305 [details] Proposed fix checkSelection() must scan from the beginning of the line to the end of the source instead of from the beginning of the line to the cursor location.
Released for 3.4M1. Test added: ResolveTests#testSelectOnCursor1() I will prepare a patch for 3.3.1.
Created attachment 72945 [details] Proposed patch for 3.3.1 The bug is a regression and the fix isn't risky. With this patch checkSelection() the end position of the scanner is set to the end of the source file instead of to the cursor position to be able to fully scan the selected token. Only the first token is scanned so move the end position won't have impact on performance.
Created attachment 72946 [details] Proposed patch for 3.3.1 The bug is a regression and the fix isn't risky. With this patch checkSelection() the end position of the scanner is set to the end of the source file instead of to the cursor position to be able to fully scan the selected token. Only the first token is scanned so move the end position won't have impact on performance.
+1 for 3.3.1
Released for 3.3.1 Test added: ResolveTests#testSelectOnCursor1()
Verified for 3.4M1 using build I20070802-0800.
Verified for 3.3.1 using M20070831-2000