mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
forbid introduce refactorings on resource from try-with-resources (IDEA-66788 )
This commit is contained in:
+6
@@ -70,6 +70,12 @@ public class IntroduceConstantHandler extends BaseExpressionToFieldHandler {
|
||||
}
|
||||
|
||||
protected boolean invokeImpl(final Project project, final PsiLocalVariable localVariable, final Editor editor) {
|
||||
final PsiElement parent = localVariable.getParent();
|
||||
if (!(parent instanceof PsiDeclarationStatement)) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.or.expression.name"));
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, getHelpID());
|
||||
return false;
|
||||
}
|
||||
final LocalToFieldHandler localToFieldHandler = new LocalToFieldHandler(project, true){
|
||||
@Override
|
||||
protected Settings showRefactoringDialog(PsiClass aClass,
|
||||
|
||||
@@ -155,6 +155,12 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler {
|
||||
}
|
||||
|
||||
protected boolean invokeImpl(final Project project, PsiLocalVariable localVariable, final Editor editor) {
|
||||
final PsiElement parent = localVariable.getParent();
|
||||
if (!(parent instanceof PsiDeclarationStatement)) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.or.expression.name"));
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, getHelpID());
|
||||
return false;
|
||||
}
|
||||
LocalToFieldHandler localToFieldHandler = new LocalToFieldHandler(project, false){
|
||||
@Override
|
||||
protected Settings showRefactoringDialog(PsiClass aClass,
|
||||
|
||||
+8
@@ -127,6 +127,14 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
return false;
|
||||
}
|
||||
|
||||
if (localVar != null) {
|
||||
final PsiElement parent = localVar.getParent();
|
||||
if (!(parent instanceof PsiDeclarationStatement)) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.or.expression.name"));
|
||||
showErrorMessage(myProject, message, editor);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (method == null) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("is.not.supported.in.the.current.context", REFACTORING_NAME));
|
||||
|
||||
Reference in New Issue
Block a user