Community
Participate
Working Groups
BETA_JAVA7 After the fix for bug 343342, we no longer propose strings inside the case expression. We should suggest them if the compliance is 1.7 or greater and the switch is done on a string type public class Try { void f(String a) { String xyz = null; final String xyzz = ""; switch (a){ case xy[CTRL-SPACE]: break; // propose xyz and xyzz here } } }
Created attachment 193812 [details] proposed fix v1.0 + regression tests This fix follows from the fix for bug 343342, and makes sure that not only are strings proposed in compliance >= 1.7, but also that they are proposed only when the switch has been done on a string
Olivier, can you please review, time permitting? Thanks! With this fix, we'll atleast be more relevant in the proposals we give for switch case in all compliance levels.
Looks good. I would make a small change though. Instead of testing == with scope.getJavaLangString(). We can simply test == with the binding id and org.eclipse.jdt.internal.compiler.lookup.TypeIds.T_JavaLangString. This of course means that we have to make sure the binding is not null before we get its id.
Created attachment 193824 [details] released patch Same fix with the change suggested by Olivier.
Released in BETA_JAVA7 branch.
Note that as opposed to what the comment in the code snippet claims, we propose only xyzz (which is as it should be). Verified using "Eclipse Java Development Tools Patch for Java 7 Support (BETA) 1.0.0.v20110623-0900 org.eclipse.jdt.patch.feature.group Eclipse.org"