mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 22:11:40 +07:00
defer assignment: choose anchor from same code block
EA-48621 - assert: CompositeElement.addChild
This commit is contained in:
@@ -154,7 +154,10 @@ public class DeferFinalAssignmentFix implements IntentionAction {
|
||||
PsiElement element = null; //controlFlow.getEndOffset(codeBlock) == offset ? getEnclosingStatement(controlFlow.getElement(offset)) : null;
|
||||
while (offset < controlFlow.getSize()) {
|
||||
element = controlFlow.getElement(offset);
|
||||
if (element != null) element = PsiUtil.getEnclosingStatement(element);
|
||||
while (element != null) {
|
||||
if (element.getParent() == codeBlock) break;
|
||||
element = element.getParent();
|
||||
}
|
||||
int startOffset = controlFlow.getStartOffset(element);
|
||||
if (startOffset != -1 && startOffset >= minOffset && element instanceof PsiStatement) break;
|
||||
offset++;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Defer assignment to 'i' using temp variable" "true"
|
||||
class a {
|
||||
{
|
||||
final int i;
|
||||
int i1;
|
||||
if (true) i1 = 0;
|
||||
if (true) i1 = 0;
|
||||
i = i1;
|
||||
{if (false);}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Defer assignment to 'i' using temp variable" "true"
|
||||
class a {
|
||||
{
|
||||
final int i;
|
||||
if (true) i = 0;
|
||||
if (true) <caret>i = 0;
|
||||
{if (false);}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user