Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 52143 Details for
Bug 154109
[clean up] [plan] Extend Clean Up
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
organize imports patch
fix_organize_imports.txt (text/plain), 66.43 KB, created by
Benno Baumgartner
on 2006-10-17 12:37:46 EDT
(
hide
)
Description:
organize imports patch
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2006-10-17 12:37:46 EDT
Size:
66.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui.tests >Index: performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java,v >retrieving revision 1.18 >diff -u -r1.18 CleanUpPerfTest.java >--- performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java 22 Jun 2006 08:44:03 -0000 1.18 >+++ performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java 17 Oct 2006 15:04:18 -0000 >@@ -136,6 +136,9 @@ > public String getPreview() { > return null; > } >+ public boolean needsFreshAST(CompilationUnit compilationUnit) { >+ return false; >+ } > }); > > cleanUpRefactoring.checkAllConditions(new NullProgressMonitor()); >Index: ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java,v >retrieving revision 1.7 >diff -u -r1.7 CleanUpStressTest.java >--- ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 13 Oct 2006 13:40:38 -0000 1.7 >+++ ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 17 Oct 2006 15:04:20 -0000 >@@ -136,11 +136,25 @@ > buf= new StringBuffer(); > buf.append("package junit.runner;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >- buf.append("import java.lang.reflect.*;\n"); >+ buf.append("import java.io.BufferedReader;\n"); >+ buf.append("import java.io.File;\n"); >+ buf.append("import java.io.FileInputStream;\n"); >+ buf.append("import java.io.FileOutputStream;\n"); >+ buf.append("import java.io.IOException;\n"); >+ buf.append("import java.io.InputStream;\n"); >+ buf.append("import java.io.PrintWriter;\n"); >+ buf.append("import java.io.StringReader;\n"); >+ buf.append("import java.io.StringWriter;\n"); >+ buf.append("import java.lang.reflect.InvocationTargetException;\n"); >+ buf.append("import java.lang.reflect.Method;\n"); >+ buf.append("import java.lang.reflect.Modifier;\n"); > buf.append("import java.text.NumberFormat;\n"); >- buf.append("import java.io.*;\n"); >- buf.append("import java.util.*;\n"); >+ buf.append("import java.util.Properties;\n"); >+ buf.append("\n"); >+ buf.append("import junit.framework.AssertionFailedError;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestListener;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * Base class for all test runners. This class was born live on stage in\n"); >@@ -248,7 +262,8 @@ > buf.append(" }\n"); > buf.append(" Test test = null;\n"); > buf.append(" try {\n"); >- buf.append(" test = (Test) suiteMethod.invoke(null, new Class[0]); // static method\n"); >+ buf.append(" test = (Test) suiteMethod.invoke(null, new Class[0]); // static\n"); >+ buf.append(" // method\n"); > buf.append(" if (test == null) {\n"); > buf.append(" return test;\n"); > buf.append(" }\n"); >@@ -451,7 +466,8 @@ > buf.append(" final String[] patterns = new String[]{\"junit.framework.TestCase\", //$NON-NLS-1$\n"); > buf.append(" \"junit.framework.TestResult\", //$NON-NLS-1$\n"); > buf.append(" \"junit.framework.TestSuite\", //$NON-NLS-1$\n"); >- buf.append(" \"junit.framework.Assert.\", // don't filter AssertionFailure //$NON-NLS-1$\n"); >+ buf.append(" \"junit.framework.Assert.\", // don't filter AssertionFailure\n"); >+ buf.append(" // //$NON-NLS-1$\n"); > buf.append(" \"junit.swingui.TestRunner\", //$NON-NLS-1$\n"); > buf.append(" \"junit.awtui.TestRunner\", //$NON-NLS-1$\n"); > buf.append(" \"junit.textui.TestRunner\", //$NON-NLS-1$\n"); >@@ -491,8 +507,11 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.runner;\n"); > buf.append("\n"); >- buf.append("import java.io.*;\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import java.io.PrintWriter;\n"); >+ buf.append("import java.io.StringWriter;\n"); >+ buf.append("\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("import junit.runner.BaseTestRunner;\n"); > buf.append("\n"); > buf.append("public class StackFilterTest extends TestCase {\n"); >@@ -760,7 +779,8 @@ > buf= new StringBuffer(); > buf.append("package junit.samples;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * TestSuite that runs all the sample tests\n"); >@@ -783,8 +803,9 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >- buf.append("import junit.extensions.*;\n"); >+ buf.append("import junit.extensions.ExceptionTestCase;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("public class ExceptionTestCaseTest extends junit.framework.TestCase {\n"); > buf.append("\n"); >@@ -858,7 +879,12 @@ > buf.append("/**\n"); > buf.append(" * Test class used in SuiteTest\n"); > buf.append(" */\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.AssertionFailedError;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestListener;\n"); >+ buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("public class TestListenerTest extends TestCase implements TestListener {\n"); > buf.append(" private TestResult fResult;\n"); >@@ -927,7 +953,8 @@ > buf.append("\n"); > buf.append("import java.util.Vector;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("import junit.runner.Sorter;\n"); > buf.append("\n"); > buf.append("public class SorterTest extends TestCase {\n"); >@@ -972,7 +999,11 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.framework;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Protectable;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * Test an implementor of junit.framework.Test other than TestCase or TestSuite\n"); >@@ -1026,7 +1057,9 @@ > buf= new StringBuffer(); > buf.append("package junit.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A Decorator for Tests. Use TestDecorator as the base class for defining new\n"); >@@ -1263,7 +1296,9 @@ > buf= new StringBuffer(); > buf.append("package junit.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestResult;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A TestSuite for active Tests. It runs each test in a separate thread and\n"); >@@ -1331,7 +1366,11 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.framework;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestResult;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A fixture for testing the \"auto\" test suite feature.\n"); >@@ -1475,7 +1514,7 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.framework;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A test case testing the testing framework.\n"); >@@ -1494,8 +1533,10 @@ > buf= new StringBuffer(); > buf.append("package junit.runner;\n"); > buf.append("\n"); >- buf.append("import java.lang.reflect.*;\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import java.lang.reflect.Modifier;\n"); >+ buf.append("\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * An implementation of a TestCollector that loads all classes on the class path\n"); >@@ -1569,10 +1610,18 @@ > buf= new StringBuffer(); > buf.append("package junit.runner;\n"); > buf.append("\n"); >- buf.append("import java.util.*;\n"); >- buf.append("import java.io.*;\n"); >+ buf.append("import java.io.ByteArrayOutputStream;\n"); >+ buf.append("import java.io.File;\n"); >+ buf.append("import java.io.FileInputStream;\n"); >+ buf.append("import java.io.IOException;\n"); >+ buf.append("import java.io.InputStream;\n"); > buf.append("import java.net.URL;\n"); >- buf.append("import java.util.zip.*;\n"); >+ buf.append("import java.util.Enumeration;\n"); >+ buf.append("import java.util.Properties;\n"); >+ buf.append("import java.util.StringTokenizer;\n"); >+ buf.append("import java.util.Vector;\n"); >+ buf.append("import java.util.zip.ZipEntry;\n"); >+ buf.append("import java.util.zip.ZipFile;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A custom class loader which enables the reloading of classes for each test\n"); >@@ -1835,7 +1884,10 @@ > buf= new StringBuffer(); > buf.append("package junit.samples;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * Some simple tests.\n"); >@@ -1942,9 +1994,10 @@ > buf.append(" public void testInvokeNonStaticSuite() {\n"); > buf.append(" final BaseTestRunner runner = new MockRunner();\n"); > buf.append(" runner.getTest(\"junit.tests.runner.BaseTestRunnerTest$NonStatic\"); // Used\n"); >- buf.append(" // to\n"); >- buf.append(" // throw\n"); >- buf.append(" // NullPointerException //$NON-NLS-1$\n"); >+ buf.append(" // to\n"); >+ buf.append(" // throw\n"); >+ buf.append(" // NullPointerException\n"); >+ buf.append(" // //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("}\n"); > buf.append(""); >@@ -1952,7 +2005,7 @@ > buf= new StringBuffer(); > buf.append("package junit.tests;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A helper test case for testing whether the testing method is run.\n"); >@@ -1968,11 +2021,14 @@ > buf= new StringBuffer(); > buf.append("package junit.framework;\n"); > buf.append("\n"); >- buf.append("import java.util.Vector;\n"); >- buf.append("import java.util.Enumeration;\n"); > buf.append("import java.io.PrintWriter;\n"); > buf.append("import java.io.StringWriter;\n"); >- buf.append("import java.lang.reflect.*;\n"); >+ buf.append("import java.lang.reflect.Constructor;\n"); >+ buf.append("import java.lang.reflect.InvocationTargetException;\n"); >+ buf.append("import java.lang.reflect.Method;\n"); >+ buf.append("import java.lang.reflect.Modifier;\n"); >+ buf.append("import java.util.Enumeration;\n"); >+ buf.append("import java.util.Vector;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A <code>TestSuite</code> is a <code>Composite</code> of Tests. It runs a\n"); >@@ -2026,8 +2082,8 @@ > buf.append(" public TestSuite(final Class theClass) {\n"); > buf.append(" this.fName = theClass.getName();\n"); > buf.append(" try {\n"); >- buf.append(" TestSuite.getTestConstructor(theClass); // Avoid generating multiple error\n"); >- buf.append(" // messages\n"); >+ buf.append(" TestSuite.getTestConstructor(theClass); // Avoid generating multiple\n"); >+ buf.append(" // error messages\n"); > buf.append(" } catch (final NoSuchMethodException e) {\n"); > buf.append(" this\n"); > buf.append(" .addTest(TestSuite\n"); >@@ -2261,7 +2317,8 @@ > buf= new StringBuffer(); > buf.append("package junit.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A TestCase that expects an Exception of class fExpected to be thrown. The\n"); >@@ -2420,9 +2477,6 @@ > buf.append(" actual));\n"); > buf.append(" }\n"); > buf.append(" } else if (!(Math.abs(expected - actual) <= delta)) {\n"); >- buf.append(" // comparison with\n"); >- buf.append(" // NaN always\n"); >- buf.append(" // returns false\n"); > buf.append(" Assert.failNotEquals(message, new Double(expected), new Double(\n"); > buf.append(" actual));\n"); > buf.append(" }\n"); >@@ -2651,8 +2705,11 @@ > buf= new StringBuffer(); > buf.append("package junit.runner;\n"); > buf.append("\n"); >- buf.append("import java.util.*;\n"); >- buf.append("import java.io.*;\n"); >+ buf.append("import java.io.File;\n"); >+ buf.append("import java.util.Enumeration;\n"); >+ buf.append("import java.util.Hashtable;\n"); >+ buf.append("import java.util.StringTokenizer;\n"); >+ buf.append("import java.util.Vector;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * An implementation of a TestCollector that consults the class path. It\n"); >@@ -2766,8 +2823,12 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >- buf.append("import junit.extensions.*;\n"); >+ buf.append("import junit.extensions.ActiveTestSuite;\n"); >+ buf.append("import junit.extensions.RepeatedTest;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * Testing the ActiveTest support\n"); >@@ -2892,8 +2953,13 @@ > buf.append("\n"); > buf.append("import java.io.PrintStream;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >- buf.append("import junit.runner.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestResult;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); >+ buf.append("import junit.runner.BaseTestRunner;\n"); >+ buf.append("import junit.runner.StandardTestSuiteLoader;\n"); >+ buf.append("import junit.runner.TestSuiteLoader;\n"); >+ buf.append("import junit.runner.Version;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A command line based tool to run tests.\n"); >@@ -3092,7 +3158,8 @@ > buf.append("/**\n"); > buf.append(" * Test class used in TestTestCaseClassLoader\n"); > buf.append(" */\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("\n"); > buf.append("public class ClassLoaderTest extends Assert {\n"); > buf.append(" public ClassLoaderTest() {\n"); >@@ -3281,8 +3348,12 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >- buf.append("import junit.extensions.*;\n"); >+ buf.append("import junit.extensions.TestSetup;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestResult;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("import junit.tests.WasRun;\n"); > buf.append("\n"); > buf.append("/**\n"); >@@ -3378,7 +3449,8 @@ > buf= new StringBuffer(); > buf.append("package junit.tests;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * TestSuite that runs all the JUnit tests\n"); >@@ -3405,7 +3477,7 @@ > buf.append("/**\n"); > buf.append(" * Test class used in TestTestCaseClassLoader\n"); > buf.append(" */\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); > buf.append("\n"); > buf.append("public class LoadedFromJar extends Assert {\n"); > buf.append(" public void verify() {\n"); >@@ -3576,9 +3648,11 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void printDefect(final TestFailure booBoo, final int count) { // only public\n"); >- buf.append(" // for testing\n"); >- buf.append(" // purposes\n"); >+ buf.append(" public void printDefect(final TestFailure booBoo, final int count) { // only\n"); >+ buf.append(" // public\n"); >+ buf.append(" // for\n"); >+ buf.append(" // testing\n"); >+ buf.append(" // purposes\n"); > buf.append(" this.printDefectHeader(booBoo, count);\n"); > buf.append(" this.printDefectTrace(booBoo);\n"); > buf.append(" }\n"); >@@ -3661,10 +3735,13 @@ > buf= new StringBuffer(); > buf.append("package junit.samples;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >- buf.append("\n"); > buf.append("import java.util.Vector;\n"); > buf.append("\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); >+ buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A sample test case, testing <code>java.util.Vector</code>.\n"); > buf.append(" * \n"); >@@ -3814,7 +3891,13 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.framework;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.AssertionFailedError;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestFailure;\n"); >+ buf.append("import junit.framework.TestResult;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("import junit.tests.WasRun;\n"); > buf.append("\n"); > buf.append("/**\n"); >@@ -4054,7 +4137,8 @@ > buf.append(" */\n"); > buf.append("public class ReloadingTestSuiteLoader implements TestSuiteLoader {\n"); > buf.append("\n"); >- buf.append(" public Class load(final String suiteClassName) throws ClassNotFoundException {\n"); >+ buf.append(" public Class load(final String suiteClassName)\n"); >+ buf.append(" throws ClassNotFoundException {\n"); > buf.append(" return this.createLoader().loadClass(suiteClassName, true);\n"); > buf.append(" }\n"); > buf.append("\n"); >@@ -4077,7 +4161,8 @@ > buf.append(" /**\n"); > buf.append(" * Uses the system class loader to load the test class\n"); > buf.append(" */\n"); >- buf.append(" public Class load(final String suiteClassName) throws ClassNotFoundException {\n"); >+ buf.append(" public Class load(final String suiteClassName)\n"); >+ buf.append(" throws ClassNotFoundException {\n"); > buf.append(" return Class.forName(suiteClassName);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >@@ -4091,7 +4176,9 @@ > buf= new StringBuffer(); > buf.append("package junit.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Protectable;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A Decorator to set up and tear down additional fixture state. Subclass\n"); >@@ -4199,7 +4286,8 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.framework;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A test case testing the testing framework.\n"); >@@ -4227,7 +4315,8 @@ > buf= new StringBuffer(); > buf.append("package junit.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A Decorator that runs a test repeatedly.\n"); >@@ -4276,7 +4365,7 @@ > buf= new StringBuffer(); > buf.append("package junit.runner;\n"); > buf.append("\n"); >- buf.append("import java.util.*;\n"); >+ buf.append("import java.util.Vector;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A custom quick sort with support to customize the swap behaviour. NOTICE: We\n"); >@@ -4319,7 +4408,8 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.framework;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * TestSuite that runs all the sample tests\n"); >@@ -4335,7 +4425,7 @@ > buf.append(" final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n"); > buf.append(" suite.addTestSuite(TestCaseTest.class);\n"); > buf.append(" suite.addTest(SuiteTest.suite()); // Tests suite building, so can't\n"); >- buf.append(" // use automatic test extraction\n"); >+ buf.append(" // use automatic test extraction\n"); > buf.append(" suite.addTestSuite(TestListenerTest.class);\n"); > buf.append(" suite.addTestSuite(AssertTest.class);\n"); > buf.append(" suite.addTestSuite(TestImplementorTest.class);\n"); >@@ -4350,8 +4440,12 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); > buf.append("import junit.extensions.RepeatedTest;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.framework.TestResult;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * Testing the RepeatedTest support.\n"); >@@ -4411,7 +4505,8 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.runner;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("import junit.runner.BaseTestRunner;\n"); > buf.append("\n"); > buf.append("/**\n"); >@@ -4425,7 +4520,7 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public static Test suite() { // Collect tests manually because we have to\n"); >- buf.append(" // test class collection code\n"); >+ buf.append(" // test class collection code\n"); > buf.append(" final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n"); > buf.append(" suite.addTestSuite(StackFilterTest.class);\n"); > buf.append(" suite.addTestSuite(SorterTest.class);\n"); >@@ -4450,7 +4545,7 @@ > buf= new StringBuffer(); > buf.append("package junit.runner;\n"); > buf.append("\n"); >- buf.append("import java.util.*;\n"); >+ buf.append("import java.util.Enumeration;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * Collects Test class names to be presented by the TestSelector.\n"); >@@ -4468,7 +4563,8 @@ > buf= new StringBuffer(); > buf.append("package junit.samples.money;\n"); > buf.append("\n"); >- buf.append("import java.util.*;\n"); >+ buf.append("import java.util.Enumeration;\n"); >+ buf.append("import java.util.Vector;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A MoneyBag defers exchange rate conversions. For example adding 12 Swiss\n"); >@@ -4636,7 +4732,9 @@ > buf= new StringBuffer(); > buf.append("package junit.framework;\n"); > buf.append("\n"); >- buf.append("import java.lang.reflect.*;\n"); >+ buf.append("import java.lang.reflect.InvocationTargetException;\n"); >+ buf.append("import java.lang.reflect.Method;\n"); >+ buf.append("import java.lang.reflect.Modifier;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A test case defines the fixture to run multiple tests. To define a test case<br>\n"); >@@ -4848,7 +4946,8 @@ > buf= new StringBuffer(); > buf.append("package junit.samples.money;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestCase;\n"); > buf.append("\n"); > buf.append("public class MoneyTest extends TestCase {\n"); > buf.append(" private Money f12CHF;\n"); >@@ -5005,7 +5104,8 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.extensions;\n"); > buf.append("\n"); >- buf.append("import junit.framework.*;\n"); >+ buf.append("import junit.framework.Test;\n"); >+ buf.append("import junit.framework.TestSuite;\n"); > buf.append("\n"); > buf.append("/**\n"); > buf.append(" * TestSuite that runs all the extension tests\n"); >@@ -5018,7 +5118,7 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public static Test suite() { // Collect tests manually because we have to\n"); >- buf.append(" // test class collection code\n"); >+ buf.append(" // test class collection code\n"); > buf.append(" final TestSuite suite = new TestSuite(\"Framework Tests\"); //$NON-NLS-1$\n"); > buf.append(" suite.addTestSuite(ExtensionTest.class);\n"); > buf.append(" suite.addTestSuite(ExceptionTestCaseTest.class);\n"); >@@ -5044,11 +5144,13 @@ > buf= new StringBuffer(); > buf.append("package junit.tests.runner;\n"); > buf.append("\n"); >- buf.append("import java.lang.reflect.*;\n"); >- buf.append("import junit.framework.*;\n"); >- buf.append("import junit.runner.*;\n"); >+ buf.append("import java.lang.reflect.Method;\n"); > buf.append("import java.net.URL;\n"); > buf.append("\n"); >+ buf.append("import junit.framework.Assert;\n"); >+ buf.append("import junit.framework.TestCase;\n"); >+ buf.append("import junit.runner.TestCaseClassLoader;\n"); >+ buf.append("\n"); > buf.append("/**\n"); > buf.append(" * A TestCase for testing the TestCaseClassLoader\n"); > buf.append(" * \n"); >@@ -5173,7 +5275,7 @@ > buf.append("}"); > fExpectedChangesAllTests.put("junit.samples.money.Money.java", buf.toString()); > } >- >+ > public void testAllCleanUps() throws Exception { > List cus= new ArrayList(); > addAllCUs(MyTestSetup.fJProject1.getChildren(), cus); >@@ -5235,6 +5337,8 @@ > node.put(CleanUpConstants.FORMAT_SINGLE_LINE_COMMENT, CleanUpConstants.TRUE); > > node.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpConstants.TRUE); >+ >+ node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.TRUE); > > ICompilationUnit[] units= (ICompilationUnit[])cus.toArray(new ICompilationUnit[cus.size()]); > Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); >#P org.eclipse.jdt.ui >Index: core extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java,v >retrieving revision 1.80 >diff -u -r1.80 OrganizeImportsOperation.java >--- core extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java 13 Oct 2006 10:15:51 -0000 1.80 >+++ core extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java 17 Oct 2006 15:04:22 -0000 >@@ -380,10 +380,27 @@ > monitor= new NullProgressMonitor(); > } > try { >+ monitor.beginTask(Messages.format(CodeGenerationMessages.OrganizeImportsOperation_description, fCompilationUnit.getElementName()), 10); >+ >+ TextEdit edit= createTextEdit(new SubProgressMonitor(monitor, 9)); >+ if (edit == null) >+ return; >+ >+ JavaModelUtil.applyEdit(fCompilationUnit, edit, fDoSave, new SubProgressMonitor(monitor, 1)); >+ } finally { >+ monitor.done(); >+ } >+ } >+ >+ public TextEdit createTextEdit(IProgressMonitor monitor) throws CoreException, OperationCanceledException { >+ if (monitor == null) { >+ monitor= new NullProgressMonitor(); >+ } >+ try { > fNumberOfImportsAdded= 0; > fNumberOfImportsRemoved= 0; > >- monitor.beginTask(Messages.format(CodeGenerationMessages.OrganizeImportsOperation_description, fCompilationUnit.getElementName()), 10); >+ monitor.beginTask(Messages.format(CodeGenerationMessages.OrganizeImportsOperation_description, fCompilationUnit.getElementName()), 9); > > CompilationUnit astRoot= fASTRoot; > if (astRoot == null) { >@@ -399,10 +416,8 @@ > List/*<SimpleName>*/ typeReferences= new ArrayList(); > List/*<SimpleName>*/ staticReferences= new ArrayList(); > >- boolean res= collectReferences(astRoot, typeReferences, staticReferences, oldSingleImports, oldDemandImports); >- if (!res) { >- return; >- } >+ if (!collectReferences(astRoot, typeReferences, staticReferences, oldSingleImports, oldDemandImports)) >+ return null; > > monitor.worked(1); > >@@ -430,12 +445,12 @@ > importsRewrite.addImport(typeInfo.getFullyQualifiedName()); > } > } >+ >+ TextEdit result= importsRewrite.rewriteImports(new SubProgressMonitor(monitor, 3)); > >- TextEdit edit= importsRewrite.rewriteImports(new SubProgressMonitor(monitor, 3)); >- JavaModelUtil.applyEdit(fCompilationUnit, edit, fDoSave, new SubProgressMonitor(monitor, 1)); >- > determineImportDifferences(importsRewrite, oldSingleImports, oldDemandImports); >- processor= null; >+ >+ return result; > } finally { > monitor.done(); > } >Index: ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties,v >retrieving revision 1.51 >diff -u -r1.51 MultiFixMessages.properties >--- ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties 16 Oct 2006 12:45:39 -0000 1.51 >+++ ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties 17 Oct 2006 15:04:23 -0000 >@@ -66,3 +66,4 @@ > > CodeFormatFix_description=Format code > CodeFormatCleanUp_description=Format source code >+ImportsCleanUp_OrganizeImports_Description=Organize imports >Index: ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java,v >retrieving revision 1.34 >diff -u -r1.34 MultiFixMessages.java >--- ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java 16 Oct 2006 12:45:43 -0000 1.34 >+++ ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java 17 Oct 2006 15:04:23 -0000 >@@ -27,6 +27,7 @@ > public static String CleanUpRefactoringWizard_Profile_TableHeader; > public static String CleanUpRefactoringWizard_Project_TableHeader; > public static String CleanUpRefactoringWizard_unknownProfile_Name; >+ public static String ImportsCleanUp_OrganizeImports_Description; > public static String StringMultiFix_AddMissingNonNls_description; > public static String StringMultiFix_RemoveUnnecessaryNonNls_description; > >Index: ui/org/eclipse/jdt/internal/ui/fix/AbstractCleanUp.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/AbstractCleanUp.java,v >retrieving revision 1.21 >diff -u -r1.21 AbstractCleanUp.java >--- ui/org/eclipse/jdt/internal/ui/fix/AbstractCleanUp.java 16 Oct 2006 12:30:53 -0000 1.21 >+++ ui/org/eclipse/jdt/internal/ui/fix/AbstractCleanUp.java 17 Oct 2006 15:04:23 -0000 >@@ -29,6 +29,7 @@ > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.compiler.IProblem; >+import org.eclipse.jdt.core.dom.CompilationUnit; > > import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; > >@@ -182,4 +183,11 @@ > Map options= CleanUpConstants.loadOptions(context); > fFlags= createFlag(options); > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean needsFreshAST(CompilationUnit compilationUnit) { >+ return false; >+ } > } >Index: ui/org/eclipse/jdt/internal/ui/fix/ICleanUp.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ICleanUp.java,v >retrieving revision 1.13 >diff -u -r1.13 ICleanUp.java >--- ui/org/eclipse/jdt/internal/ui/fix/ICleanUp.java 15 Sep 2006 08:41:56 -0000 1.13 >+++ ui/org/eclipse/jdt/internal/ui/fix/ICleanUp.java 17 Oct 2006 15:04:23 -0000 >@@ -65,6 +65,15 @@ > * @return The options as map or null > */ > public abstract Map getRequiredOptions(); >+ >+ /** >+ * If true a fresh AST, containing all the changes from previous clean ups, >+ * will be created and passed to createFix. >+ * >+ * @param compilationUnit The current available AST >+ * @return true if the caller needs an up to date AST >+ */ >+ public abstract boolean needsFreshAST(CompilationUnit compilationUnit); > > /** > * Persist current settings of this in <code>settings</code> >Index: ui/org/eclipse/jdt/internal/ui/fix/CodeFormatCleanUp.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/CodeFormatCleanUp.java,v >retrieving revision 1.2 >diff -u -r1.2 CodeFormatCleanUp.java >--- ui/org/eclipse/jdt/internal/ui/fix/CodeFormatCleanUp.java 6 Sep 2006 16:20:44 -0000 1.2 >+++ ui/org/eclipse/jdt/internal/ui/fix/CodeFormatCleanUp.java 17 Oct 2006 15:04:23 -0000 >@@ -99,7 +99,7 @@ > > public String getPreview() { > StringBuffer buf= new StringBuffer(); >- buf.append("package model;\n"); //$NON-NLS-1$ >+ buf.append("package org.model;\n"); //$NON-NLS-1$ > buf.append("public class Engine {\n"); //$NON-NLS-1$ > buf.append(" public void start() {}\n"); //$NON-NLS-1$ > buf.append(" public \n"); //$NON-NLS-1$ >Index: core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java,v >retrieving revision 1.5 >diff -u -r1.5 CleanUpConstants.java >--- core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java 16 Oct 2006 12:30:53 -0000 1.5 >+++ core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java 17 Oct 2006 15:04:22 -0000 >@@ -15,7 +15,6 @@ > import java.util.Iterator; > import java.util.Map; > >-import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.preferences.IEclipsePreferences; > import org.eclipse.core.runtime.preferences.IScopeContext; > >@@ -726,6 +725,18 @@ > public static final String ADD_MISSING_NLS_TAGS= "cleanup.add_missing_nls_tags"; //$NON-NLS-1$ > > /** >+ * If true the imports are organized while cleaning up code. >+ * >+ * Possible values: {TRUE, FALSE}<br> >+ * Default value: Value returned by {@link #getEclipseDefaultSettings()}<br> >+ * <br> >+ * @see #TRUE >+ * @see #FALSE >+ * @since 3.3 >+ */ >+ public static final String ORGANIZE_IMPORTS= "cleanup.organize_imports"; //$NON-NLS-1$ >+ >+ /** > * Should the Clean Up Wizard be shown when executing the Clean Up Action? > * <br><br> > * Possible values: {<code><b>true</b></code>, <code><b>false</b></code>}<br> >@@ -807,13 +818,15 @@ > > result.put(ADD_MISSING_NLS_TAGS, FALSE); > >- //Code Formatting >+ //Code Organising > result.put(FORMAT_SOURCE_CODE, FALSE); > > result.put(FORMAT_COMMENT, FALSE); > result.put(FORMAT_SINGLE_LINE_COMMENT, TRUE); > result.put(FORMAT_MULTI_LINE_COMMENT, TRUE); > result.put(FORMAT_JAVADOC, TRUE); >+ >+ result.put(ORGANIZE_IMPORTS, FALSE); > > return result; > } >@@ -825,9 +838,7 @@ > Map defaultSettings= getEclipseDefaultSettings(); > for (Iterator iterator= defaultSettings.keySet().iterator(); iterator.hasNext();) { > String key= (String)iterator.next(); >- String value= node.get(key, null); >- >- Assert.isTrue(value != null, key); >+ String value= node.get(key, FALSE); > > result.put(key, value); > } >Index: core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.java,v >retrieving revision 1.23 >diff -u -r1.23 FixMessages.java >--- core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.java 11 Oct 2006 09:40:05 -0000 1.23 >+++ core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.java 17 Oct 2006 15:04:23 -0000 >@@ -27,6 +27,7 @@ > public static String ConvertIterableLoopOperation_RemoveUpdateExpression_Warning; > public static String ConvertIterableLoopOperation_RemoveUpdateExpressions_Warning; > public static String ConvertIterableLoopOperation_semanticChangeWarning; >+ public static String ImportsFix_OrganizeImports_Description; > > public static String PotentialProgrammingProblemsFix_calculatingUIDFailed_binding; > public static String PotentialProgrammingProblemsFix_calculatingUIDFailed_exception; >Index: core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties,v >retrieving revision 1.27 >diff -u -r1.27 FixMessages.properties >--- core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties 11 Oct 2006 09:40:05 -0000 1.27 >+++ core extension/org/eclipse/jdt/internal/corext/fix/FixMessages.properties 17 Oct 2006 15:04:23 -0000 >@@ -74,3 +74,4 @@ > ConvertIterableLoopOperation_semanticChangeWarning=Converting the loop may change the semantics of the code. > ConvertIterableLoopOperation_RemoveUpdateExpression_Warning=The expression ''{0}'' in the update part of the loop will be removed. > ConvertIterableLoopOperation_RemoveUpdateExpressions_Warning=The expressions in the update part of the loop will be removed. >+ImportsFix_OrganizeImports_Description=Organize Imports >Index: core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java,v >retrieving revision 1.31 >diff -u -r1.31 CleanUpRefactoring.java >--- core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java 9 Oct 2006 13:03:21 -0000 1.31 >+++ core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java 17 Oct 2006 15:04:23 -0000 >@@ -196,9 +196,13 @@ > } > > private ICleanUp[] calculateSolutions(ICompilationUnit source, CompilationUnit ast, ICleanUp[] cleanUps) { >+ if (cleanUps.length == 0) >+ return null; >+ > CompilationUnitChange solution= null; > List/*<ICleanUp>*/ result= null; >- for (int i= 0; i < cleanUps.length; i++) { >+ int i= 0; >+ do { > ICleanUp cleanUp= cleanUps[i]; > try { > IFix fix= cleanUp.createFix(ast); >@@ -231,7 +235,8 @@ > } catch (CoreException e) { > throw new FixCalculationException(e); > } >- } >+ i++; >+ } while (i < cleanUps.length && (solution == null || !cleanUps[i].needsFreshAST(ast))); > > if (solution != null) { > if (fLeaveFilesDirty) >@@ -239,6 +244,13 @@ > integrateSolution(solution, source); > } > >+ for (; i < cleanUps.length; i++) { >+ if (result == null) { >+ result= new ArrayList(); >+ } >+ result.add(cleanUps[i]); >+ } >+ > if (result == null) { > return null; > } else { >@@ -773,9 +785,15 @@ > MultiTextEdit multiTextEdit1= (MultiTextEdit)edit1; > TextEdit[] children1= multiTextEdit1.getChildren(); > >+ if (children1.length == 0) >+ return edit2; >+ > MultiTextEdit multiTextEdit2= (MultiTextEdit)edit2; > TextEdit[] children2= multiTextEdit2.getChildren(); > >+ if (children2.length == 0) >+ return edit1; >+ > int i1= 0; > int i2= 0; > while (i1 < children1.length && i2 < children2.length) { >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties,v >retrieving revision 1.5 >diff -u -r1.5 CleanUpMessages.properties >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties 13 Oct 2006 13:40:55 -0000 1.5 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties 17 Oct 2006 15:04:23 -0000 >@@ -2,17 +2,21 @@ > CleanUpModifyDialog_TabPageName_MemberAccesses=Membe&r Accesses > CleanUpModifyDialog_TabPageName_UnnecessaryCode=&Unnecessary Code > CleanUpModifyDialog_TabPageName_MissingCode=&Missing Code >-CleanUpModifyDialog_TabPageName_CodeFormating=Code &Formatting >+CleanUpModifyDialog_TabPageName_CodeFormating=Code &Organizing > > CleanUpProfileManager_ProfileName_EclipseBuildIn=Eclipse [built-in] > CleanUpConfigurationBlock_SelectedCleanUps_label=Details: > CleanUpConfigurationBlock_ShowCleanUpWizard_checkBoxLabel=Show the Clean Up Wizard > > CodeFormatingTabPage_GroupName_Formatter=Formatter >+CodeFormatingTabPage_Imports_GroupName=Imports > CodeFormatingTabPage_CheckboxName_FormatSourceCode=F&ormat source code >+CodeFormatingTabPage_FormatterSettings_Description=The settings for the Formatter can be changed on the Formatter preference page. >+CodeFormatingTabPage_OrganizeImports_CheckBoxLable=Organize imports > CodeFormatingTabPage_CheckboxName_FormatComments=Form&at comments > CodeFormatingTabPage_CheckboxName_FormatJavadocComments=Java&doc > CodeFormatingTabPage_CheckboxName_FormatMultiLineComments=Mul&ti line comments >+CodeFormatingTabPage_OrganizeImportsSettings_Description=The settings for organizing imports can be changed on the Organize Imports preference page. > CodeFormatingTabPage_CheckboxName_FormatSingleLineComments=&Single line comments > > CodeStyleTabPage_CheckboxName_UseBlocks=Use bloc&ks in if/while/for/do statements >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java,v >retrieving revision 1.1 >diff -u -r1.1 CodeFormatingTabPage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java 6 Sep 2006 16:20:44 -0000 1.1 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java 17 Oct 2006 15:04:23 -0000 >@@ -25,9 +25,11 @@ > import org.eclipse.jdt.internal.ui.fix.CodeFormatCleanUp; > import org.eclipse.jdt.internal.ui.fix.CommentFormatCleanUp; > import org.eclipse.jdt.internal.ui.fix.ICleanUp; >+import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp; > import org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview; >-import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage; > import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog; >+import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage; >+import org.eclipse.jdt.internal.ui.util.PixelConverter; > > public final class CodeFormatingTabPage extends ModifyDialogTabPage { > >@@ -42,6 +44,7 @@ > > protected JavaPreview doCreateJavaPreview(Composite parent) { > fCleanUpPreview= new CleanUpPreview(parent, new ICleanUp[] { >+ new ImportsCleanUp(fValues), > new CodeFormatCleanUp(fValues), > new CommentFormatCleanUp(fValues) > }, false); >@@ -77,20 +80,24 @@ > multiLinePref.setEnabled(formatCommentsPref.getChecked()); > singleLinePref.setEnabled(formatCommentsPref.getChecked()); > >-// Link link= new Link(group, SWT.WRAP | SWT.RIGHT); >-// link.setText("The settings for the Formatter can be changed on the <a>Formatter preference page</a>."); >-// link.addSelectionListener(new SelectionAdapter() { >-// public void widgetSelected(SelectionEvent e) { >-// CleanUpModifyDialog.this.okPressed(); >-// PreferencesUtil.createPreferenceDialogOn(getShell(), CodeFormatterPreferencePage.PREF_ID, null, null).open(); >-// } >-// }); >-// link.setToolTipText("Shows the Formatter preference page"); >-// GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 0); >-// gridData.widthHint= convertHorizontalDLUsToPixels(150); >-// link.setLayoutData(gridData); >-// link.setFont(composite.getFont()); >- } >+ PixelConverter pixelConverter= new PixelConverter(composite); >+ >+ createLabel(CleanUpMessages.CodeFormatingTabPage_FormatterSettings_Description, group, numColumns, pixelConverter).setFont(composite.getFont()); >+ >+ Group importsGroup= createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_Imports_GroupName); >+ createCheckboxPref(importsGroup, numColumns, CleanUpMessages.CodeFormatingTabPage_OrganizeImports_CheckBoxLable, CleanUpConstants.ORGANIZE_IMPORTS, CleanUpModifyDialog.FALSE_TRUE); >+ >+ createLabel(CleanUpMessages.CodeFormatingTabPage_OrganizeImportsSettings_Description, importsGroup, numColumns, pixelConverter).setFont(composite.getFont()); >+ } >+ >+ private Label createLabel(String text, Group group, int numColumns, PixelConverter pixelConverter) { >+ Label label= new Label(group, SWT.WRAP); >+ label.setText(text); >+ GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 0); >+ gridData.widthHint= pixelConverter.convertHorizontalDLUsToPixels(150); >+ label.setLayoutData(gridData); >+ return label; >+ } > > private void intent(Group group) { > Label l= new Label(group, SWT.NONE); >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java,v >retrieving revision 1.2 >diff -u -r1.2 CleanUpProfileVersioner.java >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java 20 Sep 2006 09:48:46 -0000 1.2 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpProfileVersioner.java 17 Oct 2006 15:04:23 -0000 >@@ -11,6 +11,10 @@ > > package org.eclipse.jdt.internal.ui.preferences.cleanup; > >+import java.util.Map; >+ >+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; >+ > import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner; > import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile; > >@@ -20,8 +24,9 @@ > private static final String CLEAN_UP_PROFILE_KIND= "CleanUpProfile"; //$NON-NLS-1$ > > private static final int VERSION_1= 1; // 3.3M2 >+ private static final int VERSION_2= 2; // 3.3M3 Added ORGANIZE_IMPORTS > >- private static final int CURRENT_VERSION= VERSION_1; >+ private static final int CURRENT_VERSION= VERSION_2; > > /* (non-Javadoc) > * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#getFirstVersion() >@@ -41,6 +46,9 @@ > * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#updateAndComplete(org.eclipse.jdt.internal.ui.preferences.cleanup.ProfileManager.CustomProfile) > */ > public void update(CustomProfile profile) { >+ if (profile.getVersion() == VERSION_1) >+ updateFrom1To2(profile); >+ > profile.setVersion(CURRENT_VERSION); > } > >@@ -50,5 +58,10 @@ > public String getProfileKind() { > return CLEAN_UP_PROFILE_KIND; > } >+ >+ private static void updateFrom1To2(CustomProfile profile) { >+ Map defaultSettings= CleanUpConstants.getEclipseDefaultSettings(); >+ profile.getSettings().put(CleanUpConstants.ORGANIZE_IMPORTS, defaultSettings.get(CleanUpConstants.ORGANIZE_IMPORTS)); >+ } > > } >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java,v >retrieving revision 1.3 >diff -u -r1.3 CleanUpMessages.java >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java 13 Oct 2006 13:40:55 -0000 1.3 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java 17 Oct 2006 15:04:23 -0000 >@@ -32,7 +32,11 @@ > public static String CodeFormatingTabPage_CheckboxName_FormatMultiLineComments; > public static String CodeFormatingTabPage_CheckboxName_FormatSingleLineComments; > public static String CodeFormatingTabPage_CheckboxName_FormatSourceCode; >+ public static String CodeFormatingTabPage_FormatterSettings_Description; > public static String CodeFormatingTabPage_GroupName_Formatter; >+ public static String CodeFormatingTabPage_Imports_GroupName; >+ public static String CodeFormatingTabPage_OrganizeImports_CheckBoxLable; >+ public static String CodeFormatingTabPage_OrganizeImportsSettings_Description; > > public static String CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced; > public static String CodeStyleTabPage_CheckboxName_UseBlocks; >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java,v >retrieving revision 1.6 >diff -u -r1.6 CleanUpConfigurationBlock.java >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java 16 Oct 2006 12:30:53 -0000 1.6 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpConfigurationBlock.java 17 Oct 2006 15:04:23 -0000 >@@ -40,6 +40,7 @@ > import org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp; > import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp; > import org.eclipse.jdt.internal.ui.fix.ICleanUp; >+import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp; > import org.eclipse.jdt.internal.ui.fix.Java50CleanUp; > import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp; > import org.eclipse.jdt.internal.ui.fix.StringCleanUp; >@@ -109,6 +110,7 @@ > new StringCleanUp(sharedSettings), > new Java50CleanUp(sharedSettings), > new PotentialProgrammingProblemsCleanUp(sharedSettings), >+ new ImportsCleanUp(sharedSettings), > new CodeFormatCleanUp(sharedSettings), > new CommentFormatCleanUp(sharedSettings) > }; >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java,v >retrieving revision 1.30 >diff -u -r1.30 RefactoringExecutionStarter.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java 13 Oct 2006 13:40:55 -0000 1.30 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java 17 Oct 2006 15:04:23 -0000 >@@ -106,6 +106,7 @@ > import org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp; > import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp; > import org.eclipse.jdt.internal.ui.fix.Java50CleanUp; >+import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp; > import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp; > import org.eclipse.jdt.internal.ui.fix.StringCleanUp; > import org.eclipse.jdt.internal.ui.fix.UnnecessaryCodeCleanUp; >@@ -251,6 +252,7 @@ > refactoring.addCleanUp(new PotentialProgrammingProblemsCleanUp()); > refactoring.addCleanUp(new UnnecessaryCodeCleanUp()); > refactoring.addCleanUp(new StringCleanUp()); >+ refactoring.addCleanUp(new ImportsCleanUp()); > refactoring.addCleanUp(new CodeFormatCleanUp()); > refactoring.addCleanUp(new CommentFormatCleanUp()); > >Index: core extension/org/eclipse/jdt/internal/corext/fix/ImportsFix.java >=================================================================== >RCS file: core extension/org/eclipse/jdt/internal/corext/fix/ImportsFix.java >diff -N core extension/org/eclipse/jdt/internal/corext/fix/ImportsFix.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ core extension/org/eclipse/jdt/internal/corext/fix/ImportsFix.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.corext.fix; >+ >+import org.eclipse.text.edits.TextEdit; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+ >+import org.eclipse.ltk.core.refactoring.CategorizedTextEditGroup; >+import org.eclipse.ltk.core.refactoring.GroupCategory; >+import org.eclipse.ltk.core.refactoring.GroupCategorySet; >+import org.eclipse.ltk.core.refactoring.TextChange; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+ >+import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; >+import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation; >+import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange; >+ >+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; >+ >+public class ImportsFix extends AbstractFix { >+ >+ public static IFix createCleanUp(final CompilationUnit cu, CodeGenerationSettings settings, boolean organizeImports) throws CoreException { >+ if (!organizeImports) >+ return null; >+ >+ OrganizeImportsOperation op= new OrganizeImportsOperation((ICompilationUnit)cu.getJavaElement(), cu, settings.importIgnoreLowercase, false, true, null); >+ final TextEdit edit= op.createTextEdit(null); >+ if (edit == null) >+ return null; >+ >+ if (op.getNumberOfImportsAdded() == 0 && op.getNumberOfImportsRemoved() == 0) >+ return null; >+ >+ return new IFix() { >+ >+ public TextChange createChange() throws CoreException { >+ CompilationUnitChange result= new CompilationUnitChange("", getCompilationUnit()); //$NON-NLS-1$ >+ result.setEdit(edit); >+ String label= getDescription(); >+ result.addTextEditGroup(new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)))); >+ return result; >+ } >+ >+ public ICompilationUnit getCompilationUnit() { >+ return (ICompilationUnit)cu.getJavaElement(); >+ } >+ >+ public String getDescription() { >+ return FixMessages.ImportsFix_OrganizeImports_Description; >+ } >+ >+ public IStatus getStatus() { >+ return StatusInfo.OK_STATUS; >+ } >+ }; >+ } >+ >+ protected ImportsFix(String name, CompilationUnit compilationUnit, IFixRewriteOperation[] fixRewriteOperations) { >+ super(name, compilationUnit, fixRewriteOperations); >+ } >+} >Index: ui/org/eclipse/jdt/internal/ui/fix/ImportsCleanUp.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/fix/ImportsCleanUp.java >diff -N ui/org/eclipse/jdt/internal/ui/fix/ImportsCleanUp.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/fix/ImportsCleanUp.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,155 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.fix; >+ >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+ >+import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; >+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; >+import org.eclipse.jdt.internal.corext.fix.IFix; >+import org.eclipse.jdt.internal.corext.fix.ImportsFix; >+ >+import org.eclipse.jdt.ui.text.java.IProblemLocation; >+ >+import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; >+ >+public class ImportsCleanUp extends AbstractCleanUp { >+ >+ private static int ORGANIZE_IMPORTS= 1; >+ private CodeGenerationSettings fCodeGeneratorSettings; >+ >+ public ImportsCleanUp(Map options) { >+ super(options); >+ } >+ >+ public ImportsCleanUp() { >+ super(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected int createFlag(Map options) { >+ int result= 0; >+ >+ if (CleanUpConstants.TRUE.equals(options.get(CleanUpConstants.ORGANIZE_IMPORTS))) { >+ result |= ORGANIZE_IMPORTS; >+ } >+ >+ return result; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean canFix(CompilationUnit compilationUnit, IProblemLocation problem) throws CoreException { >+ return false; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IFix createFix(final CompilationUnit compilationUnit) throws CoreException { >+ return ImportsFix.createCleanUp(compilationUnit, fCodeGeneratorSettings, >+ isFlag(ORGANIZE_IMPORTS)); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public RefactoringStatus checkPreConditions(IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException { >+ if (isFlag(ORGANIZE_IMPORTS)) >+ fCodeGeneratorSettings= JavaPreferencesSettings.getCodeGenerationSettings(project); >+ >+ return super.checkPreConditions(project, compilationUnits, monitor); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public RefactoringStatus checkPostConditions(IProgressMonitor monitor) throws CoreException { >+ fCodeGeneratorSettings= null; >+ >+ return super.checkPostConditions(monitor); >+ } >+ /** >+ * {@inheritDoc} >+ */ >+ public int getDefaultFlag() { >+ return 0; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String[] getDescriptions() { >+ if (isFlag(ORGANIZE_IMPORTS)) >+ return new String[] {MultiFixMessages.ImportsCleanUp_OrganizeImports_Description}; >+ >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getPreview() { >+ StringBuffer buf= new StringBuffer(); >+ >+ if (isFlag(ORGANIZE_IMPORTS)) { >+ buf.append("import org.model.Engine;\n"); //$NON-NLS-1$ >+ } else { >+ buf.append("import org.model.*;\n"); //$NON-NLS-1$ >+ } >+ >+ return buf.toString(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Map getRequiredOptions() { >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int maximalNumberOfFixes(CompilationUnit compilationUnit) { >+ return -1; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean needsFreshAST(CompilationUnit compilationUnit) { >+ if (isFlag(ORGANIZE_IMPORTS)) >+ return true; >+ >+ return super.needsFreshAST(compilationUnit); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 154109
: 52143