mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
disable split into decl 7/ assignment for conflicting names (IDEA-173787)
for statement induces another declaration parent where another local variable could have been declared
This commit is contained in:
@@ -78,17 +78,23 @@ public class SplitDeclarationAction extends PsiElementBaseIntentionAction {
|
||||
if (declaredElements.length == 1) {
|
||||
PsiLocalVariable var = (PsiLocalVariable)declaredElements[0];
|
||||
if (var.getInitializer() == null) return false;
|
||||
PsiElement parent = decl.getParent();
|
||||
if (parent instanceof PsiForStatement) {
|
||||
String varName = var.getName();
|
||||
if (varName == null ||
|
||||
JavaPsiFacade.getInstance(decl.getProject()).getResolveHelper().resolveReferencedVariable(varName, parent.getParent()) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
setText(CodeInsightBundle.message("intention.split.declaration.assignment.text"));
|
||||
return true;
|
||||
}
|
||||
else if (declaredElements.length > 1) {
|
||||
else {
|
||||
if (decl.getParent() instanceof PsiForStatement) return false;
|
||||
|
||||
setText(CodeInsightBundle.message("intention.split.declaration.text"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Split into declaration and assignment" "false"
|
||||
class Test {
|
||||
{
|
||||
for (int i<caret>=0; i<10; i++) {
|
||||
System.out.println();
|
||||
}
|
||||
int i = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user