Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 154109
Collapse All | Expand All

(-)performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java (+3 lines)
Lines 136-141 Link Here
136
			public String getPreview() {
136
			public String getPreview() {
137
				return null;
137
				return null;
138
			}
138
			}
139
			public boolean needsFreshAST(CompilationUnit compilationUnit) {
140
	            return false;
141
            }
139
		});
142
		});
140
		
143
		
141
		cleanUpRefactoring.checkAllConditions(new NullProgressMonitor());
144
		cleanUpRefactoring.checkAllConditions(new NullProgressMonitor());
(-)ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java (-75 / +179 lines)
Lines 136-146 Link Here
136
        buf= new StringBuffer();
136
        buf= new StringBuffer();
137
        buf.append("package junit.runner;\n");
137
        buf.append("package junit.runner;\n");
138
        buf.append("\n");
138
        buf.append("\n");
139
        buf.append("import junit.framework.*;\n");
139
        buf.append("import java.io.BufferedReader;\n");
140
        buf.append("import java.lang.reflect.*;\n");
140
        buf.append("import java.io.File;\n");
141
        buf.append("import java.io.FileInputStream;\n");
142
        buf.append("import java.io.FileOutputStream;\n");
143
        buf.append("import java.io.IOException;\n");
144
        buf.append("import java.io.InputStream;\n");
145
        buf.append("import java.io.PrintWriter;\n");
146
        buf.append("import java.io.StringReader;\n");
147
        buf.append("import java.io.StringWriter;\n");
148
        buf.append("import java.lang.reflect.InvocationTargetException;\n");
149
        buf.append("import java.lang.reflect.Method;\n");
150
        buf.append("import java.lang.reflect.Modifier;\n");
141
        buf.append("import java.text.NumberFormat;\n");
151
        buf.append("import java.text.NumberFormat;\n");
142
        buf.append("import java.io.*;\n");
152
        buf.append("import java.util.Properties;\n");
143
        buf.append("import java.util.*;\n");
153
        buf.append("\n");
154
        buf.append("import junit.framework.AssertionFailedError;\n");
155
        buf.append("import junit.framework.Test;\n");
156
        buf.append("import junit.framework.TestListener;\n");
157
        buf.append("import junit.framework.TestSuite;\n");
144
        buf.append("\n");
158
        buf.append("\n");
145
        buf.append("/**\n");
159
        buf.append("/**\n");
146
        buf.append(" * Base class for all test runners. This class was born live on stage in\n");
160
        buf.append(" * Base class for all test runners. This class was born live on stage in\n");
Lines 248-254 Link Here
248
        buf.append("        }\n");
262
        buf.append("        }\n");
249
        buf.append("        Test test = null;\n");
263
        buf.append("        Test test = null;\n");
250
        buf.append("        try {\n");
264
        buf.append("        try {\n");
251
        buf.append("            test = (Test) suiteMethod.invoke(null, new Class[0]); // static method\n");
265
        buf.append("            test = (Test) suiteMethod.invoke(null, new Class[0]); // static\n");
266
        buf.append("                                                                    // method\n");
252
        buf.append("            if (test == null) {\n");
267
        buf.append("            if (test == null) {\n");
253
        buf.append("                return test;\n");
268
        buf.append("                return test;\n");
254
        buf.append("            }\n");
269
        buf.append("            }\n");
Lines 451-457 Link Here
451
        buf.append("        final String[] patterns = new String[]{\"junit.framework.TestCase\", //$NON-NLS-1$\n");
466
        buf.append("        final String[] patterns = new String[]{\"junit.framework.TestCase\", //$NON-NLS-1$\n");
452
        buf.append("                \"junit.framework.TestResult\", //$NON-NLS-1$\n");
467
        buf.append("                \"junit.framework.TestResult\", //$NON-NLS-1$\n");
453
        buf.append("                \"junit.framework.TestSuite\", //$NON-NLS-1$\n");
468
        buf.append("                \"junit.framework.TestSuite\", //$NON-NLS-1$\n");
454
        buf.append("                \"junit.framework.Assert.\", // don't filter AssertionFailure //$NON-NLS-1$\n");
469
        buf.append("                \"junit.framework.Assert.\", // don't filter AssertionFailure\n");
470
        buf.append("                                            // //$NON-NLS-1$\n");
455
        buf.append("                \"junit.swingui.TestRunner\", //$NON-NLS-1$\n");
471
        buf.append("                \"junit.swingui.TestRunner\", //$NON-NLS-1$\n");
456
        buf.append("                \"junit.awtui.TestRunner\", //$NON-NLS-1$\n");
472
        buf.append("                \"junit.awtui.TestRunner\", //$NON-NLS-1$\n");
457
        buf.append("                \"junit.textui.TestRunner\", //$NON-NLS-1$\n");
473
        buf.append("                \"junit.textui.TestRunner\", //$NON-NLS-1$\n");
Lines 491-498 Link Here
491
        buf= new StringBuffer();
507
        buf= new StringBuffer();
492
        buf.append("package junit.tests.runner;\n");
508
        buf.append("package junit.tests.runner;\n");
493
        buf.append("\n");
509
        buf.append("\n");
494
        buf.append("import java.io.*;\n");
510
        buf.append("import java.io.PrintWriter;\n");
495
        buf.append("import junit.framework.*;\n");
511
        buf.append("import java.io.StringWriter;\n");
512
        buf.append("\n");
513
        buf.append("import junit.framework.Assert;\n");
514
        buf.append("import junit.framework.TestCase;\n");
496
        buf.append("import junit.runner.BaseTestRunner;\n");
515
        buf.append("import junit.runner.BaseTestRunner;\n");
497
        buf.append("\n");
516
        buf.append("\n");
498
        buf.append("public class StackFilterTest extends TestCase {\n");
517
        buf.append("public class StackFilterTest extends TestCase {\n");
Lines 760-766 Link Here
760
        buf= new StringBuffer();
779
        buf= new StringBuffer();
761
        buf.append("package junit.samples;\n");
780
        buf.append("package junit.samples;\n");
762
        buf.append("\n");
781
        buf.append("\n");
763
        buf.append("import junit.framework.*;\n");
782
        buf.append("import junit.framework.Test;\n");
783
        buf.append("import junit.framework.TestSuite;\n");
764
        buf.append("\n");
784
        buf.append("\n");
765
        buf.append("/**\n");
785
        buf.append("/**\n");
766
        buf.append(" * TestSuite that runs all the sample tests\n");
786
        buf.append(" * TestSuite that runs all the sample tests\n");
Lines 783-790 Link Here
783
        buf= new StringBuffer();
803
        buf= new StringBuffer();
784
        buf.append("package junit.tests.extensions;\n");
804
        buf.append("package junit.tests.extensions;\n");
785
        buf.append("\n");
805
        buf.append("\n");
786
        buf.append("import junit.framework.*;\n");
806
        buf.append("import junit.extensions.ExceptionTestCase;\n");
787
        buf.append("import junit.extensions.*;\n");
807
        buf.append("import junit.framework.Assert;\n");
808
        buf.append("import junit.framework.TestResult;\n");
788
        buf.append("\n");
809
        buf.append("\n");
789
        buf.append("public class ExceptionTestCaseTest extends junit.framework.TestCase {\n");
810
        buf.append("public class ExceptionTestCaseTest extends junit.framework.TestCase {\n");
790
        buf.append("\n");
811
        buf.append("\n");
Lines 858-864 Link Here
858
        buf.append("/**\n");
879
        buf.append("/**\n");
859
        buf.append(" * Test class used in SuiteTest\n");
880
        buf.append(" * Test class used in SuiteTest\n");
860
        buf.append(" */\n");
881
        buf.append(" */\n");
861
        buf.append("import junit.framework.*;\n");
882
        buf.append("import junit.framework.Assert;\n");
883
        buf.append("import junit.framework.AssertionFailedError;\n");
884
        buf.append("import junit.framework.Test;\n");
885
        buf.append("import junit.framework.TestCase;\n");
886
        buf.append("import junit.framework.TestListener;\n");
887
        buf.append("import junit.framework.TestResult;\n");
862
        buf.append("\n");
888
        buf.append("\n");
863
        buf.append("public class TestListenerTest extends TestCase implements TestListener {\n");
889
        buf.append("public class TestListenerTest extends TestCase implements TestListener {\n");
864
        buf.append("    private TestResult fResult;\n");
890
        buf.append("    private TestResult fResult;\n");
Lines 927-933 Link Here
927
        buf.append("\n");
953
        buf.append("\n");
928
        buf.append("import java.util.Vector;\n");
954
        buf.append("import java.util.Vector;\n");
929
        buf.append("\n");
955
        buf.append("\n");
930
        buf.append("import junit.framework.*;\n");
956
        buf.append("import junit.framework.Assert;\n");
957
        buf.append("import junit.framework.TestCase;\n");
931
        buf.append("import junit.runner.Sorter;\n");
958
        buf.append("import junit.runner.Sorter;\n");
932
        buf.append("\n");
959
        buf.append("\n");
933
        buf.append("public class SorterTest extends TestCase {\n");
960
        buf.append("public class SorterTest extends TestCase {\n");
Lines 972-978 Link Here
972
        buf= new StringBuffer();
999
        buf= new StringBuffer();
973
        buf.append("package junit.tests.framework;\n");
1000
        buf.append("package junit.tests.framework;\n");
974
        buf.append("\n");
1001
        buf.append("\n");
975
        buf.append("import junit.framework.*;\n");
1002
        buf.append("import junit.framework.Assert;\n");
1003
        buf.append("import junit.framework.Protectable;\n");
1004
        buf.append("import junit.framework.Test;\n");
1005
        buf.append("import junit.framework.TestCase;\n");
1006
        buf.append("import junit.framework.TestResult;\n");
976
        buf.append("\n");
1007
        buf.append("\n");
977
        buf.append("/**\n");
1008
        buf.append("/**\n");
978
        buf.append(" * Test an implementor of junit.framework.Test other than TestCase or TestSuite\n");
1009
        buf.append(" * Test an implementor of junit.framework.Test other than TestCase or TestSuite\n");
Lines 1026-1032 Link Here
1026
        buf= new StringBuffer();
1057
        buf= new StringBuffer();
1027
        buf.append("package junit.extensions;\n");
1058
        buf.append("package junit.extensions;\n");
1028
        buf.append("\n");
1059
        buf.append("\n");
1029
        buf.append("import junit.framework.*;\n");
1060
        buf.append("import junit.framework.Assert;\n");
1061
        buf.append("import junit.framework.Test;\n");
1062
        buf.append("import junit.framework.TestResult;\n");
1030
        buf.append("\n");
1063
        buf.append("\n");
1031
        buf.append("/**\n");
1064
        buf.append("/**\n");
