diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java index 32f55cb..82b5c53 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java @@ -54,7 +54,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun } DSPLaunchDelegateLaunchBuilder builder = new DSPLaunchDelegateLaunchBuilder(configuration, mode, launch, monitor); - List readaptCommand = List.of(CommandHelper.getPlatformCommand("\"" + readaptPath + "\" stdio")); + List readaptCommand = CommandHelper.getPlatformCommand("\"" + readaptPath + "\" stdio"); builder.setLaunchDebugAdapter(readaptCommand.get(0), readaptCommand.subList(1, readaptCommand.size())); builder.setMonitorDebugAdapter(DEBUG_READAPT.getValue()); builder.setDspParameters(Map.of( diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java index 266471c..1186d2e 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java @@ -65,7 +65,7 @@ public void start() throws IOException { private static List getSolargraphCommand() { String gemPath = GEM_PATH.getValue(); if (gemPath != null && new File(gemPath).exists()) { - return List.of(CommandHelper.getPlatformCommand("\"" + gemPath + "\" stdio")); + return CommandHelper.getPlatformCommand("\"" + gemPath + "\" stdio"); } return List.of(); } diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandHelper.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandHelper.java index 0a818ff..5f1eab3 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandHelper.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandHelper.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.util.List; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.Platform; @@ -62,7 +63,7 @@ public static String findPath(String executable, boolean searchInDefaultPluginLo return ""; } - public static String[] getAbsolutePlatformCommand(String command) { + public static List getAbsolutePlatformCommand(String command) { if (!SYSTEM_RUBY.getValue()) { String rubyDir = RUBY_DIR.getValue(); if (rubyDir != null && !rubyDir.isEmpty()) { @@ -72,18 +73,18 @@ public static String[] getAbsolutePlatformCommand(String command) { return CommandHelper.getPlatformCommand(command); } - public static String[] getPlatformCommand(String command) { + public static List getPlatformCommand(String command) { if (isWindows()) { - return new String[] { "cmd.exe", "/c", command }; + return List.of("cmd.exe", "/c", command); } else if (isMacOS()) { String defaultShellMacOS = DEFAULT_SHELL_MACOS.get(); if (defaultShellMacOS == null) { defaultShellMacOS = findDefaultShellMacOS(); DEFAULT_SHELL_MACOS.set(defaultShellMacOS); } - return new String[] { defaultShellMacOS, "-c", "-li", command }; + return List.of(defaultShellMacOS, "-c", "-li", command); } - return new String[] { "bash", "-c", "-l", command }; + return List.of("bash", "-c", "-l", command); } public static boolean isWindows() { diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandJob.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandJob.java index 01697e6..110e207 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandJob.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/CommandJob.java @@ -15,6 +15,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; @@ -26,11 +27,11 @@ public class CommandJob extends Job { - private final String[] command; + private final List command; private final String description; private volatile Process process; - public CommandJob(String gemName, String[] command, String description) { + public CommandJob(String gemName, List command, String description) { super(gemName); this.command = command; this.description = description; diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java index 95d163c..78c248c 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java @@ -13,6 +13,7 @@ package io.github.pyvesb.eclipse_solargraph.utils; import java.io.File; +import java.util.List; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -34,7 +35,7 @@ public class GemHelper { public static void install(String gem, StringPreferences pathPreference) { String lowerCaseGem = gem.toLowerCase(); String command = String.format("gem install -V -n \"%s\" %s", getPluginStateLocation(), lowerCaseGem); - String[] platformCommand = CommandHelper.getPlatformCommand(command); + List platformCommand = CommandHelper.getPlatformCommand(command); CommandJob installCommandJob = new CommandJob(gem, platformCommand, "Installation in progress"); installCommandJob.addJobChangeListener(new JobChangeAdapter() { @@ -57,7 +58,7 @@ public static void scheduleUpdate(String gem, long delay, StringPreferences path String path = pathPreference.getValue(); String lowerCaseGem = gem.toLowerCase(); String command = String.format("gem update -V -n \"%s\" %s", path.substring(0, path.lastIndexOf(File.separator)), lowerCaseGem); - String[] plarformCommand = CommandHelper.getPlatformCommand(command); + List plarformCommand = CommandHelper.getPlatformCommand(command); new CommandJob(gem, plarformCommand, "Update in progress").schedule(delay); } diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/LaunchHelper.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/LaunchHelper.java index d924d6d..835f6db 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/LaunchHelper.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/LaunchHelper.java @@ -1,6 +1,7 @@ package io.github.pyvesb.eclipse_solargraph.utils; import java.io.File; +import java.util.List; import java.util.concurrent.CompletableFuture; import org.eclipse.core.runtime.CoreException; @@ -16,10 +17,10 @@ public static Job createJob(ILaunch launch, String command, String workingDirect } public static Job createJob(ILaunch launch, String command, File workingDirectory) { - String[] absolutePlatformCommand = CommandHelper.getAbsolutePlatformCommand(command); + List absolutePlatformCommand = CommandHelper.getAbsolutePlatformCommand(command); return Job.create("Running '" + command + "'", r -> { try { - Process process = DebugPlugin.exec(absolutePlatformCommand, workingDirectory); + Process process = DebugPlugin.exec(absolutePlatformCommand.toArray(new String[0]), workingDirectory); if (process == null) { LogHelper.cancelled("Command cancelled: " + command); return;