-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong method redirect #1278
Comments
Using Eclipse 2023-06 I am unable to reproduce with the following simple source in the Java editor:
When I click on the foo(i) call, F3 takes me to the middle foo(Integer i) method. Are you able to recreate with this test case and if not is there a test you can post here? |
It's the same, but even when I select whole method's name it redirects to the wrong method.
`public class TestSelect {
` |
Hi @andreasdc Thanks for the sample. I can now reproduce it. It also fails for source hover. |
Transferring to jdt.core. New test case:
Selecting the foo call in foo2 above and hitting F3 ends up jumping to the foo(String) method. Hovering also shows the foo(String) method. I followed the Open Action to the org.eclipse.jdt.internal.codeassist.SelectionEngine.select() method: line 1086 which calls parsedUnit.resolve(); and ends up throwing a SelectionNodeFoundException from org.eclipse.jdt.internal.codeassist.select.SelectionOnMessageSend.resolveType(). Looking at the parent org.eclipse.jdt.internal.compiler.ast.Block for the if block in the debugger, I see:
I am unfamiliar with this code, but wonder why the Double test2; statement doesn't precede the SelectOnMessageSend in the block. I tried the same test on Eclipse 2022-03 and the test works correctly (F3 goes to foo(Double)). It fails on 2022-06 so some regression between those two releases. The initial sample from @andreasdc had test declared as Double. On 2022-03 and 2022-06 that causes an error marker stating that expression type cannot be sub-type of Pattern type. This error does not get shown in latest M2. |
See also #1288 |
The PR #1349 fixes this problem and includes a regression test from here. So I will close this as a duplicate |
Duplicate of #1195 |
Are you sure it's a duplicate? |
Yes, It is not a duplicate in the sense of the symptoms being the same, but the underlying problem being the same - that being incorrect recovery of the parse tree in the presence of pattern matching constructs. As documented here: #1278 (comment), the recovered parse tree is
which is wrong, the pattern binding variable's declaration should precede its use, not follow. #1349 is a substantial reimplementation of pattern matching support in code selection engine and subsumes the fix for the current problem and includes a regression test from here. So breathe easy :) |
This is a substantial reimplementation of the code selection support for pattern matching constructs. By using auxiliary stacks to record the state of the parser and by using that state to drive the bottom up context recovery and parse tree construction, we now rebuild the parse tree to sufficient detail to ascertain liveness of pattern binding variables at the point of selection. Fixes #1195 Fixes #769 Fixes #1263 Fixes #1360 Fixes #1364 Fixes #1278 Fixes #1288 Verifies https://bugs.eclipse.org/bugs/show_bug.cgi?id=573257 Verifies https://bugs.eclipse.org/bugs/show_bug.cgi?id=572975 Verifies https://bugs.eclipse.org/bugs/show_bug.cgi?id=576794
When you have methods with the same name, but handles different objects in the argument it redirects you to wrong method when you click f3. However when you select the whole name, not just click on it, you are being redirected to the correct method.
The text was updated successfully, but these errors were encountered: