This commit is contained in:
@@ -31,22 +31,24 @@ public class FileScanner {
|
||||
public Map<String, String> scan() {
|
||||
Map<String, String> result = new LinkedHashMap<>();
|
||||
try (Stream<Path> stream = Files.walk(repoRoot)) {
|
||||
stream.filter(Files::isRegularFile)
|
||||
List<Path> javaFiles = stream
|
||||
.filter(Files::isRegularFile)
|
||||
.filter(p -> p.toString().endsWith(".java"))
|
||||
.forEach(p -> {
|
||||
.filter(p -> {
|
||||
String rel = repoRoot.relativize(p).toString().replace('\\', '/');
|
||||
if (!rel.contains("/src/main/java/")) {
|
||||
return;
|
||||
}
|
||||
if (!moduleAllowed(rel)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
result.put(rel, new String(Files.readAllBytes(p), StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
});
|
||||
return rel.contains("/src/main/java/") && moduleAllowed(rel);
|
||||
})
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
javaFiles.parallelStream().forEach(p -> {
|
||||
String rel = repoRoot.relativize(p).toString().replace('\\', '/');
|
||||
try {
|
||||
synchronized (result) {
|
||||
result.put(rel, new String(Files.readAllBytes(p), StandardCharsets.UTF_8));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user