mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline: warn if assignment with operation (IDEA-80348)
This commit is contained in:
@@ -308,7 +308,9 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
|
||||
}
|
||||
|
||||
if (def instanceof PsiReferenceExpression && def.getParent() instanceof PsiAssignmentExpression) {
|
||||
final PsiExpression rExpr = ((PsiAssignmentExpression)def.getParent()).getRExpression();
|
||||
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)def.getParent();
|
||||
if (assignmentExpression.getOperationTokenType() != JavaTokenType.EQ) return null;
|
||||
final PsiExpression rExpr = assignmentExpression.getRExpression();
|
||||
if (rExpr != null) return rExpr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo() {
|
||||
int x = 1;
|
||||
x += 1;
|
||||
int y = <caret>x;
|
||||
}
|
||||
}
|
||||
@@ -132,6 +132,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testNonEqAssignment() throws Exception {
|
||||
doTest(false, "Cannot perform refactoring.\n" +
|
||||
"Variable 'x' is accessed for writing.");
|
||||
}
|
||||
|
||||
private void doTest(final boolean inlineDef, String conflictMessage) throws Exception {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user