mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
IDEA-111523 (the intention is only supposed to work inside regular assignment)
This commit is contained in:
+3
-1
@@ -53,8 +53,10 @@ public class MoveFieldAssignmentToInitializerAction extends BaseIntentionAction
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
final PsiAssignmentExpression assignment = getAssignmentUnderCaret(editor, file);
|
||||
PsiAssignmentExpression assignment = getAssignmentUnderCaret(editor, file);
|
||||
if (assignment == null) return false;
|
||||
PsiElement parent = assignment.getParent();
|
||||
if (!(parent instanceof PsiExpressionStatement)) return false;
|
||||
PsiField field = getAssignedField(assignment);
|
||||
if (field == null || field.hasInitializer()) return false;
|
||||
PsiClass psiClass = field.getContainingClass();
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Move assignment to field declaration" "false"
|
||||
class Wtf {
|
||||
int myWtf;
|
||||
|
||||
void whatever() {
|
||||
<caret>myWtf = Math,max(myWtf, getWtf());
|
||||
}
|
||||
|
||||
int getWtf() { return 42; }
|
||||
}
|
||||
Reference in New Issue
Block a user