From 01366c7f83d63873e0f1fc282ce8851f51166c4d Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Wed, 6 Jul 2016 10:53:00 +0300 Subject: [PATCH] type migration: do not allow start "void" variable migration --- .../typeMigration/ui/TypeMigrationDialog.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java index be9fc5f5d887..ccd8b3ea120d 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java @@ -192,6 +192,7 @@ public abstract class TypeMigrationDialog extends RefactoringDialog { protected void canRun() throws ConfigurationException { super.canRun(); if (!checkType(getMigrationType())) throw new ConfigurationException("\'" + myTypeCodeFragment.getText() + "\' is invalid type"); + if (isVoidVariableMigration()) throw new ConfigurationException("\'void\' is not applicable"); } @Override @@ -311,6 +312,15 @@ public abstract class TypeMigrationDialog extends RefactoringDialog { return element.toString(); } + + private boolean isVoidVariableMigration() { + if (!PsiType.VOID.equals(getMigrationType())) return false; + for (PsiElement root : myRoots) { + if (root instanceof PsiVariable) return true; + } + return false; + } + private static boolean checkType(final PsiType type) { if (type == null) return false; if (!type.isValid()) return false;