mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] Fix handling unreachable statements after try (IDEA-226599)
GitOrigin-RevId: 206f9f82c377ed1301986585f20d4b0fc7c99a30
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b7c6103f12
commit
283d54c49b
+3
-2
@@ -90,8 +90,9 @@ public class DeleteCatchFix implements IntentionActionWithFixAllOption {
|
||||
boolean mayCompleteNormally = ControlFlowUtils.codeBlockMayCompleteNormally(tryBlock);
|
||||
if (!mayCompleteNormally) {
|
||||
PsiElement nextElement = PsiTreeUtil.skipWhitespacesAndCommentsForward(tryStatement.getNextSibling());
|
||||
PsiElement lastElement = PsiTreeUtil.skipWhitespacesAndCommentsBackward(((PsiCodeBlock)tryParent).getRBrace());
|
||||
if (nextElement != null && lastElement != null) {
|
||||
PsiJavaToken rBrace = ((PsiCodeBlock)tryParent).getRBrace();
|
||||
PsiElement lastElement = PsiTreeUtil.skipWhitespacesAndCommentsBackward(rBrace);
|
||||
if (nextElement != null && lastElement != null && nextElement != rBrace) {
|
||||
tryParent.deleteChildRange(nextElement, lastElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with 'cs'" "true"
|
||||
import java.nio.charset.*;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
class X {
|
||||
byte[] convert(String str, Charset cs) {
|
||||
return str.getBytes(cs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'cs'" "true"
|
||||
import java.nio.charset.*;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
class X {
|
||||
byte[] convert(String str, Charset cs) {
|
||||
try {
|
||||
return str.getBytes(<caret>cs.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user