From 4424bee95addb8c3cbc618f4c01eb67392f2cd5f Mon Sep 17 00:00:00 2001 From: "Pierre-Yves B." <10694593+PyvesB@users.noreply.github.com> Date: Sun, 20 Feb 2022 16:37:59 +0100 Subject: [PATCH] Use Java 11 collection utilities --- .../launch/debug/ReadaptDebugDelegate.java | 17 +++++++---------- .../SolargraphStreamConnectionProvider.java | 6 ++---- .../eclipse_solargraph/utils/CommandJob.java | 4 ++-- 3 files changed, 11 insertions(+), 16 deletions(-) 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 258640f..b2cc70f 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 @@ -17,8 +17,7 @@ import static io.github.pyvesb.eclipse_solargraph.preferences.StringPreferences.READAPT_PATH; import java.io.File; -import java.util.Collections; -import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; @@ -50,16 +49,14 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun return; } - Map parameters = new HashMap<>(); - parameters.put("program", configuration.getAttribute(RubyLaunchShortcut.SCRIPT, "")); - parameters.put("runtimeArgs", configuration.getAttribute(RubyLaunchShortcut.ARGUMENTS, "")); - parameters.put("cwd", configuration.getAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, "")); - parameters.put("request", "launch"); - DSPLaunchDelegateLaunchBuilder builder = new DSPLaunchDelegateLaunchBuilder(configuration, mode, launch, monitor); - builder.setLaunchDebugAdapter("\"" + readaptPath + "\"", Collections.singletonList("stdio")); + builder.setLaunchDebugAdapter("\"" + readaptPath + "\"", List.of("stdio")); builder.setMonitorDebugAdapter(DEBUG_READAPT.getValue()); - builder.setDspParameters(parameters); + builder.setDspParameters(Map.of( + "program", configuration.getAttribute(RubyLaunchShortcut.SCRIPT, ""), + "runtimeArgs", configuration.getAttribute(RubyLaunchShortcut.ARGUMENTS, ""), + "cwd", configuration.getAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, ""), + "request", "launch")); super.launch(builder); if (UPDATE_GEM.getValue() && !HAS_UPDATED_READAPT.getAndSet(true)) { 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 48532ec..9c1049b 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 @@ -17,8 +17,6 @@ import java.io.File; import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -59,9 +57,9 @@ public void start() throws IOException { private static List getSolargraphCommand() { String gemPath = GEM_PATH.getValue(); if (gemPath != null && new File(gemPath).exists()) { - return Arrays.asList(CommandHelper.getPlatformCommand("\"" + gemPath + "\" stdio")); + return List.of(CommandHelper.getPlatformCommand("\"" + gemPath + "\" stdio")); } - return Collections.emptyList(); + return List.of(); } private void displayNotFoundWarning() { 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 dbfe844..c233db3 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,7 +15,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import java.util.Arrays; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; @@ -39,7 +39,7 @@ public CommandJob(String gemName, String[] command, String description) { @Override protected IStatus run(IProgressMonitor monitor) { - String commandString = Arrays.asList(command).toString(); + String commandString = List.of(command).toString(); LogHelper.info("Running command " + commandString); monitor.beginTask(description, IProgressMonitor.UNKNOWN); try {