Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cleanroommc.groovyscript.api.GroovyLog;
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -147,16 +148,19 @@ static Collection<File> getSortedFilesOf(File root, Collection<String> paths) {
if (!rootFile.exists()) {
continue;
}
int pathSize = path.split(separator).length;
// if we are looking at a specific file, we don't want that to be overridden.
// otherwise, we want to use the specificity based on the number of file separators.
int pathSize = StringUtils.countMatches(path, separator);
try (Stream<Path> stream = Files.walk(rootFile.toPath())) {
stream.filter(path1 -> isGroovyFile(path1.toString()))
.map(Path::toFile)
//.filter(Preprocessor::validatePreprocessors)
.sorted(Comparator.comparing(File::getPath))
.forEach(file -> {
if (files.containsKey(file)) {
// if the file already exists, push the priority down if we are more specific than the already existing entry
if (pathSize > files.getInt(file)) {
files.put(file, pathSize);
files.putAndMoveToLast(file, pathSize);
}
} else {
files.put(file, pathSize);
Expand Down