type migration: to void: remove unused variables in simple cases IDEA-158196

This commit is contained in:
Dmitry Batkovich
2016-08-16 10:08:35 +03:00
parent ef5577ac06
commit 63e73c1fe8
15 changed files with 225 additions and 12 deletions
@@ -846,6 +846,22 @@ public class TypeMigrationTest extends TypeMigrationTestBase {
doTestFieldsType("Test", myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), "a", "b");
}
public void testVoidMigrationInVarDecl() {
doTestMethodType("migrationMethod", PsiType.VOID);
}
public void testVoidMigrationInVarDeclFailed() {
doTestMethodType("migrationMethod", PsiType.VOID);
}
public void testVoidMigrationInAssignment() {
doTestMethodType("migrationMethod", PsiType.VOID);
}
public void testVoidMigrationInAssignmentFailed() {
doTestMethodType("migrationMethod", PsiType.VOID);
}
private void doTestReturnType(final String methodName, final String migrationType) {
start(new RulesProvider() {
@Override
@@ -0,0 +1,10 @@
Types:
PsiMethod:migrationMethod : void
PsiMethodCallExpression:migrationMethod() : void
Conversions:
"" -> $
migrationMethod() -> $
New expression type changes:
Fails:
@@ -0,0 +1,11 @@
class Test {
static void migrationMethod() {
}
void m() {
String sss;
migrationMethod();
sss = "";
}
}
@@ -0,0 +1,12 @@
class Test {
static String migrationMethod() {
return "";
}
void m() {
String sss;
sss = migrationMethod();
sss = "";
}
}
@@ -0,0 +1,10 @@
Types:
PsiMethod:migrationMethod : void
PsiMethodCallExpression:migrationMethod() : void
Conversions:
"" -> $
New expression type changes:
Fails:
migrationMethod()->void
@@ -0,0 +1,12 @@
class Test {
static void migrationMethod() {
}
void m() {
String sss;
sss = migrationMethod();
System.out.println(sss);
sss = "";
}
}
@@ -0,0 +1,13 @@
class Test {
static String migrationMethod() {
return "";
}
void m() {
String sss;
sss = migrationMethod();
System.out.println(sss);
sss = "";
}
}
@@ -0,0 +1,10 @@
Types:
PsiMethod:migrationMethod : void
PsiMethodCallExpression:migrationMethod() : void
Conversions:
"" -> $
migrationMethod() -> $
New expression type changes:
Fails:
@@ -0,0 +1,12 @@
class Test {
static void migrationMethod() {
}
void m() {
String sss;
migrationMethod();
sss = "";
System.out.println(sss);
}
}
@@ -0,0 +1,12 @@
class Test {
static String migrationMethod() {
return "";
}
void m() {
String sss = migrationMethod();
sss = "";
System.out.println(sss);
}
}
@@ -0,0 +1,10 @@
Types:
PsiMethod:migrationMethod : void
PsiMethodCallExpression:migrationMethod() : void
Conversions:
"" -> $
New expression type changes:
Fails:
migrationMethod()->void
@@ -0,0 +1,10 @@
class Test {
static void migrationMethod() {
}
void m() {
String sss = migrationMethod();
System.out.println(sss);
}
}
@@ -0,0 +1,11 @@
class Test {
static String migrationMethod() {
return "";
}
void m() {
String sss = migrationMethod();
System.out.println(sss);
}
}