mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java nio globbing is broken and must be not used — use ported excellent and awesome Minimatch port
This commit is contained in:
@@ -223,50 +223,4 @@ inline fun <R> 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<PathMatcherEx>): 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
|
||||
}
|
||||
private val LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtil")
|
||||
@@ -183,6 +183,10 @@ public class ParametersListUtil {
|
||||
|
||||
@NotNull
|
||||
private static String encode(@NotNull final List<String> parameters) {
|
||||
if (parameters.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
for (final String parameter : parameters) {
|
||||
if (buffer.length() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user