1032
        buf.append(" * A Decorator for Tests. Use TestDecorator as the base class for defining new\n");
1065
        buf.append(" * A Decorator for Tests. Use TestDecorator as the base class for defining new\n");
Lines 1263-1269 Link Here
1263
        buf= new StringBuffer();
1296
        buf= new StringBuffer();
1264
        buf.append("package junit.extensions;\n");
1297
        buf.append("package junit.extensions;\n");
1265
        buf.append("\n");
1298
        buf.append("\n");
1266
        buf.append("import junit.framework.*;\n");
1299
        buf.append("import junit.framework.Test;\n");
1300
        buf.append("import junit.framework.TestResult;\n");
1301
        buf.append("import junit.framework.TestSuite;\n");
1267
        buf.append("\n");
1302
        buf.append("\n");
1268
        buf.append("/**\n");
1303
        buf.append("/**\n");
1269
        buf.append(" * A TestSuite for active Tests. It runs each test in a separate thread and\n");
1304
        buf.append(" * A TestSuite for active Tests. It runs each test in a separate thread and\n");
Lines 1331-1337 Link Here
1331
        buf= new StringBuffer();
1366
        buf= new StringBuffer();
1332
        buf.append("package junit.tests.framework;\n");
1367
        buf.append("package junit.tests.framework;\n");
1333
        buf.append("\n");
1368
        buf.append("\n");
1334
        buf.append("import junit.framework.*;\n");
1369
        buf.append("import junit.framework.Assert;\n");
1370
        buf.append("import junit.framework.Test;\n");
1371
        buf.append("import junit.framework.TestCase;\n");
1372
        buf.append("import junit.framework.TestResult;\n");
1373
        buf.append("import junit.framework.TestSuite;\n");
1335
        buf.append("\n");
1374
        buf.append("\n");
1336
        buf.append("/**\n");
1375
        buf.append("/**\n");
1337
        buf.append(" * A fixture for testing the \"auto\" test suite feature.\n");
1376
        buf.append(" * A fixture for testing the \"auto\" test suite feature.\n");
Lines 1475-1481 Link Here
1475
        buf= new StringBuffer();
1514
        buf= new StringBuffer();
1476
        buf.append("package junit.tests.framework;\n");
1515
        buf.append("package junit.tests.framework;\n");
1477
        buf.append("\n");
1516
        buf.append("\n");
1478
        buf.append("import junit.framework.*;\n");
1517
        buf.append("import junit.framework.TestCase;\n");
1479
        buf.append("\n");
1518
        buf.append("\n");
1480
        buf.append("/**\n");
1519
        buf.append("/**\n");
1481
        buf.append(" * A test case testing the testing framework.\n");
1520
        buf.append(" * A test case testing the testing framework.\n");
Lines 1494-1501 Link Here
1494
        buf= new StringBuffer();
1533
        buf= new StringBuffer();
1495
        buf.append("package junit.runner;\n");
1534
        buf.append("package junit.runner;\n");
1496
        buf.append("\n");
1535
        buf.append("\n");
1497
        buf.append("import java.lang.reflect.*;\n");
1536
        buf.append("import java.lang.reflect.Modifier;\n");
1498
        buf.append("import junit.framework.*;\n");
1537
        buf.append("\n");
1538
        buf.append("import junit.framework.Test;\n");
1539
        buf.append("import junit.framework.TestSuite;\n");
1499
        buf.append("\n");
1540
        buf.append("\n");
1500
        buf.append("/**\n");
1541
        buf.append("/**\n");
1501
        buf.append(" * An implementation of a TestCollector that loads all classes on the class path\n");
1542
        buf.append(" * An implementation of a TestCollector that loads all classes on the class path\n");
Lines 1569-1578 Link Here
1569
        buf= new StringBuffer();
1610
        buf= new StringBuffer();
1570
        buf.append("package junit.runner;\n");
1611
        buf.append("package junit.runner;\n");
1571
        buf.append("\n");
1612
        buf.append("\n");
1572
        buf.append("import java.util.*;\n");
1613
        buf.append("import java.io.ByteArrayOutputStream;\n");
1573
        buf.append("import java.io.*;\n");
1614
        buf.append("import java.io.File;\n");
1615
        buf.append("import java.io.FileInputStream;\n");
1616
        buf.append("import java.io.IOException;\n");
1617
        buf.append("import java.io.InputStream;\n");
1574
        buf.append("import java.net.URL;\n");
1618
        buf.append("import java.net.URL;\n");
1575
        buf.append("import java.util.zip.*;\n");
1619
        buf.append("import java.util.Enumeration;\n");
1620
        buf.append("import java.util.Properties;\n");
1621
        buf.append("import java.util.StringTokenizer;\n");
1622
        buf.append("import java.util.Vector;\n");
1623
        buf.append("import java.util.zip.ZipEntry;\n");
1624
        buf.append("import java.util.zip.ZipFile;\n");
1576
        buf.append("\n");
1625
        buf.append("\n");
1577
        buf.append("/**\n");
1626
        buf.append("/**\n");
1578
        buf.append(" * A custom class loader which enables the reloading of classes for each test\n");
1627
        buf.append(" * A custom class loader which enables the reloading of classes for each test\n");
Lines 1835-1841 Link Here
1835
        buf= new StringBuffer();
1884
        buf= new StringBuffer();
1836
        buf.append("package junit.samples;\n");
1885
        buf.append("package junit.samples;\n");
1837
        buf.append("\n");
1886
        buf.append("\n");
1838
        buf.append("import junit.framework.*;\n");
1887
        buf.append("import junit.framework.Assert;\n");
1888
        buf.append("import junit.framework.Test;\n");
1889
        buf.append("import junit.framework.TestCase;\n");
1890
        buf.append("import junit.framework.TestSuite;\n");
1839
        buf.append("\n");
1891
        buf.append("\n");
1840
        buf.append("/**\n");
1892
        buf.append("/**\n");
1841
        buf.append(" * Some simple tests.\n");
1893
        buf.append(" * Some simple tests.\n");
Lines 1942-1950 Link Here
1942
        buf.append("    public void testInvokeNonStaticSuite() {\n");
1994
        buf.append("    public void testInvokeNonStaticSuite() {\n");
1943
        buf.append("        final BaseTestRunner runner = new MockRunner();\n");
1995
        buf.append("        final BaseTestRunner runner = new MockRunner();\n");
1944
        buf.append("        runner.getTest(\"junit.tests.runner.BaseTestRunnerTest$NonStatic\"); // Used\n");
1996
        buf.append("        runner.getTest(\"junit.tests.runner.BaseTestRunnerTest$NonStatic\"); // Used\n");
1945
        buf.append("        // to\n");
1997
        buf.append("                                                                            // to\n");
1946
        buf.append("        // throw\n");
1998
        buf.append("                                                                            // throw\n");
1947
        buf.append("        // NullPointerException //$NON-NLS-1$\n");
1999
        buf.append("                                                                            // NullPointerException\n");
2000
        buf.append("                                                                            // //$NON-NLS-1$\n");
1948
        buf.append("    }\n");
2001
        buf.append("    }\n");
1949
        buf.append("}\n");
2002
        buf.append("}\n");
1950
        buf.append("");
2003
        buf.append("");
Lines 1952-1958 Link Here
1952
        buf= new StringBuffer();
2005
        buf= new StringBuffer();
1953
        buf.append("package junit.tests;\n");
2006
        buf.append("package junit.tests;\n");
1954
        buf.append("\n");
2007
        buf.append("\n");
1955
        buf.append("import junit.framework.*;\n");
2008
        buf.append("import junit.framework.TestCase;\n");
1956
        buf.append("\n");
2009
        buf.append("\n");
1957
        buf.append("/**\n");
2010
        buf.append("/**\n");
1958
        buf.append(" * A helper test case for testing whether the testing method is run.\n");
2011
        buf.append(" * A helper test case for testing whether the testing method is run.\n");
Lines 1968-1978 Link Here
1968
        buf= new StringBuffer();
2021
        buf= new StringBuffer();
1969
        buf.append("package junit.framework;\n");
2022
        buf.append("package junit.framework;\n");
1970
        buf.append("\n");
2023
        buf.append("\n");
1971
        buf.append("import java.util.Vector;\n");
1972
        buf.append("import java.util.Enumeration;\n");
1973
        buf.append("import java.io.PrintWriter;\n");
2024
        buf.append("import java.io.PrintWriter;\n");
1974
        buf.append("import java.io.StringWriter;\n");
2025
        buf.append("import java.io.StringWriter;\n");
1975
        buf.append("import java.lang.reflect.*;\n");
2026
        buf.append("import java.lang.reflect.Constructor;\n");
2027
        buf.append("import java.lang.reflect.InvocationTargetException;\n");
2028
        buf.append("import java.lang.reflect.Method;\n");
2029
        buf.append("import java.lang.reflect.Modifier;\n");
2030
        buf.append("import java.util.Enumeration;\n");
2031
        buf.append("import java.util.Vector;\n");
1976
        buf.append("\n");
2032
        buf.append("\n");
1977
        buf.append("/**\n");
2033
        buf.append("/**\n");
1978
        buf.append(" * A <code>TestSuite</code> is a <code>Composite</code> of Tests. It runs a\n");
2034
        buf.append(" * A <code>TestSuite</code> is a <code>Composite</code> of Tests. It runs a\n");
Lines 2026-2033 Link Here
2026
        buf.append("    public TestSuite(final Class theClass) {\n");
2082
        buf.append("    public TestSuite(final Class theClass) {\n");
2027
        buf.append("        this.fName = theClass.getName();\n");
2083
        buf.append("        this.fName = theClass.getName();\n");
2028
        buf.append("        try {\n");
2084
        buf.append("        try {\n");
2029
        buf.append("            TestSuite.getTestConstructor(theClass); // Avoid generating multiple error\n");
2085
        buf.append("            TestSuite.getTestConstructor(theClass); // Avoid generating multiple\n");
2030
        buf.append("            // messages\n");
2086
        buf.append("            // error messages\n");
2031
        buf.append("        } catch (final NoSuchMethodException e) {\n");
2087
        buf.append("        } catch (final NoSuchMethodException e) {\n");
2032
        buf.append("            this\n");
2088
        buf.append("            this\n");
2033
        buf.append("                    .addTest(TestSuite\n");
2089
        buf.append("                    .addTest(TestSuite\n");
Lines 2261-2267 Link Here
2261
        buf= new StringBuffer();
2317
        buf= new StringBuffer();
2262
        buf.append("package junit.extensions;\n");
2318
        buf.append("package junit.extensions;\n");
2263
        buf.append("\n");
2319
        buf.append("\n");
2264
        buf.append("import junit.framework.*;\n");
2320
        buf.append("import junit.framework.Assert;\n");
