mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ManualMinMaxCalculationInspection: remove implicit else branch during replacement (IDEA-221837)
GitOrigin-RevId: 68d542bcaa2ccaffa7b8b82a2f5a909ae08d2fd6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5c617cde0e
commit
ed0eda2fbb
@@ -140,6 +140,10 @@ public class ManualMinMaxCalculationInspection extends AbstractBaseJavaLocalInsp
|
||||
CommentTracker tracker = new CommentTracker();
|
||||
PsiStatement thenBranch = model.getThenBranch();
|
||||
tracker.text(thenBranch);
|
||||
PsiStatement elseBranch = model.getElseBranch();
|
||||
if (!PsiTreeUtil.isAncestor(ifStatement, elseBranch, true)) {
|
||||
new CommentTracker().deleteAndRestoreComments(elseBranch);
|
||||
}
|
||||
PsiElement result = PsiReplacementUtil.replaceStatement(ifStatement, thenBranch.getText(), tracker);
|
||||
SimplifiableIfStatementInspection.tryJoinDeclaration(result);
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with 'Math.min'" "true"
|
||||
class Test {
|
||||
|
||||
public int mymin(int a, int b) {
|
||||
return Math.min(a, b);
|
||||
/*comment*/
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Math.min'" "true"
|
||||
class Test {
|
||||
|
||||
public int mymin(int a, int b) {
|
||||
if<caret>(a < b) {
|
||||
return a;
|
||||
}
|
||||
return (/*comment*/(b));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user