Cleanup of CompileStrategy which no longer cares about RunStyle at all.

Review by: jlabanca (desk)

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6944 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/CompileStrategy.java b/user/src/com/google/gwt/junit/CompileStrategy.java
index fb2d404..d955e6f 100644
--- a/user/src/com/google/gwt/junit/CompileStrategy.java
+++ b/user/src/com/google/gwt/junit/CompileStrategy.java
@@ -78,6 +78,7 @@
    * 
    * @throws UnableToCompleteException if the compilation fails
    */
+  @SuppressWarnings("unused")
   public void maybeCompileAhead() throws UnableToCompleteException {
   }
 
@@ -87,14 +88,13 @@
    * @param moduleName the module name
    * @param syntheticModuleName the synthetic module name
    * @param strategy the strategy
-   * @param runStyle the run style
    * @param batchingStrategy the batching strategy
    * @param treeLogger the logger
    * @return the {@link ModuleDef} describing the synthetic module
    * @throws UnableToCompleteException
    */
   public abstract ModuleDef maybeCompileModule(String moduleName,
-      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
+      String syntheticModuleName, Strategy strategy,
       BatchingStrategy batchingStrategy, TreeLogger treeLogger)
       throws UnableToCompleteException;
 
@@ -104,19 +104,17 @@
    * @param moduleName the module name
    * @param syntheticModuleName the synthetic module name
    * @param strategy the strategy
-   * @param runStyle the run style
    * @param batchingStrategy the batching strategy
    * @param treeLogger the logger
    * @return the {@link ModuleDef} describing the synthetic module
    */
   protected ModuleDef maybeCompileModuleImpl(String moduleName,
-      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
+      String syntheticModuleName, Strategy strategy,
       BatchingStrategy batchingStrategy, TreeLogger treeLogger)
       throws UnableToCompleteException {
 
-    // Let the runstyle compile the module.
     ModuleDef moduleDef = maybeCompileModuleImpl2(moduleName,
-        syntheticModuleName, strategy, runStyle, treeLogger);
+        syntheticModuleName, strategy, treeLogger);
 
     // Add all test blocks for the module if we haven't seen this module before.
     if (!compiledModuleNames.contains(syntheticModuleName)) {
@@ -151,20 +149,19 @@
   }
 
   /**
-   * Let the {@link RunStyle} compile the module if needed
+   * Compile the module if needed.
    * 
    * Visible for testing and mocking.
    * 
    * @param moduleName the module name
    * @param syntheticModuleName the synthetic module name
    * @param strategy the strategy
-   * @param runStyle the run style
    * @param treeLogger the logger
    * @return the {@link ModuleDef} describing the synthetic module
    */
   ModuleDef maybeCompileModuleImpl2(String moduleName,
-      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
-      TreeLogger treeLogger) throws UnableToCompleteException {
+      String syntheticModuleName, Strategy strategy, TreeLogger treeLogger)
+      throws UnableToCompleteException {
     /*
      * Synthesize a synthetic module that derives from the user-specified module
      * but also includes JUnit support.
@@ -208,12 +205,6 @@
   private List<String> modulesToCompile = new ArrayList<String>();
 
   /**
-   * The {@link RunStyle} used to compile, which is set on the first compilation
-   * and is the same across all compilations.
-   */
-  private RunStyle runStyle;
-
-  /**
    * The {@link TreeLogger} used to compile, which is set on the first
    * compilation and is the same across all compilations.
    */
@@ -230,19 +221,18 @@
       TestModuleInfo moduleInfo = GWTTestCase.getTestsForModule(nextModule);
       String syntheticModuleName = moduleInfo.getSyntheticModuleName();
       maybeCompileModuleImpl(moduleInfo.getModuleName(), syntheticModuleName,
-          moduleInfo.getStrategy(), runStyle, batchingStrategy, treeLogger);
+          moduleInfo.getStrategy(), batchingStrategy, treeLogger);
     }
   }
 
   @Override
   public ModuleDef maybeCompileModule(String moduleName,
-      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
+      String syntheticModuleName, Strategy strategy,
       BatchingStrategy batchingStrategy, TreeLogger treeLogger)
       throws UnableToCompleteException {
 
     // Initialize the map of modules.
     if (preCompiledModuleDefs == null) {
-      this.runStyle = runStyle;
       this.batchingStrategy = batchingStrategy;
       this.treeLogger = treeLogger;
       preCompiledModuleDefs = new HashMap<String, ModuleDef>();
@@ -256,19 +246,19 @@
     ModuleDef moduleDef = preCompiledModuleDefs.get(syntheticModuleName);
     if (moduleDef == null) {
       moduleDef = maybeCompileModuleImpl(moduleName, syntheticModuleName,
-          strategy, runStyle, batchingStrategy, treeLogger);
+          strategy, batchingStrategy, treeLogger);
     }
     return moduleDef;
   }
 
   @Override
   protected ModuleDef maybeCompileModuleImpl(String moduleName,
-      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
+      String syntheticModuleName, Strategy strategy,
       BatchingStrategy batchingStrategy, TreeLogger treeLogger)
       throws UnableToCompleteException {
     modulesToCompile.remove(syntheticModuleName);
     ModuleDef moduleDef = super.maybeCompileModuleImpl(moduleName,
-        syntheticModuleName, strategy, runStyle, batchingStrategy, treeLogger);
+        syntheticModuleName, strategy, batchingStrategy, treeLogger);
     preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
     return moduleDef;
   }
