Report warning for non-boolean CLI argument passed multiple times
Only if its values are different, see the test
This commit is contained in:
+6
@@ -20,7 +20,9 @@ import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CommonCompilerArguments implements Serializable {
|
||||
public static final long serialVersionUID = 0L;
|
||||
@@ -105,6 +107,10 @@ public abstract class CommonCompilerArguments implements Serializable {
|
||||
// Names of extra (-X...) arguments which have been passed in an obsolete form ("-Xaaa bbb", instead of "-Xaaa=bbb")
|
||||
public List<String> extraArgumentsPassedInObsoleteForm = new SmartList<>();
|
||||
|
||||
// Non-boolean arguments which have been passed multiple times, possibly with different values.
|
||||
// The key in the map is the name of the argument, the value is the last passed value.
|
||||
public Map<String, String> duplicateArguments = new LinkedHashMap<>();
|
||||
|
||||
@NotNull
|
||||
public static CommonCompilerArguments createDefaultInstance() {
|
||||
return new DummyImpl();
|
||||
|
||||
+7
@@ -30,6 +30,7 @@ val Argument.isAdvanced: Boolean
|
||||
|
||||
private val ADVANCED_ARGUMENT_PREFIX = "-X"
|
||||
|
||||
// Parses arguments in the passed [result] object, or throws an [IllegalArgumentException] with the message to be displayed to the user
|
||||
fun <A : CommonCompilerArguments> parseCommandLineArguments(args: Array<String>, result: A) {
|
||||
data class ArgumentField(val field: Field, val argument: Argument)
|
||||
|
||||
@@ -38,6 +39,8 @@ fun <A : CommonCompilerArguments> parseCommandLineArguments(args: Array<String>,
|
||||
if (argument != null) ArgumentField(field, argument) else null
|
||||
}
|
||||
|
||||
val visitedArgs = mutableSetOf<String>()
|
||||
|
||||
var i = 0
|
||||
while (i < args.size) {
|
||||
val arg = args[i++]
|
||||
@@ -74,6 +77,10 @@ fun <A : CommonCompilerArguments> parseCommandLineArguments(args: Array<String>,
|
||||
}
|
||||
}
|
||||
|
||||
if (!field.type.isArray && !visitedArgs.add(argument.value) && value is String && field.get(result) != value) {
|
||||
result.duplicateArguments.put(argument.value, value)
|
||||
}
|
||||
|
||||
updateField(field, result, value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user