From 883883fd0a5f27ba1f0eee23ee46898fe4072a0d Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 6 Dec 2016 19:24:01 +0100 Subject: [PATCH] =?UTF-8?q?java=20nio=20globbing=20is=20broken=20and=20mus?= =?UTF-8?q?t=20be=20not=20used=20=E2=80=94=20use=20ported=20excellent=20an?= =?UTF-8?q?d=20awesome=20Minimatch=20port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/intellij/util/io/path.kt | 48 +------------------ .../util/execution/ParametersListUtil.java | 4 ++ 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/platform/projectModel-impl/src/com/intellij/util/io/path.kt b/platform/projectModel-impl/src/com/intellij/util/io/path.kt index 712ca78a0347..5d848030323a 100644 --- a/platform/projectModel-impl/src/com/intellij/util/io/path.kt +++ b/platform/projectModel-impl/src/com/intellij/util/io/path.kt @@ -223,50 +223,4 @@ inline fun Path.directoryStreamIfExists(noinline filter: ((path: Path) -> Bo return null } -private val LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtil") - -class PathMatcherEx(pattern: String) : PathMatcher { - private val matcher: PathMatcher - - val negate = pattern.startsWith('!') - val rawPattern: String - - init { - rawPattern = if (negate) pattern.substring(1) else pattern - matcher = FileSystems.getDefault().getPathMatcher("glob:$rawPattern") - } - - override fun matches(path: Path) = if (negate) !matcher.matches(path) else matcher.matches(path) - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other?.javaClass != javaClass) return false - - other as PathMatcherEx - - if (negate != other.negate) return false - if (rawPattern != other.rawPattern) return false - - return true - } - - override fun hashCode(): Int { - var result = negate.hashCode() - result = 31 * result + rawPattern.hashCode() - return result - } -} - -fun minimatchAll(path: Path, patterns: List): Boolean { - var match = false - for (pattern in patterns) { - // If we've got a match, only re-test for exclusions. - // if we don't have a match, only re-test for inclusions. - if (match !== pattern.negate) { - continue - } - - match = pattern.matches(path) - } - return match -} \ No newline at end of file +private val LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtil") \ No newline at end of file diff --git a/platform/util/src/com/intellij/util/execution/ParametersListUtil.java b/platform/util/src/com/intellij/util/execution/ParametersListUtil.java index 2aea48de96fa..8a234ff00489 100644 --- a/platform/util/src/com/intellij/util/execution/ParametersListUtil.java +++ b/platform/util/src/com/intellij/util/execution/ParametersListUtil.java @@ -183,6 +183,10 @@ public class ParametersListUtil { @NotNull private static String encode(@NotNull final List parameters) { + if (parameters.isEmpty()) { + return ""; + } + final StringBuilder buffer = new StringBuilder(); for (final String parameter : parameters) { if (buffer.length() > 0) {