@@ -291,10 +281,10 @@
 
   @Override
   public ModuleDef maybeCompileModule(String moduleName,
-      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
+      String syntheticModuleName, Strategy strategy,
       BatchingStrategy batchingStrategy, TreeLogger treeLogger)
       throws UnableToCompleteException {
-    maybePrecompileModules(runStyle, batchingStrategy, treeLogger);
+    maybePrecompileModules(batchingStrategy, treeLogger);
 
     // Since all test blocks from a module are added to the queue at the
     // same time, we can safely take the module out of the hash map at
@@ -305,9 +295,8 @@
   /**
    * Precompile all modules if needed.
    */
-  private void maybePrecompileModules(RunStyle runStyle,
-      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
-      throws UnableToCompleteException {
+  private void maybePrecompileModules(BatchingStrategy batchingStrategy,
+      TreeLogger treeLogger) throws UnableToCompleteException {
     if (preCompiledModuleDefs == null) {
       preCompiledModuleDefs = new HashMap<String, ModuleDef>();
       for (String moduleName : GWTTestCase.getAllTestModuleNames()) {
@@ -315,7 +304,7 @@
         String syntheticModuleName = moduleInfo.getSyntheticModuleName();
         ModuleDef moduleDef = maybeCompileModuleImpl(
             moduleInfo.getModuleName(), syntheticModuleName,
-            moduleInfo.getStrategy(), runStyle, batchingStrategy, treeLogger);
+            moduleInfo.getStrategy(), batchingStrategy, treeLogger);
         preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
       }
     }
@@ -333,10 +322,10 @@
 
   @Override
   public ModuleDef maybeCompileModule(String moduleName,
-      String syntheticModuleName, Strategy strategy, RunStyle runStyle,
+      String syntheticModuleName, Strategy strategy,
       BatchingStrategy batchingStrategy, TreeLogger treeLogger)
       throws UnableToCompleteException {
     return maybeCompileModuleImpl(moduleName, syntheticModuleName, strategy,
-        runStyle, batchingStrategy, treeLogger);
+        batchingStrategy, treeLogger);
   }
 }
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index 5ead356..72e5c32 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -1108,8 +1108,7 @@
     // Get the module definition for the current test.
     if (!sameTest) {
       currentModule = compileStrategy.maybeCompileModule(moduleName,
-          syntheticModuleName, strategy, runStyle, batchingStrategy,
-          getTopLogger());
+          syntheticModuleName, strategy, batchingStrategy, getTopLogger());
       currentCompilationState = currentModule.getCompilationState(getTopLogger());
     }
     assert (currentModule != null);
