Merge disparate code for creating JDT compiler options; simple refactor. git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@3647 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java index 79bd184..fca9dfe 100644 --- a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java +++ b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
@@ -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); }
diff --git a/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java b/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java index 885ef4b..fcdf196 100644 --- a/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java +++ b/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
@@ -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); + CompilerOptions options = JdtCompiler.getCompilerOptions(true); - // This is needed by TypeOracleBuilder to parse metadata. - settings.put(CompilerOptions.OPTION_DocCommentSupport, - CompilerOptions.ENABLED); + // This is only needed by TypeOracleBuilder to parse metadata. + options.docCommentSupport = false; - compiler = new CompilerImpl(env, pol, new CompilerOptions(settings), req, - probFact); + compiler = new CompilerImpl(env, pol, options, req, probFact); } protected final CompilationUnitDeclaration[] compile(TreeLogger logger,
diff --git a/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java b/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java index fb4115a..af83fca 100644 --- a/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java +++ b/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java
@@ -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())); } } @@ -170,34 +171,6 @@ } } - 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>(); /**