| Summary: | [quickfixes] Improper quickfixes proposed for loop variable | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Jeff Johnston <jjohnstn> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED MOVED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | kalyan_prasad, noopur_gupta |
| Version: | 4.20 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| See Also: |
https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/182925 https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=a0e9bdf08bf914efcb4b7185628ef7d35e143ae2 |
||
| Whiteboard: | stalebug | ||
I20210707-1800
win32-java11
UnresolvedTypesQuickFixTest.testForEachMissingType() failed with:
expected:<...; public class E1 { [ /** * Method foo * * @param a * - integer input * * @return integer */ public int foo(int a) { return 0; ]} }> but was:<...; public class E1 { [ /** * Method foo * * @param a - integer input * * @return integer */ public int foo(int a) { return 0; ]} }>
org.junit.ComparisonFailure: expected:<...;
public class E1 {
[ /**
* Method foo
*
* @param a
* - integer input
*
* @return integer
*/
public int foo(int a) {
return 0;
]}
}> but was:<...;
public class E1 {
[ /**
* Method foo
*
* @param a - integer input
*
* @return integer
*/
public int foo(int a) {
return 0;
]}
}>
at org.junit.Assert.assertEquals(Assert.java:117)
at org.junit.Assert.assertEquals(Assert.java:146)
at org.eclipse.jdt.ui.tests.quickfix.SaveParticipantTest.testFormatChangeBug488229_3(SaveParticipantTest.java:990)
...
Jeff, can you try to modify the example to get a stable test result?
(In reply to Noopur Gupta from comment #1) > I20210707-1800 > > win32-java11 > > UnresolvedTypesQuickFixTest.testForEachMissingType() failed with: Pasted the wrong stack trace above. Here's the failure trace from build for this test: Wrong number of proposals, is: 7, expected: 6 - Create loop variable 'element' package pack; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (HashSet<? super Integer> element: list) { } } } - Change to 'Statement' (java.sql) package pack; import java.sql.Statement; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (Statement: list) { } } } - Change to 'ElementType' (java.lang.annotation) package pack; import java.lang.annotation.ElementType; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (ElementType: list) { } } } - Create class 'element' - Create interface 'element' - Create enum 'element' - Fix project setup... package pack; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (element: list) { } } } java.lang.AssertionError: Wrong number of proposals, is: 7, expected: 6 - Create loop variable 'element' package pack; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (HashSet<? super Integer> element: list) { } } } - Change to 'Statement' (java.sql) package pack; import java.sql.Statement; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (Statement: list) { } } } - Change to 'ElementType' (java.lang.annotation) package pack; import java.lang.annotation.ElementType; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (ElementType: list) { } } } - Create class 'element' - Create interface 'element' - Create enum 'element' - Fix project setup... package pack; import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (element: list) { } } } at org.junit.Assert.fail(Assert.java:89) at org.eclipse.jdt.ui.tests.quickfix.QuickFixTest.assertNumberOfProposals(QuickFixTest.java:475) at org.eclipse.jdt.ui.tests.quickfix.UnresolvedTypesQuickFixTest.testForEachMissingType(UnresolvedTypesQuickFixTest.java:1603 ... Jeff, can you try to modify the example to get a stable test result? (In reply to Noopur Gupta from comment #3) > Jeff, can you try to modify the example to get a stable test result? Ok. New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/182925 Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/182925 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=a0e9bdf08bf914efcb4b7185628ef7d35e143ae2 This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
For the following snippet taken from UnresolvedTypesQuickFixTest.testForEachMissingType() import java.util.*; public class E { public void foo(ArrayList<? extends HashSet<? super Integer>> list) { for (element: list) { } } } A number of quick fix suggestions are made. The first one: Create loop variable 'element' seems to be the only valid one. Among others are: Create enum element Create class element Create interface element Change to ElementType (java.annotation) Change to Statement (java.sql) Fix project setup... I actually get many more class suggestions when running in my child Eclipse (70). All of them but the first one are invalid choices. First of all, they cause another error in that you have a class, interface, enum specifier but no variable aname. When you add a variable name, none of the suggestions are compatible with the type of "list". Also, I have found that there is some randomness on the number of suggested quickfixes which makes the test sometimes fail in running the JDT UI test suite. The test is expecting 6 suggestions and I have seen it report 7 in the test run (including Statement and ElementType). I have run the test locally and it succeeded. Running in a child Eclipse I see 70 quickfixes with a lot of other class suggestions but all of the ones in the failed test show up (i.e. all 7).