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 @@ -102,7 +102,7 @@ public Optional<FileReference> getFile(List<String> filepath) {
if (filepath.stream().anyMatch(s -> s.equals(".."))) {
return Optional.empty();
}
String fullpath = buildPathString(filepath);
String fullpath = buildPathString(filepath, false);
if (classLoader.getResource(fullpath) != null) {
return Optional.of(new ClasspathSourceFileReference(fullpath, extractSubpath(basePath, fullpath), classLoader));
} else {
Expand All @@ -112,7 +112,7 @@ public Optional<FileReference> getFile(List<String> filepath) {

@Override
public Collection<FileReference> getFilesInPath(boolean recursive, List<String> path) {
String fullPath = buildPathString(path);
String fullPath = buildPathString(path, true);
Stream<String> candidates = files
.stream()
.filter(file -> file.startsWith(fullPath))
Expand All @@ -129,7 +129,7 @@ public Collection<FileReference> getFilesInPath(boolean recursive, List<String>

@Override
public Set<String> getSubpaths(List<String> path) {
String fullPath = buildPathString(path);
String fullPath = buildPathString(path, true);
return files
.stream()
.filter(file -> file.startsWith(fullPath))
Expand All @@ -141,12 +141,15 @@ public Set<String> getSubpaths(List<String> path) {
.collect(Collectors.toSet());
}

private String buildPathString(List<String> path) {
private String buildPathString(List<String> path, boolean isDirectory) {
String fullPath;
if (path.isEmpty() || (path.size() == 1 && path.get(0).isEmpty())) {
fullPath = basePath;
} else {
fullPath = basePath + CLASS_PATH_JOINER.join(path) + CLASS_PATH_SEPARATOR;
fullPath = basePath + CLASS_PATH_JOINER.join(path);
if (isDirectory) {
fullPath += CLASS_PATH_SEPARATOR;
}
}
return fullPath;
}
Expand Down