IDEA: created a infrastructure for saving any compiler settings.

Added "generate no warnings" to Settings.
This commit is contained in:
Zalim Bashorov
2013-10-10 14:48:55 +04:00
parent 0901c98ff8
commit 809e25f48a
13 changed files with 365 additions and 11 deletions
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.cli.common.arguments;
public interface CommonArgumentConstants {
String SUPPRESS_WARNINGS = "warnings";
}
@@ -18,7 +18,11 @@ package org.jetbrains.jet.cli.common.arguments;
import com.sampullara.cli.Argument;
import static org.jetbrains.jet.cli.common.arguments.CommonArgumentConstants.SUPPRESS_WARNINGS;
public abstract class CommonCompilerArguments extends CompilerArguments {
public static final CommonCompilerArguments DUMMY = new DummyImpl();
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
public boolean tags;
@Argument(value = "verbose", description = "Enable verbose logging output")
@@ -60,6 +64,14 @@ public abstract class CommonCompilerArguments extends CompilerArguments {
@Override
public boolean suppressAllWarnings() {
return "warnings".equalsIgnoreCase(suppress);
return SUPPRESS_WARNINGS.equalsIgnoreCase(suppress);
}
// Used only for serialize and deserialize settings. Don't use in other places!
public static final class DummyImpl extends CommonCompilerArguments {
@Override
public String getSrc() {
return null;
}
}
}
@@ -19,6 +19,9 @@ package org.jetbrains.jet.cli.common.arguments;
import com.sampullara.cli.Argument;
import org.jetbrains.annotations.Nullable;
import static org.jetbrains.jet.cli.common.arguments.K2JsArgumentConstants.CALL;
import static org.jetbrains.jet.cli.common.arguments.K2JsArgumentConstants.NO_CALL;
/**
* NOTE: for now K2JSCompiler supports only minimal amount of parameters required to launch it from the plugin.
*/
@@ -39,7 +42,8 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
public String target;
@Nullable
@Argument(value = "main", description = "Whether a main function should be called; either 'call' or 'noCall', default 'call' (main function will be auto detected)")
@Argument(value = "main", description = "Whether a main function should be called; either '" + CALL +
"' or '" + NO_CALL + "', default '" + CALL + "' (main function will be auto detected)")
public String main;
@Override
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.cli.common.arguments;
public interface K2JsArgumentConstants {
String CALL = "call";
String NO_CALL = "noCall";
}
@@ -32,6 +32,7 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.common.CLICompiler;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments;
import org.jetbrains.jet.cli.common.arguments.K2JsArgumentConstants;
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
@@ -170,7 +171,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
}
public static MainCallParameters createMainCallParameters(String main) {
if ("noCall".equals(main)) {
if (K2JsArgumentConstants.NO_CALL.equals(main)) {
return MainCallParameters.noCall();
}
else {