Get rid of coroutinesWarn/coroutinesEnable/coroutinesError
Use a single coroutinesState instead. Change the coroutines state in
some tests from "warn" to "enable"/"error" to test that deserialization
of older config files works ("warn" is the default value, so it wasn't
testing anything here)
This commit is contained in:
@@ -275,19 +275,17 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
@NotNull CompilerConfiguration configuration,
|
||||
@NotNull CommonCompilerArguments arguments
|
||||
) {
|
||||
if (arguments.coroutinesError && !arguments.coroutinesWarn && !arguments.coroutinesEnable) {
|
||||
return LanguageFeature.State.ENABLED_WITH_ERROR;
|
||||
}
|
||||
else if (arguments.coroutinesEnable && !arguments.coroutinesWarn && !arguments.coroutinesError) {
|
||||
return LanguageFeature.State.ENABLED;
|
||||
}
|
||||
else if (!arguments.coroutinesEnable && !arguments.coroutinesError) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
String message = "The -Xcoroutines can only have one value";
|
||||
configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(ERROR, message, null);
|
||||
return null;
|
||||
switch (arguments.coroutinesState) {
|
||||
case CommonCompilerArguments.ERROR:
|
||||
return LanguageFeature.State.ENABLED_WITH_ERROR;
|
||||
case CommonCompilerArguments.ENABLE:
|
||||
return LanguageFeature.State.ENABLED;
|
||||
case CommonCompilerArguments.WARN:
|
||||
return null;
|
||||
default:
|
||||
String message = "Invalid value of -Xcoroutines (should be: enable, warn or error): " + arguments.coroutinesState;
|
||||
configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(ERROR, message, null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,20 +29,13 @@ class Usage {
|
||||
// The magic number 29 corresponds to the similar padding width in javac and scalac command line compilers
|
||||
private static final int OPTION_NAME_PADDING_WIDTH = 29;
|
||||
|
||||
private static final String coroutinesKeyDescription = "Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier";
|
||||
|
||||
public static void print(@NotNull PrintStream target, @NotNull CommonCompilerArguments arguments, boolean extraHelp) {
|
||||
target.println("Usage: " + arguments.executableScriptFileName() + " <options> <source files>");
|
||||
target.println("where " + (extraHelp ? "advanced" : "possible") + " options include:");
|
||||
boolean coroutinesUsagePrinted = false;
|
||||
for (Class<?> clazz = arguments.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
for (Field field : clazz.getDeclaredFields()) {
|
||||
String usage = fieldUsage(field, extraHelp);
|
||||
if (usage != null) {
|
||||
if (usage.contains("Xcoroutines")) {
|
||||
if (coroutinesUsagePrinted) continue;
|
||||
coroutinesUsagePrinted = true;
|
||||
}
|
||||
target.println(usage);
|
||||
}
|
||||
}
|
||||
@@ -59,14 +52,10 @@ class Usage {
|
||||
Argument argument = field.getAnnotation(Argument.class);
|
||||
if (argument == null) return null;
|
||||
|
||||
String argumentValue = argument.value();
|
||||
// TODO: this is a dirty hack, provide better mechanism for keys that can have several values
|
||||
boolean isXCoroutinesKey = argumentValue.contains("Xcoroutines");
|
||||
String value = isXCoroutinesKey ? "-Xcoroutines={enable|warn|error}" : argumentValue;
|
||||
if (extraHelp != ParseCommandLineArgumentsKt.isAdvanced(argument)) return null;
|
||||
|
||||
StringBuilder sb = new StringBuilder(" ");
|
||||
sb.append(value);
|
||||
sb.append(argument.value());
|
||||
|
||||
if (!argument.shortName().isEmpty()) {
|
||||
sb.append(" (");
|
||||
@@ -79,12 +68,6 @@ class Usage {
|
||||
sb.append(argument.valueDescription());
|
||||
}
|
||||
|
||||
if (isXCoroutinesKey) {
|
||||
sb.append(" ");
|
||||
sb.append(coroutinesKeyDescription);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
int width = OPTION_NAME_PADDING_WIDTH - 1;
|
||||
if (sb.length() >= width + 5) { // Break the line if it's too long
|
||||
sb.append("\n");
|
||||
|
||||
Reference in New Issue
Block a user