2321
        buf.append("import junit.framework.TestCase;\n");
2265
        buf.append("\n");
2322
        buf.append("\n");
2266
        buf.append("/**\n");
2323
        buf.append("/**\n");
2267
        buf.append(" * A TestCase that expects an Exception of class fExpected to be thrown. The\n");
2324
        buf.append(" * A TestCase that expects an Exception of class fExpected to be thrown. The\n");
Lines 2420-2428 Link Here
2420
        buf.append("                        actual));\n");
2477
        buf.append("                        actual));\n");
2421
        buf.append("            }\n");
2478
        buf.append("            }\n");
2422
        buf.append("        } else if (!(Math.abs(expected - actual) <= delta)) {\n");
2479
        buf.append("        } else if (!(Math.abs(expected - actual) <= delta)) {\n");
2423
        buf.append("            // comparison with\n");
2424
        buf.append("            // NaN always\n");
2425
        buf.append("            // returns false\n");
2426
        buf.append("            Assert.failNotEquals(message, new Double(expected), new Double(\n");
2480
        buf.append("            Assert.failNotEquals(message, new Double(expected), new Double(\n");
2427
        buf.append("                    actual));\n");
2481
        buf.append("                    actual));\n");
2428
        buf.append("        }\n");
2482
        buf.append("        }\n");
Lines 2651-2658 Link Here
2651
        buf= new StringBuffer();
2705
        buf= new StringBuffer();
2652
        buf.append("package junit.runner;\n");
2706
        buf.append("package junit.runner;\n");
2653
        buf.append("\n");
2707
        buf.append("\n");
2654
        buf.append("import java.util.*;\n");
2708
        buf.append("import java.io.File;\n");
2655
        buf.append("import java.io.*;\n");
2709
        buf.append("import java.util.Enumeration;\n");
2710
        buf.append("import java.util.Hashtable;\n");
2711
        buf.append("import java.util.StringTokenizer;\n");
2712
        buf.append("import java.util.Vector;\n");
2656
        buf.append("\n");
2713
        buf.append("\n");
2657
        buf.append("/**\n");
2714
        buf.append("/**\n");
2658
        buf.append(" * An implementation of a TestCollector that consults the class path. It\n");
2715
        buf.append(" * An implementation of a TestCollector that consults the class path. It\n");
Lines 2766-2773 Link Here
2766
        buf= new StringBuffer();
2823
        buf= new StringBuffer();
2767
        buf.append("package junit.tests.extensions;\n");
2824
        buf.append("package junit.tests.extensions;\n");
2768
        buf.append("\n");
2825
        buf.append("\n");
2769
        buf.append("import junit.framework.*;\n");
2826
        buf.append("import junit.extensions.ActiveTestSuite;\n");
2770
        buf.append("import junit.extensions.*;\n");
2827
        buf.append("import junit.extensions.RepeatedTest;\n");
2828
        buf.append("import junit.framework.Assert;\n");
2829
        buf.append("import junit.framework.Test;\n");
2830
        buf.append("import junit.framework.TestCase;\n");
2831
        buf.append("import junit.framework.TestResult;\n");
2771
        buf.append("\n");
2832
        buf.append("\n");
2772
        buf.append("/**\n");
2833
        buf.append("/**\n");
2773
        buf.append(" * Testing the ActiveTest support\n");
2834
        buf.append(" * Testing the ActiveTest support\n");
Lines 2892-2899 Link Here
2892
        buf.append("\n");
2953
        buf.append("\n");
2893
        buf.append("import java.io.PrintStream;\n");
2954
        buf.append("import java.io.PrintStream;\n");
2894
        buf.append("\n");
2955
        buf.append("\n");
2895
        buf.append("import junit.framework.*;\n");
2956
        buf.append("import junit.framework.Test;\n");
2896
        buf.append("import junit.runner.*;\n");
2957
        buf.append("import junit.framework.TestResult;\n");
2958
        buf.append("import junit.framework.TestSuite;\n");
2959
        buf.append("import junit.runner.BaseTestRunner;\n");
2960
        buf.append("import junit.runner.StandardTestSuiteLoader;\n");
2961
        buf.append("import junit.runner.TestSuiteLoader;\n");
2962
        buf.append("import junit.runner.Version;\n");
2897
        buf.append("\n");
2963
        buf.append("\n");
2898
        buf.append("/**\n");
2964
        buf.append("/**\n");
2899
        buf.append(" * A command line based tool to run tests.\n");
2965
        buf.append(" * A command line based tool to run tests.\n");
Lines 3092-3098 Link Here
3092
        buf.append("/**\n");
3158
        buf.append("/**\n");
3093
        buf.append(" * Test class used in TestTestCaseClassLoader\n");
3159
        buf.append(" * Test class used in TestTestCaseClassLoader\n");
3094
        buf.append(" */\n");
3160
        buf.append(" */\n");
3095
        buf.append("import junit.framework.*;\n");
3161
        buf.append("import junit.framework.Assert;\n");
3162
        buf.append("import junit.framework.TestCase;\n");
3096
        buf.append("\n");
3163
        buf.append("\n");
3097
        buf.append("public class ClassLoaderTest extends Assert {\n");
3164
        buf.append("public class ClassLoaderTest extends Assert {\n");
3098
        buf.append("    public ClassLoaderTest() {\n");
3165
        buf.append("    public ClassLoaderTest() {\n");
Lines 3281-3288 Link Here
3281
        buf= new StringBuffer();
3348
        buf= new StringBuffer();
3282
        buf.append("package junit.tests.extensions;\n");
3349
        buf.append("package junit.tests.extensions;\n");
3283
        buf.append("\n");
3350
        buf.append("\n");
3284
        buf.append("import junit.framework.*;\n");
3351
        buf.append("import junit.extensions.TestSetup;\n");
3285
        buf.append("import junit.extensions.*;\n");
3352
        buf.append("import junit.framework.Assert;\n");
3353
        buf.append("import junit.framework.Test;\n");
3354
        buf.append("import junit.framework.TestCase;\n");
3355
        buf.append("import junit.framework.TestResult;\n");
3356
        buf.append("import junit.framework.TestSuite;\n");
3286
        buf.append("import junit.tests.WasRun;\n");
3357
        buf.append("import junit.tests.WasRun;\n");
3287
        buf.append("\n");
3358
        buf.append("\n");
3288
        buf.append("/**\n");
3359
        buf.append("/**\n");
Lines 3378-3384 Link Here
3378
        buf= new StringBuffer();
3449
        buf= new StringBuffer();
3379
        buf.append("package junit.tests;\n");
3450
        buf.append("package junit.tests;\n");
3380
        buf.append("\n");
3451
        buf.append("\n");
3381
        buf.append("import junit.framework.*;\n");
3452
        buf.append("import junit.framework.Test;\n");
3453
        buf.append("import junit.framework.TestSuite;\n");
3382
        buf.append("\n");
3454
        buf.append("\n");
3383
        buf.append("/**\n");
3455
        buf.append("/**\n");
3384
        buf.append(" * TestSuite that runs all the JUnit tests\n");
3456
        buf.append(" * TestSuite that runs all the JUnit tests\n");
Lines 3405-3411 Link Here
3405
        buf.append("/**\n");
3477
        buf.append("/**\n");
3406
        buf.append(" * Test class used in TestTestCaseClassLoader\n");
3478
        buf.append(" * Test class used in TestTestCaseClassLoader\n");
3407
        buf.append(" */\n");
3479
        buf.append(" */\n");
3408
        buf.append("import junit.framework.*;\n");
3480
        buf.append("import junit.framework.Assert;\n");
3409
        buf.append("\n");
3481
        buf.append("\n");
3410
        buf.append("public class LoadedFromJar extends Assert {\n");
3482
        buf.append("public class LoadedFromJar extends Assert {\n");
3411
        buf.append("    public void verify() {\n");
3483
        buf.append("    public void verify() {\n");
Lines 3576-3584 Link Here
3576
        buf.append("        }\n");
3648
        buf.append("        }\n");
3577
        buf.append("    }\n");
3649
        buf.append("    }\n");
3578
        buf.append("\n");
3650
        buf.append("\n");
3579
        buf.append("    public void printDefect(final TestFailure booBoo, final int count) { // only public\n");
3651
        buf.append("    public void printDefect(final TestFailure booBoo, final int count) { // only\n");
3580
        buf.append("        // for testing\n");
3652
        buf.append("                                                                            // public\n");
3581
        buf.append("        // purposes\n");
3653
        buf.append("                                                                            // for\n");
3654
        buf.append("                                                                            // testing\n");
3655
        buf.append("                                                                            // purposes\n");
3582
        buf.append("        this.printDefectHeader(booBoo, count);\n");
3656
        buf.append("        this.printDefectHeader(booBoo, count);\n");
3583
        buf.append("        this.printDefectTrace(booBoo);\n");
3657
        buf.append("        this.printDefectTrace(booBoo);\n");
3584
        buf.append("    }\n");
3658
        buf.append("    }\n");
Lines 3661-3670 Link Here
3661
        buf= new StringBuffer();
3735
        buf= new StringBuffer();
3662
        buf.append("package junit.samples;\n");
3736
        buf.append("package junit.samples;\n");
3663
        buf.append("\n");
3737
        buf.append("\n");
3664
        buf.append("import junit.framework.*;\n");
3665
        buf.append("\n");
3666
        buf.append("import java.util.Vector;\n");
3738
        buf.append("import java.util.Vector;\n");
3667
        buf.append("\n");
3739
        buf.append("\n");
3740
        buf.append("import junit.framework.Assert;\n");
3741
        buf.append("import junit.framework.Test;\n");
3742
        buf.append("import junit.framework.TestCase;\n");
3743
        buf.append("import junit.framework.TestSuite;\n");
3744
        buf.append("\n");
3668
        buf.append("/**\n");
3745
        buf.append("/**\n");
3669
        buf.append(" * A sample test case, testing <code>java.util.Vector</code>.\n");
3746
        buf.append(" * A sample test case, testing <code>java.util.Vector</code>.\n");
3670
        buf.append(" * \n");
3747
        buf.append(" * \n");
Lines 3814-3820 Link Here
3814
        buf= new StringBuffer();
3891
        buf= new StringBuffer();
3815
        buf.append("package junit.tests.framework;\n");
3892
        buf.append("package junit.tests.framework;\n");
3816
        buf.append("\n");
3893
        buf.append("\n");
3817
        buf.append("import junit.framework.*;\n");
3894
        buf.append("import junit.framework.Assert;\n");
3895
        buf.append("import junit.framework.AssertionFailedError;\n");
3896
        buf.append("import junit.framework.Test;\n");
3897
        buf.append("import junit.framework.TestCase;\n");
