diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java index a526c87f196c..8f45d10ad042 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java @@ -19,6 +19,7 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.openapi.vfs.newvfs.ArchiveFileSystem; @@ -39,8 +40,6 @@ import java.util.Arrays; import java.util.Optional; import java.util.stream.Stream; -import static com.intellij.openapi.util.text.StringUtil.defaultIfEmpty; - /** * This helpful action opens a file or directory in a system file manager. * @@ -246,37 +245,37 @@ public class RevealFileAction extends DumbAwareAction { SystemInfo.isMac ? "Finder" : SystemInfo.isWindows ? "Explorer" : readDesktopEntryKey("Name").orElse("File Manager"); - } - private static Optional readDesktopEntryKey(String key) { - if (SystemInfo.hasXdgMime()) { - String appName = ExecUtil.execAndReadLine(new GeneralCommandLine("xdg-mime", "query", "default", "inode/directory")); - if (appName != null && appName.endsWith(".desktop")) { - return Stream.of(getXdgDataDirectories().split(":")) - .map(dir -> new File(dir, "applications/" + appName)) - .filter(File::exists) - .findFirst() - .map(file -> readDesktopEntryKey(file, key)); + + private static Optional readDesktopEntryKey(String key) { + if (SystemInfo.hasXdgMime()) { + String appName = ExecUtil.execAndReadLine(new GeneralCommandLine("xdg-mime", "query", "default", "inode/directory")); + if (appName != null && appName.endsWith(".desktop")) { + return Stream.of(getXdgDataDirectories().split(":")) + .map(dir -> new File(dir, "applications/" + appName)) + .filter(File::exists) + .findFirst() + .map(file -> readDesktopEntryKey(file, key)); + } } + + return Optional.empty(); } - return Optional.empty(); - } - - private static String getXdgDataDirectories() { - String dataHome = System.getenv("XDG_DATA_HOME"); - String dataDirs = System.getenv("XDG_DATA_DIRS"); - return defaultIfEmpty(dataHome, SystemProperties.getUserHome() + "/.local/share") + ':' + defaultIfEmpty(dataDirs, "/usr/local/share:/usr/share"); - } - - private static String readDesktopEntryKey(File file, String key) { - LOG.debug("looking for '" + key + "' in " + file); - String prefix = key + '='; - try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { - return reader.lines().filter(l -> l.startsWith(prefix)).map(l -> l.substring(prefix.length())).findFirst().orElse(null); + private static String getXdgDataDirectories() { + return StringUtil.defaultIfEmpty(System.getenv("XDG_DATA_HOME"), SystemProperties.getUserHome() + "/.local/share") + ':' + + StringUtil.defaultIfEmpty(System.getenv("XDG_DATA_DIRS"), "/usr/local/share:/usr/share"); } - catch (IOException | UncheckedIOException e) { - LOG.info("Cannot read: " + file, e); - return null; + + private static String readDesktopEntryKey(File file, String key) { + LOG.debug("looking for '" + key + "' in " + file); + String prefix = key + '='; + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { + return reader.lines().filter(l -> l.startsWith(prefix)).map(l -> l.substring(prefix.length())).findFirst().orElse(null); + } + catch (IOException | UncheckedIOException e) { + LOG.info("Cannot read: " + file, e); + return null; + } } } } \ No newline at end of file diff --git a/platform/platform-util-io/src/com/intellij/execution/process/ProcessOutput.java b/platform/platform-util-io/src/com/intellij/execution/process/ProcessOutput.java index d6579f3c836f..cda9704dcdd4 100644 --- a/platform/platform-util-io/src/com/intellij/execution/process/ProcessOutput.java +++ b/platform/platform-util-io/src/com/intellij/execution/process/ProcessOutput.java @@ -14,14 +14,13 @@ import java.util.List; public class ProcessOutput { private final StringBuilder myStdoutBuilder = new StringBuilder(); private final StringBuilder myStderrBuilder = new StringBuilder(); - @Nullable private Integer myExitCode; + private @Nullable Integer myExitCode; private boolean myTimeout; private boolean myCancelled; - public ProcessOutput() { - } + public ProcessOutput() { } - public ProcessOutput(final int exitCode) { + public ProcessOutput(int exitCode) { myExitCode = exitCode; } @@ -63,18 +62,14 @@ public class ProcessOutput { return splitLines(getStderr(), excludeEmptyLines); } - @NotNull private static List splitLines(String s, boolean excludeEmptyLines) { String converted = StringUtil.convertLineSeparators(s); return StringUtil.split(converted, "\n", true, excludeEmptyLines); } /** - * If exit code is nonzero or the process timed out, logs stderr and exit code and returns false, - * else just returns true. - * - * @param logger where to put error information - * @return true iff exit code is zero + * If exit code is nonzero or the process timed out, logs exit code and process output (if any) and returns {@code false}, + * otherwise just returns {@code true}. */ public boolean checkSuccess(@NotNull Logger logger) { int ec = getExitCode(); @@ -103,8 +98,7 @@ public class ProcessOutput { } /** - * @return false if exit code wasn't set, - * for example, when our CapturingProcessHandler.runProcess() is interrupted) + * Returns {@code false} if exit code wasn't set (e.g. when {@code CapturingProcessHandler.runProcess()} execution was interrupted). */ public boolean isExitCodeSet() { return myExitCode != null; @@ -125,4 +119,4 @@ public class ProcessOutput { public boolean isCancelled() { return myCancelled; } -} +} \ No newline at end of file diff --git a/xml/impl/src/com/intellij/ide/browsers/BrowserLauncherImpl.kt b/xml/impl/src/com/intellij/ide/browsers/BrowserLauncherImpl.kt index 7e95c82e5d81..f44aa911d5bb 100644 --- a/xml/impl/src/com/intellij/ide/browsers/BrowserLauncherImpl.kt +++ b/xml/impl/src/com/intellij/ide/browsers/BrowserLauncherImpl.kt @@ -89,8 +89,7 @@ class BrowserLauncherImpl : BrowserLauncherAppless() { showError(ExecUtil.readFirstLine(process.errorStream, null), browser, project, null, launchTask) } } - catch (ignored: InterruptedException) { - } + catch (ignored: InterruptedException) { } } // 10 seconds is enough to start JobScheduler.getScheduler().schedule({ future.cancel(true) }, 10, TimeUnit.SECONDS)