Skip to content

Commit

Permalink
Use Java 11 collection utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Feb 20, 2022
1 parent ebc5b94 commit 4424bee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -50,16 +49,14 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
return;
}

Map<String, Object> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -59,9 +57,9 @@ public void start() throws IOException {
private static List<String> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 4424bee

Please sign in to comment.