3898
        buf.append("import junit.framework.TestFailure;\n");
3899
        buf.append("import junit.framework.TestResult;\n");
3900
        buf.append("import junit.framework.TestSuite;\n");
3818
        buf.append("import junit.tests.WasRun;\n");
3901
        buf.append("import junit.tests.WasRun;\n");
3819
        buf.append("\n");
3902
        buf.append("\n");
3820
        buf.append("/**\n");
3903
        buf.append("/**\n");
Lines 4054-4060 Link Here
4054
        buf.append(" */\n");
4137
        buf.append(" */\n");
4055
        buf.append("public class ReloadingTestSuiteLoader implements TestSuiteLoader {\n");
4138
        buf.append("public class ReloadingTestSuiteLoader implements TestSuiteLoader {\n");
4056
        buf.append("\n");
4139
        buf.append("\n");
4057
        buf.append("    public Class load(final String suiteClassName) throws ClassNotFoundException {\n");
4140
        buf.append("    public Class load(final String suiteClassName)\n");
4141
        buf.append("            throws ClassNotFoundException {\n");
4058
        buf.append("        return this.createLoader().loadClass(suiteClassName, true);\n");
4142
        buf.append("        return this.createLoader().loadClass(suiteClassName, true);\n");
4059
        buf.append("    }\n");
4143
        buf.append("    }\n");
4060
        buf.append("\n");
4144
        buf.append("\n");
Lines 4077-4083 Link Here
4077
        buf.append("    /**\n");
4161
        buf.append("    /**\n");
4078
        buf.append("     * Uses the system class loader to load the test class\n");
4162
        buf.append("     * Uses the system class loader to load the test class\n");
4079
        buf.append("     */\n");
4163
        buf.append("     */\n");
4080
        buf.append("    public Class load(final String suiteClassName) throws ClassNotFoundException {\n");
4164
        buf.append("    public Class load(final String suiteClassName)\n");
4165
        buf.append("            throws ClassNotFoundException {\n");
4081
        buf.append("        return Class.forName(suiteClassName);\n");
4166
        buf.append("        return Class.forName(suiteClassName);\n");
4082
        buf.append("    }\n");
4167
        buf.append("    }\n");
4083
        buf.append("    /**\n");
4168
        buf.append("    /**\n");
Lines 4091-4097 Link Here
4091
        buf= new StringBuffer();
4176
        buf= new StringBuffer();
4092
        buf.append("package junit.extensions;\n");
4177
        buf.append("package junit.extensions;\n");
4093
        buf.append("\n");
4178
        buf.append("\n");
4094
        buf.append("import junit.framework.*;\n");
4179
        buf.append("import junit.framework.Protectable;\n");
4180
        buf.append("import junit.framework.Test;\n");
4181
        buf.append("import junit.framework.TestResult;\n");
4095
        buf.append("\n");
4182
        buf.append("\n");
4096
        buf.append("/**\n");
4183
        buf.append("/**\n");
4097
        buf.append(" * A Decorator to set up and tear down additional fixture state. Subclass\n");
4184
        buf.append(" * A Decorator to set up and tear down additional fixture state. Subclass\n");
Lines 4199-4205 Link Here
4199
        buf= new StringBuffer();
4286
        buf= new StringBuffer();
4200
        buf.append("package junit.tests.framework;\n");
4287
        buf.append("package junit.tests.framework;\n");
4201
        buf.append("\n");
4288
        buf.append("\n");
4202
        buf.append("import junit.framework.*;\n");
4289
        buf.append("import junit.framework.Assert;\n");
4290
        buf.append("import junit.framework.TestCase;\n");
4203
        buf.append("\n");
4291
        buf.append("\n");
4204
        buf.append("/**\n");
4292
        buf.append("/**\n");
4205
        buf.append(" * A test case testing the testing framework.\n");
4293
        buf.append(" * A test case testing the testing framework.\n");
Lines 4227-4233 Link Here
4227
        buf= new StringBuffer();
4315
        buf= new StringBuffer();
4228
        buf.append("package junit.extensions;\n");
4316
        buf.append("package junit.extensions;\n");
4229
        buf.append("\n");
4317
        buf.append("\n");
4230
        buf.append("import junit.framework.*;\n");
4318
        buf.append("import junit.framework.Test;\n");
4319
        buf.append("import junit.framework.TestResult;\n");
4231
        buf.append("\n");
4320
        buf.append("\n");
4232
        buf.append("/**\n");
4321
        buf.append("/**\n");
4233
        buf.append(" * A Decorator that runs a test repeatedly.\n");
4322
        buf.append(" * A Decorator that runs a test repeatedly.\n");
Lines 4276-4282 Link Here
4276
        buf= new StringBuffer();
4365
        buf= new StringBuffer();
4277
        buf.append("package junit.runner;\n");
4366
        buf.append("package junit.runner;\n");
4278
        buf.append("\n");
4367
        buf.append("\n");
4279
        buf.append("import java.util.*;\n");
4368
        buf.append("import java.util.Vector;\n");
4280
        buf.append("\n");
4369
        buf.append("\n");
4281
        buf.append("/**\n");
4370
        buf.append("/**\n");
4282
        buf.append(" * A custom quick sort with support to customize the swap behaviour. NOTICE: We\n");
4371
        buf.append(" * A custom quick sort with support to customize the swap behaviour. NOTICE: We\n");
Lines 4319-4325 Link Here
4319
        buf= new StringBuffer();
4408
        buf= new StringBuffer();
4320
        buf.append("package junit.tests.framework;\n");
4409
        buf.append("package junit.tests.framework;\n");
4321
        buf.append("\n");
4410
        buf.append("\n");
4322
        buf.append("import junit.framework.*;\n");
4411
        buf.append("import junit.framework.Test;\n");
4412
        buf.append("import junit.framework.TestSuite;\n");
4323
        buf.append("\n");
4413
        buf.append("\n");
4324
        buf.append("/**\n");
4414
        buf.append("/**\n");
4325
        buf.append(" * TestSuite that runs all the sample tests\n");
4415
        buf.append(" * TestSuite that runs all the sample tests\n");
Lines 4335-4341 Link Here
4335
        buf.append("        final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n");
4425
        buf.append("        final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n");
4336
        buf.append("        suite.addTestSuite(TestCaseTest.class);\n");
4426
        buf.append("        suite.addTestSuite(TestCaseTest.class);\n");
4337
        buf.append("        suite.addTest(SuiteTest.suite()); // Tests suite building, so can't\n");
4427
        buf.append("        suite.addTest(SuiteTest.suite()); // Tests suite building, so can't\n");
4338
        buf.append("        // use automatic test extraction\n");
4428
        buf.append("                                            // use automatic test extraction\n");
4339
        buf.append("        suite.addTestSuite(TestListenerTest.class);\n");
4429
        buf.append("        suite.addTestSuite(TestListenerTest.class);\n");
4340
        buf.append("        suite.addTestSuite(AssertTest.class);\n");
4430
        buf.append("        suite.addTestSuite(AssertTest.class);\n");
4341
        buf.append("        suite.addTestSuite(TestImplementorTest.class);\n");
4431
        buf.append("        suite.addTestSuite(TestImplementorTest.class);\n");
Lines 4350-4357 Link Here
4350
        buf= new StringBuffer();
4440
        buf= new StringBuffer();
4351
        buf.append("package junit.tests.extensions;\n");
4441
        buf.append("package junit.tests.extensions;\n");
4352
        buf.append("\n");
4442
        buf.append("\n");
4353
        buf.append("import junit.framework.*;\n");
4354
        buf.append("import junit.extensions.RepeatedTest;\n");
4443
        buf.append("import junit.extensions.RepeatedTest;\n");
4444
        buf.append("import junit.framework.Assert;\n");
4445
        buf.append("import junit.framework.Test;\n");
4446
        buf.append("import junit.framework.TestCase;\n");
4447
        buf.append("import junit.framework.TestResult;\n");
4448
        buf.append("import junit.framework.TestSuite;\n");
4355
        buf.append("\n");
4449
        buf.append("\n");
4356
        buf.append("/**\n");
4450
        buf.append("/**\n");
4357
        buf.append(" * Testing the RepeatedTest support.\n");
4451
        buf.append(" * Testing the RepeatedTest support.\n");
Lines 4411-4417 Link Here
4411
        buf= new StringBuffer();
4505
        buf= new StringBuffer();
4412
        buf.append("package junit.tests.runner;\n");
4506
        buf.append("package junit.tests.runner;\n");
4413
        buf.append("\n");
4507
        buf.append("\n");
4414
        buf.append("import junit.framework.*;\n");
4508
        buf.append("import junit.framework.Test;\n");
4509
        buf.append("import junit.framework.TestSuite;\n");
4415
        buf.append("import junit.runner.BaseTestRunner;\n");
4510
        buf.append("import junit.runner.BaseTestRunner;\n");
4416
        buf.append("\n");
4511
        buf.append("\n");
4417
        buf.append("/**\n");
4512
        buf.append("/**\n");
Lines 4425-4431 Link Here
4425
        buf.append("    }\n");
4520
        buf.append("    }\n");
4426
        buf.append("\n");
4521
        buf.append("\n");
4427
        buf.append("    public static Test suite() { // Collect tests manually because we have to\n");
4522
        buf.append("    public static Test suite() { // Collect tests manually because we have to\n");
4428
        buf.append("        // test class collection code\n");
4523
        buf.append("                                    // test class collection code\n");
4429
        buf.append("        final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n");
4524
        buf.append("        final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n");
4430
        buf.append("        suite.addTestSuite(StackFilterTest.class);\n");
4525
        buf.append("        suite.addTestSuite(StackFilterTest.class);\n");
4431
        buf.append("        suite.addTestSuite(SorterTest.class);\n");
4526
        buf.append("        suite.addTestSuite(SorterTest.class);\n");
Lines 4450-4456 Link Here
4450
        buf= new StringBuffer();
4545
        buf= new StringBuffer();
4451
        buf.append("package junit.runner;\n");
4546
        buf.append("package junit.runner;\n");
4452
        buf.append("\n");
4547
        buf.append("\n");
4453
        buf.append("import java.util.*;\n");
4548
        buf.append("import java.util.Enumeration;\n");
4454
        buf.append("\n");
4549
        buf.append("\n");
4455
        buf.append("/**\n");
4550
        buf.append("/**\n");
4456
        buf.append(" * Collects Test class names to be presented by the TestSelector.\n");
4551
        buf.append(" * Collects Test class names to be presented by the TestSelector.\n");
Lines 4468-4474 Link Here
4468
        buf= new StringBuffer();
4563
        buf= new StringBuffer();
4469
        buf.append("package junit.samples.money;\n");
4564
        buf.append("package junit.samples.money;\n");
4470
        buf.append("\n");