diff --git a/user/test/com/google/gwt/junit/CompileStrategyTest.java b/user/test/com/google/gwt/junit/CompileStrategyTest.java
index ad644e0..308c104 100644
--- a/user/test/com/google/gwt/junit/CompileStrategyTest.java
+++ b/user/test/com/google/gwt/junit/CompileStrategyTest.java
@@ -57,7 +57,7 @@
 
     @Override
     public ModuleDef maybeCompileModule(String moduleName,
-        String syntheticModuleName, Strategy strategy, RunStyle runStyle,
+        String syntheticModuleName, Strategy strategy,
         BatchingStrategy batchingStrategy, TreeLogger treeLogger) {
       fail("This method should not be called.");
       return null;
@@ -75,8 +75,7 @@
 
     @Override
     ModuleDef maybeCompileModuleImpl2(String moduleName,
-        String syntheticModuleName, Strategy strategy, RunStyle runStyle,
-        TreeLogger treeLogger) {
+        String syntheticModuleName, Strategy strategy, TreeLogger treeLogger) {
       return null;
     }
   }
@@ -111,13 +110,13 @@
   private static class MockJUnitMessageQueue extends JUnitMessageQueue {
 
     /**
-   * Indicates that this is the last test block.
-   */
+     * Indicates that this is the last test block.
+     */
     private boolean isLastBlock;
 
     /**
-                         * The test blocks added to the queue.
-                         */
+     * The test blocks added to the queue.
+     */
     private List<TestInfo[]> testBlocks;
 
     public MockJUnitMessageQueue() {
@@ -153,20 +152,6 @@
     }
   }
 
-  /**
- * A mock {@link RunStyle} used for testing.
- */
-  private static class MockRunStyle extends RunStyle {
-
-    public MockRunStyle() {
-      super(null);
-    }
-
-    @Override
-    public void launchModule(String moduleName) {
-    }
-  }
-
   public void testMaybeAddTestBlockForCurrentTestWithBatching() {
     BatchingStrategy batchingStrategy = new ModuleBatchingStrategy();
     assertFalse(batchingStrategy.isSingleTestOnly());
@@ -205,12 +190,11 @@
     assertFalse(batchingStrategy.isSingleTestOnly());
 
     // Maybe add the current test.
-    RunStyle runStyle = new MockRunStyle();
     GWTTestCase testCase = new MockGWTTestCase();
     MockCompileStrategy strategy = new MockCompileStrategy(-1);
     try {
       strategy.maybeCompileModuleImpl(testCase.getModuleName(),
-          testCase.getSyntheticModuleName(), testCase.getStrategy(), runStyle,
+          testCase.getSyntheticModuleName(), testCase.getStrategy(),
           batchingStrategy, TreeLogger.NULL);
     } catch (UnableToCompleteException e) {
       fail("Unexpected UnableToCompleteException: " + e.getMessage());
@@ -227,12 +211,11 @@
     assertFalse(batchingStrategy.isSingleTestOnly());
 
     // Maybe add the current test.
-    RunStyle runStyle = new MockRunStyle();
     GWTTestCase testCase = new MockGWTTestCase();
     MockCompileStrategy strategy = new MockCompileStrategy(1000);
     try {
       strategy.maybeCompileModuleImpl(testCase.getModuleName(),
-          testCase.getSyntheticModuleName(), testCase.getStrategy(), runStyle,
+          testCase.getSyntheticModuleName(), testCase.getStrategy(),
           batchingStrategy, TreeLogger.NULL);
     } catch (UnableToCompleteException e) {
       fail("Unexpected UnableToCompleteException: " + e.getMessage());
@@ -249,12 +232,11 @@
     assertTrue(batchingStrategy.isSingleTestOnly());
 
     // Maybe add the current test.
-    RunStyle runStyle = new MockRunStyle();
     GWTTestCase testCase = new MockGWTTestCase();
     MockCompileStrategy strategy = new MockCompileStrategy(-1);
     try {
       strategy.maybeCompileModuleImpl(testCase.getModuleName(),
-          testCase.getSyntheticModuleName(), testCase.getStrategy(), runStyle,
+          testCase.getSyntheticModuleName(), testCase.getStrategy(),
           batchingStrategy, TreeLogger.NULL);
     } catch (UnableToCompleteException e) {
       fail("Unexpected UnableToCompleteException: " + e.getMessage());