Community
Participate
Working Groups
The quickfix "extract to checked local variable" has multiple issues: a) It cannot handle generics: <Object> instead of <T> in line 27 b) It cannot detect if there is already an immediately surrounding null-check (it will just stack the ifs) c) It only applies to 110 annotation error "Potential null pointer access: The field list is specified as @Nullable" but not to 200 annotation error "Potential null pointer access: this expression has a '@Nullable' type". d) The other quickfixes "extract to local variable" and its companion "extract local variable (replace all occurrences)" handle generics just fine, but won't insert the extra if for the null-check if it's not present. Can you please try to: A) Make it handle generics. B) Check the immediately preceding statement, if it already is a null check (don't offer "extract to checked local variable" but instead fall back to "extract to local variable"). C) Also apply Quickfix to 200 error Tested with org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar and org.eclipse.jdt.annotation_2.0.0.v20140415-1436.jar
Created attachment 245329 [details] Demo-sourcecode
(In reply to Holger Klene from comment #0) > Can you please try to: > A) Make it handle generics. The problem is specific to the use of a type variable as a type argument. List<String>, e.g., is handled correctly. From a quick comparison it looks like org.eclipse.jdt.internal.ui.text.correction.proposals.ExtractToNullCheckedLocalProposal.newType(ITypeBinding, AST, ImportRewrite) is doing a lot of stuff (incompletely it seems) that is better delegated to ImportRewrite.addImport(). > B) Check the immediately preceding statement, if it already is a null check > (don't offer "extract to checked local variable" but instead fall back to > "extract to local variable"). Not sure how much effort this would cost. > C) Also apply Quickfix to 200 error Should be done as part of bug 427423.
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. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. 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.
At least issue (A) should be addressed.
.
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.