4565
        buf.append("\n");
4471
        buf.append("import java.util.*;\n");
4566
        buf.append("import java.util.Enumeration;\n");
4567
        buf.append("import java.util.Vector;\n");
4472
        buf.append("\n");
4568
        buf.append("\n");
4473
        buf.append("/**\n");
4569
        buf.append("/**\n");
4474
        buf.append(" * A MoneyBag defers exchange rate conversions. For example adding 12 Swiss\n");
4570
        buf.append(" * A MoneyBag defers exchange rate conversions. For example adding 12 Swiss\n");
Lines 4636-4642 Link Here
4636
        buf= new StringBuffer();
4732
        buf= new StringBuffer();
4637
        buf.append("package junit.framework;\n");
4733
        buf.append("package junit.framework;\n");
4638
        buf.append("\n");
4734
        buf.append("\n");
4639
        buf.append("import java.lang.reflect.*;\n");
4735
        buf.append("import java.lang.reflect.InvocationTargetException;\n");
4736
        buf.append("import java.lang.reflect.Method;\n");
4737
        buf.append("import java.lang.reflect.Modifier;\n");
4640
        buf.append("\n");
4738
        buf.append("\n");
4641
        buf.append("/**\n");
4739
        buf.append("/**\n");
4642
        buf.append(" * A test case defines the fixture to run multiple tests. To define a test case<br>\n");
4740
        buf.append(" * A test case defines the fixture to run multiple tests. To define a test case<br>\n");
Lines 4848-4854 Link Here
4848
        buf= new StringBuffer();
4946
        buf= new StringBuffer();
4849
        buf.append("package junit.samples.money;\n");
4947
        buf.append("package junit.samples.money;\n");
4850
        buf.append("\n");
4948
        buf.append("\n");
4851
        buf.append("import junit.framework.*;\n");
4949
        buf.append("import junit.framework.Assert;\n");
4950
        buf.append("import junit.framework.TestCase;\n");
4852
        buf.append("\n");
4951
        buf.append("\n");
4853
        buf.append("public class MoneyTest extends TestCase {\n");
4952
        buf.append("public class MoneyTest extends TestCase {\n");
4854
        buf.append("    private Money f12CHF;\n");
4953
        buf.append("    private Money f12CHF;\n");
Lines 5005-5011 Link Here
5005
        buf= new StringBuffer();
5104
        buf= new StringBuffer();
5006
        buf.append("package junit.tests.extensions;\n");
5105
        buf.append("package junit.tests.extensions;\n");
5007
        buf.append("\n");
5106
        buf.append("\n");
5008
        buf.append("import junit.framework.*;\n");
5107
        buf.append("import junit.framework.Test;\n");
5108
        buf.append("import junit.framework.TestSuite;\n");
5009
        buf.append("\n");
5109
        buf.append("\n");
5010
        buf.append("/**\n");
5110
        buf.append("/**\n");
5011
        buf.append(" * TestSuite that runs all the extension tests\n");
5111
        buf.append(" * TestSuite that runs all the extension tests\n");
Lines 5018-5024 Link Here
5018
        buf.append("    }\n");
5118
        buf.append("    }\n");
5019
        buf.append("\n");
5119
        buf.append("\n");
5020
        buf.append("    public static Test suite() { // Collect tests manually because we have to\n");
5120
        buf.append("    public static Test suite() { // Collect tests manually because we have to\n");
5021
        buf.append("        // test class collection code\n");
5121
        buf.append("                                    // test class collection code\n");
5022
        buf.append("        final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n");
5122
        buf.append("        final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n");
5023
        buf.append("        suite.addTestSuite(ExtensionTest.class);\n");
5123
        buf.append("        suite.addTestSuite(ExtensionTest.class);\n");
5024
        buf.append("        suite.addTestSuite(ExceptionTestCaseTest.class);\n");
5124
        buf.append("        suite.addTestSuite(ExceptionTestCaseTest.class);\n");
Lines 5044-5054 Link Here
5044
        buf= new StringBuffer();
5144
        buf= new StringBuffer();
5045
        buf.append("package junit.tests.runner;\n");
5145
        buf.append("package junit.tests.runner;\n");
5046
        buf.append("\n");
5146
        buf.append("\n");
5047
        buf.append("import java.lang.reflect.*;\n");
5147
        buf.append("import java.lang.reflect.Method;\n");
5048
        buf.append("import junit.framework.*;\n");
5049
        buf.append("import junit.runner.*;\n");
5050
        buf.append("import java.net.URL;\n");
5148
        buf.append("import java.net.URL;\n");
5051
        buf.append("\n");
5149
        buf.append("\n");
5150
        buf.append("import junit.framework.Assert;\n");
5151
        buf.append("import junit.framework.TestCase;\n");
5152
        buf.append("import junit.runner.TestCaseClassLoader;\n");
5153
        buf.append("\n");
5052
        buf.append("/**\n");
5154
        buf.append("/**\n");
5053
        buf.append(" * A TestCase for testing the TestCaseClassLoader\n");
5155
        buf.append(" * A TestCase for testing the TestCaseClassLoader\n");
5054
        buf.append(" * \n");
5156
        buf.append(" * \n");
Lines 5173-5179 Link Here
5173
        buf.append("}");
5275
        buf.append("}");
5174
        fExpectedChangesAllTests.put("junit.samples.money.Money.java", buf.toString());
5276
        fExpectedChangesAllTests.put("junit.samples.money.Money.java", buf.toString());
5175
    }
5277
    }
5176
    
5278
	
5177
	public void testAllCleanUps() throws Exception {
5279
	public void testAllCleanUps() throws Exception {
5178
		List cus= new ArrayList();
5280
		List cus= new ArrayList();
5179
		addAllCUs(MyTestSetup.fJProject1.getChildren(), cus);
5281
		addAllCUs(MyTestSetup.fJProject1.getChildren(), cus);
Lines 5235-5240 Link Here
5235
		node.put(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT, CleanUpConstants.TRUE);
5337
		node.put(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT, CleanUpConstants.TRUE);
5236
		
5338
		
5237
		node.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpConstants.TRUE);
5339
		node.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpConstants.TRUE);
5340
		
5341
		node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.TRUE);
5238
	
5342
	
5239
		ICompilationUnit[] units= (ICompilationUnit[])cus.toArray(new ICompilationUnit[cus.size()]);	
5343
		ICompilationUnit[] units= (ICompilationUnit[])cus.toArray(new ICompilationUnit[cus.size()]);	
5240
		Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
5344
		Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
(-)core extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java (-9 / +24 lines)
Lines 380-389 Link Here
380
			monitor= new NullProgressMonitor();
380
			monitor= new NullProgressMonitor();
381
		}
381
		}
382
		try {
382
		try {
383
			monitor.beginTask(Messages.format(CodeGenerationMessages.OrganizeImportsOperation_description, fCompilationUnit.getElementName()), 10);
384
			
385
    		TextEdit edit= createTextEdit(new SubProgressMonitor(monitor, 9));
386
    		if (edit == null)
387
    			return;
388
    		
389
    		JavaModelUtil.applyEdit(fCompilationUnit, edit, fDoSave, new SubProgressMonitor(monitor, 1));
390
		} finally {
391
			monitor.done();
392
		}
393
	}
394
	
395
	public TextEdit createTextEdit(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
396
		if (monitor == null) {
397
			monitor= new NullProgressMonitor();
398
		}
399
		try {
383
			fNumberOfImportsAdded= 0;
400
			fNumberOfImportsAdded= 0;
384
			fNumberOfImportsRemoved= 0;
401
			fNumberOfImportsRemoved= 0;
385
			
402
			
386
			monitor.beginTask(Messages.format(CodeGenerationMessages.OrganizeImportsOperation_description, fCompilationUnit.getElementName()), 10);
403
			monitor.beginTask(Messages.format(CodeGenerationMessages.OrganizeImportsOperation_description, fCompilationUnit.getElementName()), 9);
387
			
404
			
388
			CompilationUnit astRoot= fASTRoot;
405
			CompilationUnit astRoot= fASTRoot;
389
			if (astRoot == null) {
406
			if (astRoot == null) {
Lines 399-408 Link Here
399
			List/*<SimpleName>*/ typeReferences= new ArrayList();
416
			List/*<SimpleName>*/ typeReferences= new ArrayList();
400
			List/*<SimpleName>*/ staticReferences= new ArrayList();
417
			List/*<SimpleName>*/ staticReferences= new ArrayList();
401
			
418
			
402
			boolean res= collectReferences(astRoot, typeReferences, staticReferences, oldSingleImports, oldDemandImports);
419
			if (!collectReferences(astRoot, typeReferences, staticReferences, oldSingleImports, oldDemandImports))
403
			if (!res) {
420
				return null;
404
				return;
405
			}
406
						
421
						
407
			monitor.worked(1);
422
			monitor.worked(1);
408
		
423
		
Lines 430-441 Link Here
430
					importsRewrite.addImport(typeInfo.getFullyQualifiedName());
445
					importsRewrite.addImport(typeInfo.getFullyQualifiedName());
431
				}				
446
				}				
432
			}
447
			}
448
449
			TextEdit result= importsRewrite.rewriteImports(new SubProgressMonitor(monitor, 3));
433
			
450
			
434
			TextEdit edit= importsRewrite.rewriteImports(new SubProgressMonitor(monitor, 3));
435
			JavaModelUtil.applyEdit(fCompilationUnit, edit, fDoSave, new SubProgressMonitor(monitor, 1));
436
						
437
			determineImportDifferences(importsRewrite, oldSingleImports, oldDemandImports);
451
			determineImportDifferences(importsRewrite, oldSingleImports, oldDemandImports);
438
			processor= null;
452
			
453
			return result;
439
		} finally {
454
		} finally {
440
			monitor.done();
455
			monitor.done();
441
		}
456
		}
(-)ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties (+1 lines)
Lines 66-68 Link Here
66
66
67
CodeFormatFix_description=Format code
67
CodeFormatFix_description=Format code
68
CodeFormatCleanUp_description=Format source code
68
CodeFormatCleanUp_description=Format source code
69
ImportsCleanUp_OrganizeImports_Description=Organize imports
(-)ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java (+1 lines)
Lines 27-32 Link Here
27
	public static String CleanUpRefactoringWizard_Profile_TableHeader;
27
	public static String CleanUpRefactoringWizard_Profile_TableHeader;
28
	public static String CleanUpRefactoringWizard_Project_TableHeader;
28
	public static String CleanUpRefactoringWizard_Project_TableHeader;
29
	public static String CleanUpRefactoringWizard_unknownProfile_Name;
29
	public static String CleanUpRefactoringWizard_unknownProfile_Name;
30
	public static String ImportsCleanUp_OrganizeImports_Description;
