Author: [EMAIL PROTECTED]
Date: Thu Sep 11 11:08:46 2008
New Revision: 3647

Modified:
    trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
    trunk/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
    trunk/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java

Log:
Merge disparate code for creating JDT compiler options; simple refactor.

Modified: trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java        
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java        Thu Sep 
11  
11:08:46 2008
@@ -92,7 +92,7 @@
      public CompilerImpl() {
        super(new INameEnvironmentImpl(),
            DefaultErrorHandlingPolicies.proceedWithAllProblems(),
-          getCompilerOptions(), new ICompilerRequestorImpl(),
+          getCompilerOptions(true), new ICompilerRequestorImpl(),
            new DefaultProblemFactory(Locale.getDefault()));
      }

@@ -193,7 +193,8 @@
      return new JdtCompiler().doCompile(units);
    }

-  private static CompilerOptions getCompilerOptions() {
+  public static CompilerOptions getCompilerOptions(
+      boolean enableDocCommentSupport) {
      Map<String, String> settings = new HashMap<String, String>();
      settings.put(CompilerOptions.OPTION_LineNumberAttribute,
          CompilerOptions.GENERATE);
@@ -216,8 +217,10 @@
          CompilerOptions.VERSION_1_5);

      // This is needed by TypeOracleBuilder to parse metadata.
-    settings.put(CompilerOptions.OPTION_DocCommentSupport,
-        CompilerOptions.ENABLED);
+    if (enableDocCommentSupport) {
+      settings.put(CompilerOptions.OPTION_DocCommentSupport,
+          CompilerOptions.ENABLED);
+    }
      return new CompilerOptions(settings);
    }


Modified: trunk/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java      
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java     Thu Sep 
 
11 11:08:46 2008
@@ -20,6 +20,7 @@
  import com.google.gwt.dev.javac.CompilationState;
  import com.google.gwt.dev.javac.CompilationUnit;
  import com.google.gwt.dev.javac.GWTProblem;
+import com.google.gwt.dev.javac.JdtCompiler;
  import com.google.gwt.dev.javac.JdtCompiler.CompilationUnitAdapter;
  import com.google.gwt.dev.javac.impl.Shared;
  import com.google.gwt.dev.util.CharArrayComparator;
@@ -446,33 +447,12 @@
      IErrorHandlingPolicy pol =  
DefaultErrorHandlingPolicies.proceedWithAllProblems();
      IProblemFactory probFact = new  
DefaultProblemFactory(Locale.getDefault());
      ICompilerRequestor req = new ICompilerRequestorImpl();
-    Map<String, String> settings = new HashMap<String, String>();
-    settings.put(CompilerOptions.OPTION_LineNumberAttribute,
-        CompilerOptions.GENERATE);
-    settings.put(CompilerOptions.OPTION_SourceFileAttribute,
-        CompilerOptions.GENERATE);
-    /*
-     * Tricks like "boolean stopHere = true;" depend on this setting to  
work in
-     * hosted mode. In web mode, our compiler should optimize them out  
once we
-     * do real data flow.
-     */
-    settings.put(CompilerOptions.OPTION_PreserveUnusedLocal,
-        CompilerOptions.PRESERVE);
-    settings.put(CompilerOptions.OPTION_ReportDeprecation,
-        CompilerOptions.IGNORE);
-    settings.put(CompilerOptions.OPTION_LocalVariableAttribute,
-        CompilerOptions.GENERATE);
-    settings.put(CompilerOptions.OPTION_Compliance,  
CompilerOptions.VERSION_1_5);
-    settings.put(CompilerOptions.OPTION_Source,  
CompilerOptions.VERSION_1_5);
-    settings.put(CompilerOptions.OPTION_TargetPlatform,
-        CompilerOptions.VERSION_1_5);
-
-    // This is needed by TypeOracleBuilder to parse metadata.
-    settings.put(CompilerOptions.OPTION_DocCommentSupport,
-        CompilerOptions.ENABLED);
+    CompilerOptions options = JdtCompiler.getCompilerOptions(true);

-    compiler = new CompilerImpl(env, pol, new CompilerOptions(settings),  
req,
-        probFact);
+    // This is only needed by TypeOracleBuilder to parse metadata.
+    options.docCommentSupport = false;
+
+    compiler = new CompilerImpl(env, pol, options, req, probFact);
    }

    protected final CompilationUnitDeclaration[] compile(TreeLogger logger,

Modified:  
trunk/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java
==============================================================================
--- trunk/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java      
 
(original)
+++ trunk/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java      
 
Thu Sep 11 11:08:46 2008
@@ -15,6 +15,8 @@
   */
  package com.google.gwt.dev.javac.impl;

+import com.google.gwt.dev.javac.JdtCompiler;
+
  import junit.framework.TestCase;

  import org.eclipse.jdt.core.compiler.CategorizedProblem;
@@ -29,7 +31,6 @@
  import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
  import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
  import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
  import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;

  import java.util.ArrayList;
@@ -57,8 +58,8 @@
      public CompilerImpl(INameEnvironment environment,
          ICompilerRequestor requestor) {
        super(environment,  
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
-          getCompilerOptions(), requestor, new DefaultProblemFactory(
-              Locale.getDefault()));
+          JdtCompiler.getCompilerOptions(false), requestor,
+          new DefaultProblemFactory(Locale.getDefault()));
      }
    }

@@ -168,34 +169,6 @@
      public String toString() {
        return sourceFile.toString();
      }
-  }
-
-  private static CompilerOptions getCompilerOptions() {
-    Map<String, String> settings = new HashMap<String, String>();
-    settings.put(CompilerOptions.OPTION_LineNumberAttribute,
-        CompilerOptions.GENERATE);
-    settings.put(CompilerOptions.OPTION_SourceFileAttribute,
-        CompilerOptions.GENERATE);
-    /*
-     * Tricks like "boolean stopHere = true;" depend on this setting to  
work in
-     * hosted mode. In web mode, our compiler should optimize them out  
once we
-     * do real data flow.
-     */
-    settings.put(CompilerOptions.OPTION_PreserveUnusedLocal,
-        CompilerOptions.PRESERVE);
-    settings.put(CompilerOptions.OPTION_ReportDeprecation,
-        CompilerOptions.IGNORE);
-    settings.put(CompilerOptions.OPTION_LocalVariableAttribute,
-        CompilerOptions.GENERATE);
-    settings.put(CompilerOptions.OPTION_Compliance,  
CompilerOptions.VERSION_1_5);
-    settings.put(CompilerOptions.OPTION_Source,  
CompilerOptions.VERSION_1_5);
-    settings.put(CompilerOptions.OPTION_TargetPlatform,
-        CompilerOptions.VERSION_1_5);
-
-    // This is needed by TypeOracleBuilder to parse metadata.
-    settings.put(CompilerOptions.OPTION_DocCommentSupport,
-        CompilerOptions.ENABLED);
-    return new CompilerOptions(settings);
    }

    protected Map<String, ClassFile> classFiles = new HashMap<String,  
ClassFile>();

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to