CLI: change "-suppress warnings" option to "-nowarn"
Following the rule of the least surprise: this option is named "-nowarn" in other JVM language compilers. Besides, having an option with an argument which can take exactly one predefined value is sort of confusing
This commit is contained in:
-21
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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";
|
|
||||||
}
|
|
||||||
+3
-10
@@ -22,9 +22,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.jet.cli.common.arguments.CommonArgumentConstants.SUPPRESS_WARNINGS;
|
|
||||||
|
|
||||||
public abstract class CommonCompilerArguments {
|
public abstract class CommonCompilerArguments {
|
||||||
|
@Argument(value = "nowarn", description = "Generate no warnings")
|
||||||
|
public boolean suppressWarnings;
|
||||||
|
|
||||||
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
|
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
|
||||||
public boolean tags;
|
public boolean tags;
|
||||||
|
|
||||||
@@ -37,19 +38,11 @@ public abstract class CommonCompilerArguments {
|
|||||||
@Argument(value = "help", alias = "h", description = "Print a synopsis of standard options")
|
@Argument(value = "help", alias = "h", description = "Print a synopsis of standard options")
|
||||||
public boolean help;
|
public boolean help;
|
||||||
|
|
||||||
@Argument(value = "suppress", description = "Suppress all compiler warnings")
|
|
||||||
@ValueDescription(SUPPRESS_WARNINGS)
|
|
||||||
public String suppress;
|
|
||||||
|
|
||||||
@Argument(value = "X", description = "Print a synopsis of advanced options")
|
@Argument(value = "X", description = "Print a synopsis of advanced options")
|
||||||
public boolean extraHelp;
|
public boolean extraHelp;
|
||||||
|
|
||||||
public List<String> freeArgs = new SmartList<String>();
|
public List<String> freeArgs = new SmartList<String>();
|
||||||
|
|
||||||
public boolean suppressAllWarnings() {
|
|
||||||
return SUPPRESS_WARNINGS.equalsIgnoreCase(suppress);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String executableScriptFileName() {
|
public String executableScriptFileName() {
|
||||||
return "kotlinc";
|
return "kotlinc";
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
|
|
||||||
MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose);
|
MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose);
|
||||||
|
|
||||||
if (arguments.suppressAllWarnings()) {
|
if (arguments.suppressWarnings) {
|
||||||
collector = new FilteringMessageCollector(collector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
|
collector = new FilteringMessageCollector(collector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ where possible options include:
|
|||||||
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
|
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
|
||||||
-output-prefix <path> Path to file which will be added to the beginning of output file
|
-output-prefix <path> Path to file which will be added to the beginning of output file
|
||||||
-output-postfix <path> Path to file which will be added to the end of output file
|
-output-postfix <path> Path to file which will be added to the end of output file
|
||||||
|
-nowarn Generate no warnings
|
||||||
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
||||||
-verbose Enable verbose logging output
|
-verbose Enable verbose logging output
|
||||||
-version Display compiler version
|
-version Display compiler version
|
||||||
-help (-h) Print a synopsis of standard options
|
-help (-h) Print a synopsis of standard options
|
||||||
-suppress warnings Suppress all compiler warnings
|
|
||||||
-X Print a synopsis of advanced options
|
-X Print a synopsis of advanced options
|
||||||
OK
|
OK
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
$TESTDATA_DIR$/../warnings.kt
|
$TESTDATA_DIR$/../warnings.kt
|
||||||
-suppress
|
-nowarn
|
||||||
WaRnInGs
|
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$/out.js
|
$TEMP_DIR$/out.js
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ where possible options include:
|
|||||||
-module <path> Path to the module file to compile
|
-module <path> Path to the module file to compile
|
||||||
-script Evaluate the script file
|
-script Evaluate the script file
|
||||||
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||||
|
-nowarn Generate no warnings
|
||||||
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
||||||
-verbose Enable verbose logging output
|
-verbose Enable verbose logging output
|
||||||
-version Display compiler version
|
-version Display compiler version
|
||||||
-help (-h) Print a synopsis of standard options
|
-help (-h) Print a synopsis of standard options
|
||||||
-suppress warnings Suppress all compiler warnings
|
|
||||||
-X Print a synopsis of advanced options
|
-X Print a synopsis of advanced options
|
||||||
OK
|
OK
|
||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
$TESTDATA_DIR$/../warnings.kt
|
$TESTDATA_DIR$/../warnings.kt
|
||||||
-suppress
|
-nowarn
|
||||||
warnings
|
|
||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
$TESTDATA_DIR$/../warnings.kt
|
|
||||||
-suppress
|
|
||||||
WaRnInGs
|
|
||||||
-d
|
|
||||||
$TEMP_DIR$
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -11,10 +11,10 @@ where possible options include:
|
|||||||
-module <path> Path to the module file to compile
|
-module <path> Path to the module file to compile
|
||||||
-script Evaluate the script file
|
-script Evaluate the script file
|
||||||
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||||
|
-nowarn Generate no warnings
|
||||||
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
||||||
-verbose Enable verbose logging output
|
-verbose Enable verbose logging output
|
||||||
-version Display compiler version
|
-version Display compiler version
|
||||||
-help (-h) Print a synopsis of standard options
|
-help (-h) Print a synopsis of standard options
|
||||||
-suppress warnings Suppress all compiler warnings
|
|
||||||
-X Print a synopsis of advanced options
|
-X Print a synopsis of advanced options
|
||||||
INTERNAL_ERROR
|
INTERNAL_ERROR
|
||||||
@@ -52,12 +52,7 @@ public class CliCommonTest extends CliBaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void suppressAllWarningsLowercase() throws Exception {
|
public void suppressAllWarningsJvm() throws Exception {
|
||||||
executeCompilerCompareOutputJVM();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void suppressAllWarningsMixedCase() throws Exception {
|
|
||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,14 +89,9 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
|||||||
doJvmTest("compiler/testData/cli/jvm/simple.args");
|
doJvmTest("compiler/testData/cli/jvm/simple.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("suppressAllWarningsLowercase.args")
|
@TestMetadata("suppressAllWarningsJvm.args")
|
||||||
public void testSuppressAllWarningsLowercase() throws Exception {
|
public void testSuppressAllWarningsJvm() throws Exception {
|
||||||
doJvmTest("compiler/testData/cli/jvm/suppressAllWarningsLowercase.args");
|
doJvmTest("compiler/testData/cli/jvm/suppressAllWarningsJvm.args");
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("suppressAllWarningsMixedCase.args")
|
|
||||||
public void testSuppressAllWarningsMixedCase() throws Exception {
|
|
||||||
doJvmTest("compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("wrongAbiVersion.args")
|
@TestMetadata("wrongAbiVersion.args")
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class ForTestCompileRuntime {
|
|||||||
"-d", destDir.getPath(),
|
"-d", destDir.getPath(),
|
||||||
"-no-stdlib",
|
"-no-stdlib",
|
||||||
"-no-jdk-annotations",
|
"-no-jdk-annotations",
|
||||||
"-suppress", "warnings",
|
"-nowarn",
|
||||||
"-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(),
|
"-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(),
|
||||||
"-classpath", classPath
|
"-classpath", classPath
|
||||||
);
|
);
|
||||||
|
|||||||
+3
-13
@@ -36,8 +36,6 @@ import org.jetbrains.jet.plugin.JetBundle;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.cli.common.arguments.CommonArgumentConstants.SUPPRESS_WARNINGS;
|
|
||||||
|
|
||||||
public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Configurable.NoScroll{
|
public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Configurable.NoScroll{
|
||||||
private final CommonCompilerArguments commonCompilerArguments;
|
private final CommonCompilerArguments commonCompilerArguments;
|
||||||
private final K2JSCompilerArguments k2jsCompilerArguments;
|
private final K2JSCompilerArguments k2jsCompilerArguments;
|
||||||
@@ -88,7 +86,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
return ComparingUtils.isModified(generateNoWarningsCheckBox, isGenerateNoWarnings()) ||
|
return ComparingUtils.isModified(generateNoWarningsCheckBox, commonCompilerArguments.suppressWarnings) ||
|
||||||
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) ||
|
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) ||
|
||||||
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
|
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
|
||||||
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
|
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
|
||||||
@@ -97,7 +95,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() throws ConfigurationException {
|
public void apply() throws ConfigurationException {
|
||||||
setGenerateNoWarnings(generateNoWarningsCheckBox.isSelected());
|
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
|
||||||
compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText());
|
compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText());
|
||||||
k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected();
|
k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected();
|
||||||
k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true);
|
k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true);
|
||||||
@@ -106,7 +104,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
generateNoWarningsCheckBox.setSelected(isGenerateNoWarnings());
|
generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
|
||||||
additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
|
additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
|
||||||
generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourceMap);
|
generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourceMap);
|
||||||
outputPrefixFile.setText(k2jsCompilerArguments.outputPrefix);
|
outputPrefixFile.setText(k2jsCompilerArguments.outputPrefix);
|
||||||
@@ -129,14 +127,6 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGenerateNoWarnings() {
|
|
||||||
return commonCompilerArguments.suppressAllWarnings();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setGenerateNoWarnings(boolean selected) {
|
|
||||||
commonCompilerArguments.suppress = selected ? SUPPRESS_WARNINGS : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setupFileChooser(
|
private static void setupFileChooser(
|
||||||
@NotNull JLabel label,
|
@NotNull JLabel label,
|
||||||
@NotNull TextFieldWithBrowseButton fileChooser,
|
@NotNull TextFieldWithBrowseButton fileChooser,
|
||||||
|
|||||||
Reference in New Issue
Block a user