Lines 3352-3357
Link Here
|
3352 |
assertExpectedExistInProposals(proposals, expected); |
3352 |
assertExpectedExistInProposals(proposals, expected); |
3353 |
} |
3353 |
} |
3354 |
|
3354 |
|
|
|
3355 |
public void testUnusedPrivateFieldBug328481() throws Exception { |
3356 |
Hashtable hashtable= JavaCore.getOptions(); |
3357 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR); |
3358 |
JavaCore.setOptions(hashtable); |
3359 |
|
3360 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
3361 |
StringBuffer buf= new StringBuffer(); |
3362 |
buf.append("package test1;\n"); |
3363 |
buf.append("public class E {\n"); |
3364 |
buf.append(" private int count;\n"); |
3365 |
buf.append(" void foo(){;\n"); |
3366 |
buf.append(" count++;\n"); |
3367 |
buf.append(" count--;\n"); |
3368 |
buf.append(" --count;\n"); |
3369 |
buf.append(" ++count;\n"); |
3370 |
buf.append(" for ( ; ; count++) {\n"); |
3371 |
buf.append(" }\n"); |
3372 |
buf.append(" }\n"); |
3373 |
buf.append("}\n"); |
3374 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
3375 |
|
3376 |
CompilationUnit astRoot= getASTRoot(cu); |
3377 |
ArrayList proposals= collectCorrections(cu, astRoot); |
3378 |
assertNumberOfProposals(proposals, 2); |
3379 |
assertCorrectLabels(proposals); |
3380 |
|
3381 |
String[] expected= new String[2]; |
3382 |
|
3383 |
buf= new StringBuffer(); |
3384 |
buf.append("package test1;\n"); |
3385 |
buf.append("public class E {\n"); |
3386 |
buf.append(" void foo(){;\n"); |
3387 |
buf.append(" for ( ; ;) {\n"); |
3388 |
buf.append(" }\n"); |
3389 |
buf.append(" }\n"); |
3390 |
buf.append("}\n"); |
3391 |
expected[0]= buf.toString(); |
3392 |
|
3393 |
buf= new StringBuffer(); |
3394 |
buf.append("package test1;\n"); |
3395 |
buf.append("public class E {\n"); |
3396 |
buf.append(" private int count;\n"); |
3397 |
buf.append(" void foo(){;\n"); |
3398 |
buf.append(" setCount(getCount() + 1);\n"); |
3399 |
buf.append(" setCount(getCount() - 1);\n"); |
3400 |
buf.append(" setCount(getCount() - 1);\n"); |
3401 |
buf.append(" setCount(getCount() + 1);\n"); |
3402 |
buf.append(" for ( ; ; count++) {\n"); |
3403 |
buf.append(" }\n"); |
3404 |
buf.append(" }\n"); |
3405 |
buf.append(" public int getCount() {\n"); |
3406 |
buf.append(" return count;\n"); |
3407 |
buf.append(" }\n"); |
3408 |
buf.append(" public void setCount(int count) {\n"); |
3409 |
buf.append(" this.count = count;\n"); |
3410 |
buf.append(" }\n"); |
3411 |
buf.append("}\n"); |
3412 |
expected[1]= buf.toString(); |
3413 |
|
3414 |
assertExpectedExistInProposals(proposals, expected); |
3415 |
} |
3355 |
|
3416 |
|
3356 |
public void testUnusedVariable() throws Exception { |
3417 |
public void testUnusedVariable() throws Exception { |
3357 |
Hashtable hashtable= JavaCore.getOptions(); |
3418 |
Hashtable hashtable= JavaCore.getOptions(); |
Lines 3540-3546
Link Here
|
3540 |
assertEqualString(preview, buf.toString()); |
3601 |
assertEqualString(preview, buf.toString()); |
3541 |
} |
3602 |
} |
3542 |
|
3603 |
|
3543 |
public void testUnusedVariables5() throws Exception { |
3604 |
public void testUnusedVariable5() throws Exception { |
3544 |
Hashtable hashtable= JavaCore.getOptions(); |
3605 |
Hashtable hashtable= JavaCore.getOptions(); |
3545 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3606 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3546 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR); |
3607 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR); |
Lines 3582-3588
Link Here
|
3582 |
|
3643 |
|
3583 |
} |
3644 |
} |
3584 |
|
3645 |
|
3585 |
public void testUnusedVariables6() throws Exception { |
3646 |
public void testUnusedVariable6() throws Exception { |
3586 |
Hashtable hashtable= JavaCore.getOptions(); |
3647 |
Hashtable hashtable= JavaCore.getOptions(); |
3587 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3648 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3588 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR); |
3649 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR); |
Lines 3630-3636
Link Here
|
3630 |
} |
3691 |
} |
3631 |
|
3692 |
|
3632 |
|
3693 |
|
3633 |
public void testUnusedVariables7() throws Exception { |
3694 |
public void testUnusedVariable7() throws Exception { |
3634 |
Hashtable hashtable= JavaCore.getOptions(); |
3695 |
Hashtable hashtable= JavaCore.getOptions(); |
3635 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3696 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3636 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.ERROR); |
3697 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.ERROR); |
Lines 3682-3688
Link Here
|
3682 |
assertExpectedExistInProposals(proposals, expected); |
3743 |
assertExpectedExistInProposals(proposals, expected); |
3683 |
} |
3744 |
} |
3684 |
|
3745 |
|
3685 |
public void testUnusedVariables8() throws Exception { |
3746 |
public void testUnusedVariable8() throws Exception { |
3686 |
Hashtable hashtable= JavaCore.getOptions(); |
3747 |
Hashtable hashtable= JavaCore.getOptions(); |
3687 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3748 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3688 |
JavaCore.setOptions(hashtable); |
3749 |
JavaCore.setOptions(hashtable); |
Lines 3739-3746
Link Here
|
3739 |
assertExpectedExistInProposals(proposals, expected); |
3800 |
assertExpectedExistInProposals(proposals, expected); |
3740 |
} |
3801 |
} |
3741 |
|
3802 |
|
|
|
3803 |
public void testUnusedVariableBug328481() throws Exception { |
3804 |
Hashtable hashtable= JavaCore.getOptions(); |
3805 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3806 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.ERROR); |
3807 |
JavaCore.setOptions(hashtable); |
3808 |
|
3809 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
3810 |
StringBuffer buf= new StringBuffer(); |
3811 |
buf.append("package test1;\n"); |
3812 |
buf.append("public class E {\n"); |
3813 |
buf.append(" private void foo() {\n"); |
3814 |
buf.append(" int a= 10;\n"); |
3815 |
buf.append(" a++;\n"); |
3816 |
buf.append(" a--;\n"); |
3817 |
buf.append(" --a;\n"); |
3818 |
buf.append(" ++a;\n"); |
3819 |
buf.append(" for ( ; ; a++) {\n"); |
3820 |
buf.append(" }\n"); |
3821 |
buf.append(" }\n"); |
3822 |
buf.append("}\n"); |
3823 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
3824 |
|
3825 |
CompilationUnit astRoot= getASTRoot(cu); |
3826 |
ArrayList proposals= collectCorrections(cu, astRoot); |
3827 |
assertNumberOfProposals(proposals, 2); |
3828 |
assertCorrectLabels(proposals); |
3829 |
|
3830 |
String[] expected= new String[2]; |
3831 |
buf= new StringBuffer(); |
3832 |
buf.append("package test1;\n"); |
3833 |
buf.append("public class E {\n"); |
3834 |
buf.append(" private void foo() {\n"); |
3835 |
buf.append(" for ( ; ;) {\n"); |
3836 |
buf.append(" }\n"); |
3837 |
buf.append(" }\n"); |
3838 |
buf.append("}\n"); |
3839 |
expected[0]= buf.toString(); |
3840 |
|
3841 |
buf= new StringBuffer(); |
3842 |
buf.append("package test1;\n"); |
3843 |
buf.append("public class E {\n"); |
3844 |
buf.append(" private void foo() {\n"); |
3845 |
buf.append(" for ( ; ;) {\n"); |
3846 |
buf.append(" }\n"); |
3847 |
buf.append(" }\n"); |
3848 |
buf.append("}\n"); |
3849 |
expected[1]= buf.toString(); |
3850 |
|
3851 |
assertExpectedExistInProposals(proposals, expected); |
3852 |
} |
3742 |
|
3853 |
|
3743 |
public void testUnusedVariablesAsSwitchStatement() throws Exception { |
3854 |
public void testUnusedVariableAsSwitchStatement() throws Exception { |
3744 |
Hashtable hashtable= JavaCore.getOptions(); |
3855 |
Hashtable hashtable= JavaCore.getOptions(); |
3745 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3856 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); |
3746 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.ERROR); |
3857 |
hashtable.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.ERROR); |