mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-19530 - AIOOBE: GroovyVariableValidator.isOKImpl
This commit is contained in:
+2
-1
@@ -121,4 +121,5 @@ changing.signature.of.0=Changing signature of {0}
|
||||
refactored.method.will.cover.closure.property=Refactored method will override closure property ''{0}'' in {1}
|
||||
changeSignature.not.throwable.type=Wrong type: ''{0}'' for exception, should extend java.lang.Throwable
|
||||
changeSignature.wrong.type.for.exception=Wrong type: ''{0}'' for exception
|
||||
changeSignature.no.type.for.exception=Specify a type for exception
|
||||
changeSignature.no.type.for.exception=Specify a type for exception
|
||||
no.occurences.found=No occurences found
|
||||
+10
-2
@@ -38,6 +38,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlo
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
@@ -90,8 +91,9 @@ public abstract class GroovyIntroduceVariableBase implements RefactoringActionHa
|
||||
|
||||
private boolean invokeImpl(final Project project, final GrExpression selectedExpr, final Editor editor) {
|
||||
|
||||
if (selectedExpr == null) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(GroovyRefactoringBundle.message("selected.block.should.represent.an.expression"));
|
||||
if (selectedExpr == null || (selectedExpr instanceof GrClosableBlock && selectedExpr.getParent() instanceof GrStringInjection)) {
|
||||
String message =
|
||||
RefactoringBundle.getCannotRefactorMessage(GroovyRefactoringBundle.message("selected.block.should.represent.an.expression"));
|
||||
showErrorMessage(project, editor, message);
|
||||
return false;
|
||||
}
|
||||
@@ -145,6 +147,12 @@ public abstract class GroovyIntroduceVariableBase implements RefactoringActionHa
|
||||
|
||||
// Find occurrences
|
||||
final PsiElement[] occurrences = GroovyRefactoringUtil.getExpressionOccurrences(GroovyRefactoringUtil.getUnparenthesizedExpr(selectedExpr), tempContainer);
|
||||
if (occurrences == null || occurrences.length == 0) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(GroovyRefactoringBundle.message("no.occurences.found"));
|
||||
showErrorMessage(project, editor, message);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Getting settings
|
||||
Validator validator = new GroovyVariableValidator(this, project, selectedExpr, occurrences, tempContainer);
|
||||
GroovyIntroduceVariableDialog dialog = getDialog(project, editor, selectedExpr, type, occurrences, false, validator);
|
||||
|
||||
Reference in New Issue
Block a user