mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SurroundWithTryCatchFix: support local classes properly
GitOrigin-RevId: 50ee098d1287f976331692361ff29bf3dbbbd26a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d26a9eee44
commit
5e592af488
+1
-7
@@ -46,13 +46,7 @@ public class SurroundWithTryCatchFix implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (myElement != null && myElement.isValid()) {
|
||||
PsiElement parentStatement = RefactoringUtil.getParentStatement(myElement, false);
|
||||
return !(parentStatement instanceof PsiDeclarationStatement &&
|
||||
((PsiDeclarationStatement)parentStatement).getDeclaredElements()[0] instanceof PsiClass);
|
||||
}
|
||||
|
||||
return false;
|
||||
return myElement != null && myElement.isValid();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Surround with try/catch" "true"
|
||||
import java.io.*;
|
||||
|
||||
class C {
|
||||
public void m() {
|
||||
class Local {
|
||||
InputStream in;
|
||||
|
||||
{
|
||||
try {
|
||||
in = new FileInputStream("");
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
// "Surround with try/catch" "false"
|
||||
// "Add exception to method signature" "false"
|
||||
// "Surround with try/catch" "true"
|
||||
import java.io.*;
|
||||
|
||||
class C {
|
||||
|
||||
Reference in New Issue
Block a user