invert boolean: disable for foreach params (IDEA-151634)

This commit is contained in:
Anna Kozlova
2016-02-19 19:18:43 +01:00
parent e6a49d0ab6
commit 3537458aa3
2 changed files with 15 additions and 5 deletions
@@ -66,13 +66,22 @@ public class JavaInvertBooleanDelegate extends InvertBooleanDelegate {
return null;
}
if (var instanceof PsiParameter && ((PsiParameter)var).getDeclarationScope() instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)((PsiParameter)var).getDeclarationScope();
final PsiMethod superMethod = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
if (superMethod == null) {
if (var instanceof PsiParameter) {
final PsiElement declarationScope = ((PsiParameter)var).getDeclarationScope();
if (declarationScope instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)declarationScope;
final PsiMethod superMethod = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
if (superMethod == null) {
return null;
}
var = superMethod.getParameterList().getParameters()[method.getParameterList().getParameterIndex((PsiParameter)var)];
}
else if (declarationScope instanceof PsiForeachStatement) {
CommonRefactoringUtil.showErrorHint(project, editor,
RefactoringBundle.message("invert.boolean.foreach"),
InvertBooleanHandler.REFACTORING_NAME, InvertBooleanHandler.INVERT_BOOLEAN_HELP_ID);
return null;
}
var = superMethod.getParameterList().getParameters()[method.getParameterList().getParameterIndex((PsiParameter)var)];
}
return var;
}
@@ -713,6 +713,7 @@ invert.boolean.elements.header={0} to invert
please.enter.a.valid.name.for.inverted.element=Please enter a valid name for inverted {0}
invert.boolean.name.of.inverted.element=&Name of inverted {0}:
invert.0.1=Invert {0} {1} and its usages
invert.boolean.foreach=Foreach parameter initializer can't be inverted
0.is.a.part.of.method.hierarchy.do.you.want.to.delete.multiple.parameters={0} is a part of method hierarchy. Do you want to delete multiple parameters?
0.is.a.part.of.method.hierarchy.do.you.want.to.delete.multiple.type.parameters={0} is a part of method hierarchy. Do you want to delete multiple type parameters?
move.inner.class.to.be.moved=Class to be moved