type migration: do not allow start "void" variable migration

This commit is contained in:
Dmitry Batkovich
2016-07-06 18:25:39 +03:00
parent c400fa39ce
commit 01366c7f83
@@ -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;