mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
Don't fail parsing of arguments if there is additional argument
Otherwise it's not possible to add new parameters to the command without breaking old versions of IDE GitOrigin-RevId: 4d2d8e7ab87bac4435f42a430d1c129f4b5cac9a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ae2e2f737c
commit
bd56198eab
@@ -25,7 +25,7 @@ class AssertFindUsagesEntryCommand(text: String, line: Int) : PlaybackCommandCor
|
||||
}
|
||||
|
||||
val options = AssertFindUsagesEntryArguments()
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split(" ", limit= 2) }.toTypedArray())
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split(" ", limit = 2) }.toTypedArray(), false)
|
||||
|
||||
if (options.text == null && options.filePath == null) {
|
||||
throw IllegalStateException("Provide expected test or position of the find usages option.")
|
||||
|
||||
@@ -21,7 +21,7 @@ class AssertModuleJdkVersionCommand(text: String, line: Int) : PerformanceComman
|
||||
val project = context.project
|
||||
val options = AssertModuleJdkArguments()
|
||||
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split("=") }.toTypedArray())
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split("=") }.toTypedArray(), false)
|
||||
val moduleManager = ModuleManager.getInstance(project)
|
||||
val module = moduleManager.findModuleByName(options.moduleName)
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class FindUsagesCommand(text: String, line: Int) : PerformanceCommandCoroutineAd
|
||||
|
||||
override suspend fun doExecute(context: PlaybackContext) {
|
||||
val options = FindUsagesArguments()
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split(" ", limit = 2) }.toTypedArray())
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split(" ", limit = 2) }.toTypedArray(), false)
|
||||
|
||||
val project = context.project
|
||||
val position = options.position
|
||||
|
||||
@@ -37,7 +37,7 @@ class FindUsagesInBackgroundCommand(text: String, line: Int) : PerformanceComman
|
||||
|
||||
override suspend fun doExecute(context: PlaybackContext) {
|
||||
val options = FindUsagesArguments()
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split(" ", limit = 2) }.toTypedArray())
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split(" ", limit = 2) }.toTypedArray(), false)
|
||||
|
||||
val project = context.project
|
||||
val elementName = options.expectedName
|
||||
|
||||
@@ -73,7 +73,7 @@ public class InspectionCommandEx extends AbstractCommand {
|
||||
public InspectionCommandEx(@NotNull String text, int line) {
|
||||
super(text, line);
|
||||
if (text.startsWith(PREFIX)) {
|
||||
Args.parse(myOptions, text.substring(PREFIX.length()).trim().split(" "));
|
||||
Args.parse(myOptions, text.substring(PREFIX.length()).trim().split(" "), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdap
|
||||
|
||||
fun getOptions(arguments: String): OpenFileCommandOptions? {
|
||||
return runCatching {
|
||||
OpenFileCommandOptions().apply { Args.parse(this, arguments.split(" ").toTypedArray()) }
|
||||
OpenFileCommandOptions().apply { Args.parse(this, arguments.split(" ").toTypedArray(), false) }
|
||||
}.getOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ReplaceTextCommand extends AbstractCommand {
|
||||
protected @NotNull Promise<Object> _execute(@NotNull PlaybackContext context) {
|
||||
final AsyncPromise<Object> result = new AsyncPromise<>();
|
||||
Options options = new Options();
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split(" "));
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split(" "), false);
|
||||
|
||||
ApplicationManager.getApplication().executeOnPooledThread(() -> {
|
||||
try {
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class RunConfigurationCommand extends AbstractCommand {
|
||||
//example: %runConfiguration -mode=TILL_TERMINATED|-configurationName=My Run Configuration|-failureExpected|-debug
|
||||
RunConfigurationOptions options = new RunConfigurationOptions();
|
||||
Args.parse(options, Arrays.stream(extractCommandArgument(PREFIX).split("\\|"))
|
||||
.flatMap(item -> Arrays.stream(item.split("="))).toArray(String[]::new));
|
||||
.flatMap(item -> Arrays.stream(item.split("="))).toArray(String[]::new), false);
|
||||
|
||||
Ref<Span> mainSpan = new Ref<>(), processSpan = new Ref<>();
|
||||
Timer timer = new Timer();
|
||||
|
||||
@@ -267,7 +267,7 @@ public class SearchEverywhereCommand extends AbstractCommand {
|
||||
protected String @NotNull [] getArgs(String prefix) {
|
||||
String input = extractCommandArgument(prefix);
|
||||
String[] args = input.split("\\|");
|
||||
Args.parse(myOptions, args[0].split(" "));
|
||||
Args.parse(myOptions, args[0].split(" "), false);
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class SetModuleJdkCommand(text: String, line: Int) : PerformanceCommandCoroutine
|
||||
override suspend fun doExecute(context: PlaybackContext) {
|
||||
val project = context.project
|
||||
val options = SetModuleJdkArguments()
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split("=") }.toTypedArray())
|
||||
Args.parse(options, extractCommandArgument(PREFIX).split("|").flatMap { it.split("=") }.toTypedArray(), false)
|
||||
|
||||
val moduleManager = ModuleManager.getInstance(project)
|
||||
val module = moduleManager.findModuleByName(options.moduleName)
|
||||
|
||||
@@ -4,5 +4,5 @@ import com.jetbrains.performancePlugin.commands.CommandArguments
|
||||
import com.sampullara.cli.Args
|
||||
|
||||
fun CommandArguments.parse(text: String) {
|
||||
Args.parse(this, text.split("|").flatMap { it.split(" ", limit=2) }.toTypedArray())
|
||||
Args.parse(this, text.split("|").flatMap { it.split(" ", limit = 2) }.toTypedArray(), false)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class OpenFileCommandOptionsTest {
|
||||
fun testThat_Options_Successfully_Parsed(commandLine: String) {
|
||||
//Related to OpenFileCommand logic
|
||||
val myOptions = runCatching {
|
||||
OpenFileCommandOptions().apply { Args.parse(this, commandLine.split(" ").toTypedArray()) }
|
||||
OpenFileCommandOptions().apply { Args.parse(this, commandLine.split(" ").toTypedArray(), false) }
|
||||
}.getOrNull()
|
||||
|
||||
assertTrue(myOptions!!.suppressErrors)
|
||||
@@ -32,7 +32,7 @@ class OpenFileCommandOptionsTest {
|
||||
fun testThat_DisableCodeAnalysis_is_False_ByDefault() {
|
||||
//Related to OpenFileCommand logic
|
||||
val myOptions = runCatching {
|
||||
OpenFileCommandOptions().apply { Args.parse(this, "-file src/Main.java -suppressErrors -timeout 99".split(" ").toTypedArray()) }
|
||||
OpenFileCommandOptions().apply { Args.parse(this, "-file src/Main.java -suppressErrors -timeout 99".split(" ").toTypedArray(), false) }
|
||||
}.getOrNull()
|
||||
|
||||
assertFalse(myOptions!!.disableCodeAnalysis)
|
||||
|
||||
Reference in New Issue
Block a user