30
	public static String StringMultiFix_AddMissingNonNls_description;
31
	public static String StringMultiFix_AddMissingNonNls_description;
31
	public static String StringMultiFix_RemoveUnnecessaryNonNls_description;
32
	public static String StringMultiFix_RemoveUnnecessaryNonNls_description;
32
	
33
	
(-)ui/org/eclipse/jdt/internal/ui/fix/AbstractCleanUp.java (+8 lines)
Lines 29-34 Link Here
29
import org.eclipse.jdt.core.ICompilationUnit;
29
import org.eclipse.jdt.core.ICompilationUnit;
30
import org.eclipse.jdt.core.IJavaProject;
30
import org.eclipse.jdt.core.IJavaProject;
31
import org.eclipse.jdt.core.compiler.IProblem;
31
import org.eclipse.jdt.core.compiler.IProblem;
32
import org.eclipse.jdt.core.dom.CompilationUnit;
32
33
33
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
34
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
34
35
Lines 182-185 Link Here
182
		Map options= CleanUpConstants.loadOptions(context);
183
		Map options= CleanUpConstants.loadOptions(context);
183
		fFlags= createFlag(options);
184
		fFlags= createFlag(options);
184
    }
185
    }
186
    
187
    /**
188
     * {@inheritDoc}
189
     */
190
    public boolean needsFreshAST(CompilationUnit compilationUnit) {
191
        return false;
192
    }
185
}
193
}
(-)ui/org/eclipse/jdt/internal/ui/fix/ICleanUp.java (+9 lines)
Lines 65-70 Link Here
65
	 * @return The options as map or null
65
	 * @return The options as map or null
66
	 */
66
	 */
67
	public abstract Map getRequiredOptions();
67
	public abstract Map getRequiredOptions();
68
	
69
	/**
70
	 * If true a fresh AST, containing all the changes from previous clean ups, 
71
	 * will be created and passed to createFix.
72
	 * 
73
	 * @param compilationUnit The current available AST
74
	 * @return true if the caller needs an up to date AST
75
	 */
76
	public abstract boolean needsFreshAST(CompilationUnit compilationUnit);
68
77
69
	/**
78
	/**
70
	 * Persist current settings of this in <code>settings</code>
79
	 * Persist current settings of this in <code>settings</code>
(-)ui/org/eclipse/jdt/internal/ui/fix/CodeFormatCleanUp.java (-1 / +1 lines)
Lines 99-105 Link Here
99
	
99
	
100
	public String getPreview() {
100
	public String getPreview() {
101
		StringBuffer buf= new StringBuffer();
101
		StringBuffer buf= new StringBuffer();
102
		buf.append("package model;\n"); //$NON-NLS-1$
102
		buf.append("package org.model;\n"); //$NON-NLS-1$
103
		buf.append("public class Engine {\n"); //$NON-NLS-1$
103
		buf.append("public class Engine {\n"); //$NON-NLS-1$
104
		buf.append("  public void start() {}\n"); //$NON-NLS-1$
104
		buf.append("  public void start() {}\n"); //$NON-NLS-1$
105
		buf.append("    public \n"); //$NON-NLS-1$
105
		buf.append("    public \n"); //$NON-NLS-1$
(-)core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java (-5 / +16 lines)
Lines 15-21 Link Here
15
import java.util.Iterator;
15
import java.util.Iterator;
16
import java.util.Map;
16
import java.util.Map;
17
17
18
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
18
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
20
import org.eclipse.core.runtime.preferences.IScopeContext;
19
import org.eclipse.core.runtime.preferences.IScopeContext;
21
20
Lines 726-731 Link Here
726
	public static final String ADD_MISSING_NLS_TAGS= "cleanup.add_missing_nls_tags"; //$NON-NLS-1$
725
	public static final String ADD_MISSING_NLS_TAGS= "cleanup.add_missing_nls_tags"; //$NON-NLS-1$
727
	
726
	
728
	/**
727
	/**
728
	 * If true the imports are organized while cleaning up code.
729
	 * 
730
	 * Possible values: {TRUE, FALSE}<br>
731
	 * Default value: Value returned by {@link #getEclipseDefaultSettings()}<br>
732
	 * <br>
733
	 * @see #TRUE
734
	 * @see #FALSE
735
	 * @since 3.3
736
	 */
737
	public static final String ORGANIZE_IMPORTS= "cleanup.organize_imports"; //$NON-NLS-1$
738
	
739
	/**
729
	 * Should the Clean Up Wizard be shown when executing the Clean Up Action?
740
	 * Should the Clean Up Wizard be shown when executing the Clean Up Action?
730
	 * <br><br>
741
	 * <br><br>
731
	 * Possible values: {<code><b>true</b></code>, <code><b>false</b></code>}<br>
742
	 * Possible values: {<code><b>true</b></code>, <code><b>false</b></code>}<br>
Lines 807-819 Link Here
807
    		
818
    		
808
    	result.put(ADD_MISSING_NLS_TAGS, FALSE);
819
    	result.put(ADD_MISSING_NLS_TAGS, FALSE);
809
820
810
    	//Code Formatting
821
    	//Code Organising
811
    	result.put(FORMAT_SOURCE_CODE, FALSE);
822
    	result.put(FORMAT_SOURCE_CODE, FALSE);
812
    	
823
    	
813
    	result.put(FORMAT_COMMENT, FALSE);
824
    	result.put(FORMAT_COMMENT, FALSE);
814
    		result.put(FORMAT_SINGLE_LINE_COMMENT, TRUE);
825
    		result.put(FORMAT_SINGLE_LINE_COMMENT, TRUE);
815
    		result.put(FORMAT_MULTI_LINE_COMMENT, TRUE);
826
    		result.put(FORMAT_MULTI_LINE_COMMENT, TRUE);
816
    		result.put(FORMAT_JAVADOC, TRUE);
827
    		result.put(FORMAT_JAVADOC, TRUE);
828
    		
829
    	result.put(ORGANIZE_IMPORTS, FALSE);
817
    	
830
    	
818
	    return result;
831
	    return result;
819
    }
832
    }
Lines 825-833 Link Here
825
		Map defaultSettings= getEclipseDefaultSettings();
838
		Map defaultSettings= getEclipseDefaultSettings();
826
		for (Iterator iterator= defaultSettings.keySet().iterator(); iterator.hasNext();) {
839
		for (Iterator iterator= defaultSettings.keySet().iterator(); iterator.hasNext();) {
827
	        String key= (String)iterator.next();
840
	        String key= (String)iterator.next();
828
	        String value= node.get(key, null);
841
	        String value= node.get(key, FALSE);
829
	        
830
	        Assert.isTrue(value != null, key);
831
	        
842
	        
832
	        result.put(key, value);
843
	        result.put(key, value);
833
        }
844
        }
(-)core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.java (+1 lines)
Lines 27-32 Link Here
27
	public static String ConvertIterableLoopOperation_RemoveUpdateExpression_Warning;
27
	public static String ConvertIterableLoopOperation_RemoveUpdateExpression_Warning;
28
	public static String ConvertIterableLoopOperation_RemoveUpdateExpressions_Warning;
28
	public static String ConvertIterableLoopOperation_RemoveUpdateExpressions_Warning;
29
	public static String ConvertIterableLoopOperation_semanticChangeWarning;
29
	public static String ConvertIterableLoopOperation_semanticChangeWarning;
30
	public static String ImportsFix_OrganizeImports_Description;
30
	
31
	
31
	public static String PotentialProgrammingProblemsFix_calculatingUIDFailed_binding;
32
	public static String PotentialProgrammingProblemsFix_calculatingUIDFailed_binding;
32
	public static String PotentialProgrammingProblemsFix_calculatingUIDFailed_exception;
33
	public static String PotentialProgrammingProblemsFix_calculatingUIDFailed_exception;
(-)core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties (+1 lines)
Lines 74-76 Link Here
74
ConvertIterableLoopOperation_semanticChangeWarning=Converting the loop may change the semantics of the code.
74
ConvertIterableLoopOperation_semanticChangeWarning=Converting the loop may change the semantics of the code.
75
ConvertIterableLoopOperation_RemoveUpdateExpression_Warning=The expression ''{0}'' in the update part of the loop will be removed.
75
ConvertIterableLoopOperation_RemoveUpdateExpression_Warning=The expression ''{0}'' in the update part of the loop will be removed.
76
ConvertIterableLoopOperation_RemoveUpdateExpressions_Warning=The expressions in the update part of the loop will be removed.
76
ConvertIterableLoopOperation_RemoveUpdateExpressions_Warning=The expressions in the update part of the loop will be removed.
77
ImportsFix_OrganizeImports_Description=Organize Imports
(-)core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java (-2 / +20 lines)
Lines 196-204 Link Here
196
        }
196
        }
197
197
198
		private ICleanUp[] calculateSolutions(ICompilationUnit source, CompilationUnit ast, ICleanUp[] cleanUps) {
198
		private ICleanUp[] calculateSolutions(ICompilationUnit source, CompilationUnit ast, ICleanUp[] cleanUps) {
199
			if (cleanUps.length == 0)
200
				return null;
201
			
199
			CompilationUnitChange solution= null;
202
			CompilationUnitChange solution= null;
200
			List/*<ICleanUp>*/ result= null;
203
			List/*<ICleanUp>*/ result= null;
201
			for (int i= 0; i < cleanUps.length; i++) {
204
			int i= 0;
205
			do {
202
				ICleanUp cleanUp= cleanUps[i];
206
				ICleanUp cleanUp= cleanUps[i];
203
				try {
207
				try {
204
					IFix fix= cleanUp.createFix(ast);
208
					IFix fix= cleanUp.createFix(ast);
Lines 231-237 Link Here
231
				} catch (CoreException e) {
235
				} catch (CoreException e) {
232
					throw new FixCalculationException(e);
236
					throw new FixCalculationException(e);
233
				}
237
				}
234
			}
238
				i++;
239
			} while (i < cleanUps.length && (solution == null || !cleanUps[i].needsFreshAST(ast)));
235
			
240
			
236
			if (solution != null) {
241
			if (solution != null) {
237
				if (fLeaveFilesDirty)
242
				if (fLeaveFilesDirty)
Lines 239-244 Link Here
239
				integrateSolution(solution, source);
244
				integrateSolution(solution, source);
240
			}
245
			}
241
			
246
			
247
			for (; i < cleanUps.length; i++) {
248
	            if (result == null) {
249
	            	result= new ArrayList();
250
	            }
251
	            result.add(cleanUps[i]);
252
            }
253
			
242
			if (result == null) {
254
			if (result == null) {
243
				return null;
255
				return null;
244
			} else {
256
			} else {
Lines 773-781 Link Here
773
			MultiTextEdit multiTextEdit1= (MultiTextEdit)edit1;
785
			MultiTextEdit multiTextEdit1= (MultiTextEdit)edit1;
774
			TextEdit[] children1= multiTextEdit1.getChildren();
786
			TextEdit[] children1= multiTextEdit1.getChildren();
775
			
787
			
788
			if (children1.length == 0)
789
				return edit2;
790
			
776
			MultiTextEdit multiTextEdit2= (MultiTextEdit)edit2;
791
			MultiTextEdit multiTextEdit2= (MultiTextEdit)edit2;
777
			TextEdit[] children2= multiTextEdit2.getChildren();
792
			TextEdit[] children2= multiTextEdit2.getChildren();
778
			
793
			
794
			if (children2.length == 0)
795
				return edit1;
796
			
779
			int i1= 0;
797
			int i1= 0;
780
			int i2= 0;
798
			int i2= 0;
781
			while (i1 < children1.length && i2 < children2.length) {
799
			while (i1 < children1.length && i2 < children2.length) {
(-)ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties (-1 / +5 lines)
Lines 2-18 Link Here
2
CleanUpModifyDialog_TabPageName_MemberAccesses=Membe&r Accesses
2
CleanUpModifyDialog_TabPageName_MemberAccesses=Membe&r Accesses
3
CleanUpModifyDialog_TabPageName_UnnecessaryCode=&Unnecessary Code
3
CleanUpModifyDialog_TabPageName_UnnecessaryCode=&Unnecessary Code
4
CleanUpModifyDialog_TabPageName_MissingCode=&Missing Code
4
CleanUpModifyDialog_TabPageName_MissingCode=&Missing Code
5
CleanUpModifyDialog_TabPageName_CodeFormating=Code &Formatting
5
CleanUpModifyDialog_TabPageName_CodeFormating=Code &Organizing
6
6
7
CleanUpProfileManager_ProfileName_EclipseBuildIn=Eclipse [built-in]
7
CleanUpProfileManager_ProfileName_EclipseBuildIn=Eclipse [built-in]
8
CleanUpConfigurationBlock_SelectedCleanUps_label=Details:
8
CleanUpConfigurationBlock_SelectedCleanUps_label=Details:
9
CleanUpConfigurationBlock_ShowCleanUpWizard_checkBoxLabel=Show the Clean Up Wizard
9
CleanUpConfigurationBlock_ShowCleanUpWizard_checkBoxLabel=Show the Clean Up Wizard
10
10
11
CodeFormatingTabPage_GroupName_Formatter=Formatter
11
CodeFormatingTabPage_GroupName_Formatter=Formatter
12
CodeFormatingTabPage_Imports_GroupName=Imports
12
CodeFormatingTabPage_CheckboxName_FormatSourceCode=F&ormat source code
13
CodeFormatingTabPage_CheckboxName_FormatSourceCode=F&ormat source code
14
CodeFormatingTabPage_FormatterSettings_Description=The settings for the Formatter can be changed on the Formatter preference page.
15
CodeFormatingTabPage_OrganizeImports_CheckBoxLable=Organize imports
13
CodeFormatingTabPage_CheckboxName_FormatComments=Form&at comments
16
CodeFormatingTabPage_CheckboxName_FormatComments=Form&at comments
14
CodeFormatingTabPage_CheckboxName_FormatJavadocComments=Java&doc
17
CodeFormatingTabPage_CheckboxName_FormatJavadocComments=Java&doc
15
CodeFormatingTabPage_CheckboxName_FormatMultiLineComments=Mul&ti line comments
18
CodeFormatingTabPage_CheckboxName_FormatMultiLineComments=Mul&ti line comments
19
CodeFormatingTabPage_OrganizeImportsSettings_Description=The settings for organizing imports can be changed on the Organize Imports preference page.
16
CodeFormatingTabPage_CheckboxName_FormatSingleLineComments=&Single line comments
20
CodeFormatingTabPage_CheckboxName_FormatSingleLineComments=&Single line comments
17
21
18
CodeStyleTabPage_CheckboxName_UseBlocks=Use bloc&ks in if/while/for/do statements
22
CodeStyleTabPage_CheckboxName_UseBlocks=Use bloc&ks in if/while/for/do statements
(-)ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java (-15 / +22 lines)
Lines 25-33 Link Here
25
import org.eclipse.jdt.internal.ui.fix.CodeFormatCleanUp;
25
import org.eclipse.jdt.internal.ui.fix.CodeFormatCleanUp;
26
import org.eclipse.jdt.internal.ui.fix.CommentFormatCleanUp;
26
import org.eclipse.jdt.internal.ui.fix.CommentFormatCleanUp;
27
import org.eclipse.jdt.internal.ui.fix.ICleanUp;
27
import org.eclipse.jdt.internal.ui.fix.ICleanUp;
28
import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp;
28
import org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview;
29
import org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview;
29
import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage;
30
import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog;
30
import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog;
31
import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage;
32
import org.eclipse.jdt.internal.ui.util.PixelConverter;
31
33
32
public final class CodeFormatingTabPage extends ModifyDialogTabPage {
34
public final class CodeFormatingTabPage extends ModifyDialogTabPage {
33
	   
35
	   
Lines 42-47 Link Here
42
44
43
	    protected JavaPreview doCreateJavaPreview(Composite parent) {
45
	    protected JavaPreview doCreateJavaPreview(Composite parent) {
44
	        fCleanUpPreview= new CleanUpPreview(parent, new ICleanUp[] {
46
	        fCleanUpPreview= new CleanUpPreview(parent, new ICleanUp[] {
47
	        	new ImportsCleanUp(fValues),
45
        		new CodeFormatCleanUp(fValues),
48
        		new CodeFormatCleanUp(fValues),
46
    	    	new CommentFormatCleanUp(fValues)
49
    	    	new CommentFormatCleanUp(fValues)
47
	        }, false);
50
	        }, false);
Lines 77-96 Link Here
77
	    	multiLinePref.setEnabled(formatCommentsPref.getChecked());
80
	    	multiLinePref.setEnabled(formatCommentsPref.getChecked());
78
	    	singleLinePref.setEnabled(formatCommentsPref.getChecked());
81
	    	singleLinePref.setEnabled(formatCommentsPref.getChecked());
79
	    	
82
	    	
80
//	    	Link link= new Link(group, SWT.WRAP | SWT.RIGHT);
83
	    	PixelConverter pixelConverter= new PixelConverter(composite);
81
//			link.setText("The settings for the Formatter can be changed on the <a>Formatter preference page</a>."); 
84
	    	
82
//			link.addSelectionListener(new SelectionAdapter() {
85
	    	createLabel(CleanUpMessages.CodeFormatingTabPage_FormatterSettings_Description, group, numColumns, pixelConverter).setFont(composite.getFont());
83
//				public void widgetSelected(SelectionEvent e) {
86
			
84
//					CleanUpModifyDialog.this.okPressed();
87
			Group importsGroup= createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_Imports_GroupName);
85
//					PreferencesUtil.createPreferenceDialogOn(getShell(), CodeFormatterPreferencePage.PREF_ID, null, null).open();
88
	    	createCheckboxPref(importsGroup, numColumns, CleanUpMessages.CodeFormatingTabPage_OrganizeImports_CheckBoxLable, CleanUpConstants.ORGANIZE_IMPORTS, CleanUpModifyDialog.FALSE_TRUE);
86
//				}
89
	    	
87
//			});
90
	    	createLabel(CleanUpMessages.CodeFormatingTabPage_OrganizeImportsSettings_Description, importsGroup, numColumns, pixelConverter).setFont(composite.getFont());
88
//			link.setToolTipText("Shows the Formatter preference page"); 
91
	    }
89
//			GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 0);
92
90
//			gridData.widthHint= convertHorizontalDLUsToPixels(150);
93
		private Label createLabel(String text, Group group, int numColumns, PixelConverter pixelConverter) {
91
//			link.setLayoutData(gridData);
94
	        Label label= new Label(group, SWT.WRAP);
92
//			link.setFont(composite.getFont());
95
	    	label.setText(text); 
93
	    }
96
			GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 0);
97
			gridData.widthHint= pixelConverter.convertHorizontalDLUsToPixels(150);
98
			label.setLayoutData(gridData);
99
			return label;
100
        }
94
101
95
	    private void intent(Group group) {
102
	    private void intent(Group group) {
96
	        Label l= new Label(group, SWT.NONE);
103
	        Label l= new Label(group, SWT.NONE);
(-)ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java (-1 / +14 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.jdt.internal.ui.preferences.cleanup;
12
package org.eclipse.jdt.internal.ui.preferences.cleanup;
13
13
14
import java.util.Map;
15
16
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
17
14
import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner;
18
import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner;
15
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
19
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
16
20
Lines 20-27 Link Here
20
	private static final String CLEAN_UP_PROFILE_KIND= "CleanUpProfile"; //$NON-NLS-1$
24
	private static final String CLEAN_UP_PROFILE_KIND= "CleanUpProfile"; //$NON-NLS-1$
21
25
22
	private static final int VERSION_1= 1; // 3.3M2
26
	private static final int VERSION_1= 1; // 3.3M2
27
	private static final int VERSION_2= 2; // 3.3M3 Added ORGANIZE_IMPORTS
23
	
28
	
24
	private static final int CURRENT_VERSION= VERSION_1;
29
	private static final int CURRENT_VERSION= VERSION_2;
25
	
30
	
26
	/* (non-Javadoc)
31
	/* (non-Javadoc)
27
     * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#getFirstVersion()
32
     * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#getFirstVersion()
Lines 41-46 Link Here
41
     * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#updateAndComplete(org.eclipse.jdt.internal.ui.preferences.cleanup.ProfileManager.CustomProfile)
46
     * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#updateAndComplete(org.eclipse.jdt.internal.ui.preferences.cleanup.ProfileManager.CustomProfile)
42
     */
47
     */
43
	public void update(CustomProfile profile) {
48
	public void update(CustomProfile profile) {
49
		if (profile.getVersion() == VERSION_1)
50
			updateFrom1To2(profile);
51
		
44
		profile.setVersion(CURRENT_VERSION);
52
		profile.setVersion(CURRENT_VERSION);
45
	}
53
	}
46
54
Lines 50-54 Link Here
50
    public String getProfileKind() {
58
    public String getProfileKind() {
51
	    return CLEAN_UP_PROFILE_KIND;
59
	    return CLEAN_UP_PROFILE_KIND;
52
    }
60
    }
61
    
62
	private static void updateFrom1To2(CustomProfile profile) {
63
		Map defaultSettings= CleanUpConstants.getEclipseDefaultSettings();
64
		profile.getSettings().put(CleanUpConstants.ORGANIZE_IMPORTS, defaultSettings.get(CleanUpConstants.ORGANIZE_IMPORTS));
65
    }
53
	
66
	
54
 }
67
 }
(-)ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java (+4 lines)
Lines 32-38 Link Here
32
	public static String CodeFormatingTabPage_CheckboxName_FormatMultiLineComments;
32
	public static String CodeFormatingTabPage_CheckboxName_FormatMultiLineComments;
33
	public static String CodeFormatingTabPage_CheckboxName_FormatSingleLineComments;
33
	public static String CodeFormatingTabPage_CheckboxName_FormatSingleLineComments;
34
	public static String CodeFormatingTabPage_CheckboxName_FormatSourceCode;
34
	public static String CodeFormatingTabPage_CheckboxName_FormatSourceCode;
35
	public static String CodeFormatingTabPage_FormatterSettings_Description;
35
	public static String CodeFormatingTabPage_GroupName_Formatter;
36
	public static String CodeFormatingTabPage_GroupName_Formatter;
37
	public static String CodeFormatingTabPage_Imports_GroupName;
38
	public static String CodeFormatingTabPage_OrganizeImports_CheckBoxLable;
39
	public static String CodeFormatingTabPage_OrganizeImportsSettings_Description;
36
40
37
	public static String CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced;
41
	public static String CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced;
38
	public static String CodeStyleTabPage_CheckboxName_UseBlocks;
42
	public static String CodeStyleTabPage_CheckboxName_UseBlocks;
(-)ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java (+2 lines)
Lines 40-45 Link Here
40
import org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp;
40
import org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp;
41
import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp;
41
import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp;
42
import org.eclipse.jdt.internal.ui.fix.ICleanUp;
42
import org.eclipse.jdt.internal.ui.fix.ICleanUp;
43
import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp;
43
import org.eclipse.jdt.internal.ui.fix.Java50CleanUp;
44
import org.eclipse.jdt.internal.ui.fix.Java50CleanUp;
44
import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp;
45
import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp;
45
import org.eclipse.jdt.internal.ui.fix.StringCleanUp;
46
import org.eclipse.jdt.internal.ui.fix.StringCleanUp;
Lines 109-114 Link Here
109
                		new StringCleanUp(sharedSettings),
110
                		new StringCleanUp(sharedSettings),
110
                		new Java50CleanUp(sharedSettings),
111
                		new Java50CleanUp(sharedSettings),
111
                		new PotentialProgrammingProblemsCleanUp(sharedSettings),
112
                		new PotentialProgrammingProblemsCleanUp(sharedSettings),
113
                		new ImportsCleanUp(sharedSettings),
112
                		new CodeFormatCleanUp(sharedSettings),
114
                		new CodeFormatCleanUp(sharedSettings),
113
                		new CommentFormatCleanUp(sharedSettings)
115
                		new CommentFormatCleanUp(sharedSettings)
114
                };
116
                };
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java (+2 lines)
Lines 106-111 Link Here
106
import org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp;
106
import org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp;
107
import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp;
107
import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp;
108
import org.eclipse.jdt.internal.ui.fix.Java50CleanUp;
108
import org.eclipse.jdt.internal.ui.fix.Java50CleanUp;
109
import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp;
109
import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp;
110
import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp;
110
import org.eclipse.jdt.internal.ui.fix.StringCleanUp;
111
import org.eclipse.jdt.internal.ui.fix.StringCleanUp;
111
import org.eclipse.jdt.internal.ui.fix.UnnecessaryCodeCleanUp;
112
import org.eclipse.jdt.internal.ui.fix.UnnecessaryCodeCleanUp;
Lines 251-256 Link Here
251
		refactoring.addCleanUp(new PotentialProgrammingProblemsCleanUp());
252
		refactoring.addCleanUp(new PotentialProgrammingProblemsCleanUp());
252
		refactoring.addCleanUp(new UnnecessaryCodeCleanUp());
253
		refactoring.addCleanUp(new UnnecessaryCodeCleanUp());
253
		refactoring.addCleanUp(new StringCleanUp());
254
		refactoring.addCleanUp(new StringCleanUp());
255
		refactoring.addCleanUp(new ImportsCleanUp());
254
		refactoring.addCleanUp(new CodeFormatCleanUp());
256
		refactoring.addCleanUp(new CodeFormatCleanUp());
255
		refactoring.addCleanUp(new CommentFormatCleanUp());
257
		refactoring.addCleanUp(new CommentFormatCleanUp());
256
		
258
		
(-)core (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.corext.fix;
12
13
import org.eclipse.text.edits.TextEdit;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IStatus;
17
18
import org.eclipse.ltk.core.refactoring.CategorizedTextEditGroup;
19
import org.eclipse.ltk.core.refactoring.GroupCategory;
20
import org.eclipse.ltk.core.refactoring.GroupCategorySet;
21
import org.eclipse.ltk.core.refactoring.TextChange;
22
23
import org.eclipse.jdt.core.ICompilationUnit;
24
import org.eclipse.jdt.core.dom.CompilationUnit;
25
26
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
27
import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation;
28
import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange;
29
30
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
31
32
public class ImportsFix extends AbstractFix {
33
	
34
	public static IFix createCleanUp(final CompilationUnit cu, CodeGenerationSettings settings, boolean organizeImports) throws CoreException {
35
		if (!organizeImports)
36
			return null;
37
		
38
		OrganizeImportsOperation op= new OrganizeImportsOperation((ICompilationUnit)cu.getJavaElement(), cu, settings.importIgnoreLowercase, false, true, null);
39
		final TextEdit edit= op.createTextEdit(null);
40
		if (edit == null)
41
			return null;
42
		
43
		if (op.getNumberOfImportsAdded() == 0 && op.getNumberOfImportsRemoved() == 0)
44
			return null;
45
46
		return new IFix() {
47
			
48
			public TextChange createChange() throws CoreException {
49
				CompilationUnitChange result= new CompilationUnitChange("", getCompilationUnit()); //$NON-NLS-1$
50
				result.setEdit(edit);
51
				String label= getDescription();
52
				result.addTextEditGroup(new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))));
53
	            return result;
54
            }
55
56
			public ICompilationUnit getCompilationUnit() {
57
	            return (ICompilationUnit)cu.getJavaElement();
58
            }
59
60
			public String getDescription() {
61
	            return FixMessages.ImportsFix_OrganizeImports_Description;
62
            }
63
64
			public IStatus getStatus() {
65
	            return StatusInfo.OK_STATUS;
66
         	  }
67
    	};
68
    }
69
	
70
	protected ImportsFix(String name, CompilationUnit compilationUnit, IFixRewriteOperation[] fixRewriteOperations) {
71
	    super(name, compilationUnit, fixRewriteOperations);
72
    }
73
}
(-)ui/org/eclipse/jdt/internal/ui/fix/ImportsCleanUp.java (+155 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.fix;
12
13
import java.util.Map;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
18
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
19
20
import org.eclipse.jdt.core.ICompilationUnit;
21
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.dom.CompilationUnit;
23
24
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
25
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
26
import org.eclipse.jdt.internal.corext.fix.IFix;
27
import org.eclipse.jdt.internal.corext.fix.ImportsFix;
28
29
import org.eclipse.jdt.ui.text.java.IProblemLocation;
30
31
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
32
33
public class ImportsCleanUp extends AbstractCleanUp {
34
	
35
	private static int ORGANIZE_IMPORTS= 1;
36
	private CodeGenerationSettings fCodeGeneratorSettings;
37
38
	public ImportsCleanUp(Map options) {
39
		super(options);
40
    }
41
	
42
	public ImportsCleanUp() {
43
		super();
44
    }
45
46
	/**
47
     * {@inheritDoc}
48
     */
49
    protected int createFlag(Map options) {
50
		int result= 0;
51
    	
52
		if (CleanUpConstants.TRUE.equals(options.get(CleanUpConstants.ORGANIZE_IMPORTS))) {
53
			result |= ORGANIZE_IMPORTS;	
54
		}
55
    	
56
	    return result;
57
    }
58
59
	/**
60
     * {@inheritDoc}
61
     */
62
    public boolean canFix(CompilationUnit compilationUnit, IProblemLocation problem) throws CoreException {
63
	    return false;
64
    }
65
66
	/**
67
     * {@inheritDoc}
68
     */
69
    public IFix createFix(final CompilationUnit compilationUnit) throws CoreException {
70
		return ImportsFix.createCleanUp(compilationUnit, fCodeGeneratorSettings,
71
				isFlag(ORGANIZE_IMPORTS));
72
	}
73
74
	/**
75
     * {@inheritDoc}
76
     */
77
    public IFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
78
	    return null;
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public RefactoringStatus checkPreConditions(IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException {
85
    	if (isFlag(ORGANIZE_IMPORTS))
86
    		fCodeGeneratorSettings= JavaPreferencesSettings.getCodeGenerationSettings(project);
87
    	
88
		return super.checkPreConditions(project, compilationUnits, monitor);
89
    }
90
    
91
    /**
92
     * {@inheritDoc}
93
     */
94
    public RefactoringStatus checkPostConditions(IProgressMonitor monitor) throws CoreException {
95
    	fCodeGeneratorSettings= null;
96
    	
97
        return super.checkPostConditions(monitor);
98
    }
99
	/**
100
     * {@inheritDoc}
101
     */
102
    public int getDefaultFlag() {
103
	    return 0;
104
    }
105
106
	/**
107
     * {@inheritDoc}
108
     */
109
    public String[] getDescriptions() {
110
    	if (isFlag(ORGANIZE_IMPORTS))
111
    		return new String[] {MultiFixMessages.ImportsCleanUp_OrganizeImports_Description};
112
    		
113
	    return null;
114
    }
115
116
	/**
117
     * {@inheritDoc}
118
     */
119
    public String getPreview() {
120
		StringBuffer buf= new StringBuffer();
121
		
122
		if (isFlag(ORGANIZE_IMPORTS)) {
123
			buf.append("import org.model.Engine;\n"); //$NON-NLS-1$
124
		} else {
125
			buf.append("import org.model.*;\n"); //$NON-NLS-1$
126
		}
127
		
128
		return buf.toString();
129
    }
130
131
	/**
132
     * {@inheritDoc}
133
     */
134
    public Map getRequiredOptions() {
135
	    return null;
136
    }
137
138
	/**
139
     * {@inheritDoc}
140
     */
141
    public int maximalNumberOfFixes(CompilationUnit compilationUnit) {
142
	    return -1;
143
    }
144
145
	/**
146
     * {@inheritDoc}
147
     */
148
    public boolean needsFreshAST(CompilationUnit compilationUnit) {
149
    	if (isFlag(ORGANIZE_IMPORTS))
150
	    	return true;
151
    	
152
    	return super.needsFreshAST(compilationUnit);
153
    }
154
155
}

Return to bug 154109