-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
SourceRoot.java
621 lines (571 loc) · 27.6 KB
/
SourceRoot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
package com.github.javaparser.utils;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseProblemException;
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParserConfiguration;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.printer.PrettyPrinter;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveAction;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.github.javaparser.ParseStart.COMPILATION_UNIT;
import static com.github.javaparser.Providers.provider;
import static com.github.javaparser.utils.CodeGenerationUtils.*;
import static com.github.javaparser.utils.Utils.assertNotNull;
import static java.nio.file.FileVisitResult.*;
/**
* A collection of Java source files located in one directory and its subdirectories on the file system. The root directory
* corresponds to the root of the package structure of the source files within. Files can be parsed and written back one
* by one or all together. <b>Note that</b> the internal cache used is thread-safe.
* <ul>
* <li>methods called "tryToParse..." will return their result inside a "ParseResult", which supports parse successes and failures.</li>
* <li>methods called "parse..." will return "CompilationUnit"s. If a file fails to parse, an exception is thrown.</li>
* <li>methods ending in "...Parallelized" will speed up parsing by using multiple threads.</li>
* </ul>
*/
public class SourceRoot {
@FunctionalInterface
public interface Callback {
enum Result {
SAVE, DONT_SAVE, TERMINATE
}
/**
* @param localPath the path to the file that was parsed, relative to the source root path.
* @param absolutePath the absolute path to the file that was parsed.
* @param result the result of of parsing the file.
*/
Result process(Path localPath, Path absolutePath, ParseResult<CompilationUnit> result);
}
private final Path root;
private final Map<Path, ParseResult<CompilationUnit>> cache = new ConcurrentHashMap<>();
private ParserConfiguration parserConfiguration = new ParserConfiguration();
private Function<CompilationUnit, String> printer = new PrettyPrinter()::print;
private static final Pattern JAVA_IDENTIFIER = Pattern.compile("\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*");
/**
* @param root the root directory of a set of source files. It corresponds to the root of the package structure of the
* source files within, like "javaparser/javaparser-core/src/main/java"
*/
public SourceRoot(Path root) {
assertNotNull(root);
if (!Files.isDirectory(root)) {
throw new IllegalArgumentException("Only directories are allowed as root path: " + root);
}
this.root = root.normalize();
Log.info("New source root at \"%s\"", this.root);
}
/**
* @param root the root directory of a set of source files. It corresponds to the root of the package structure of the
* source files within, like "javaparser/javaparser-core/src/main/java"
*/
public SourceRoot(Path root, ParserConfiguration parserConfiguration) {
this(root);
setParserConfiguration(parserConfiguration);
}
/**
* Tries to parse a .java files under the source root and returns the ParseResult. It keeps track of the parsed file
* so you can write it out with the saveAll() call. Note that the cache grows with every file parsed, so if you
* don't need saveAll(), or you don't ask SourceRoot to parse files multiple times (where the cache is useful) you
* might want to use the parse method with a callback.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
* @deprecated pass ParserConfiguration instead of JavaParser
*/
@Deprecated
public ParseResult<CompilationUnit> tryToParse(String startPackage, String filename, JavaParser javaParser)
throws IOException {
return tryToParse(startPackage, filename, javaParser.getParserConfiguration());
}
/**
* Tries to parse a .java files under the source root and returns the ParseResult. It keeps track of the parsed file
* so you can write it out with the saveAll() call. Note that the cache grows with every file parsed, so if you
* don't need saveAll(), or you don't ask SourceRoot to parse files multiple times (where the cache is useful) you
* might want to use the parse method with a callback.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public ParseResult<CompilationUnit> tryToParse(String startPackage, String filename, ParserConfiguration configuration) throws IOException {
assertNotNull(startPackage);
assertNotNull(filename);
final Path relativePath = fileInPackageRelativePath(startPackage, filename);
if (cache.containsKey(relativePath)) {
Log.trace("Retrieving cached %s", relativePath);
return cache.get(relativePath);
}
final Path path = root.resolve(relativePath);
Log.trace("Parsing %s", path);
final ParseResult<CompilationUnit> result = new JavaParser(configuration)
.parse(COMPILATION_UNIT, provider(path));
result.getResult().ifPresent(cu -> cu.setStorage(path));
cache.put(relativePath, result);
return result;
}
/**
* Tries to parse a .java files under the source root and returns the ParseResult. It keeps track of the parsed file
* so you can write it out with the saveAll() call. Note that the cache grows with every file parsed, so if you
* don't need saveAll(), or you don't ask SourceRoot to parse files multiple times (where the cache is useful) you
* might want to use the parse method with a callback.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public ParseResult<CompilationUnit> tryToParse(String startPackage, String filename) throws IOException {
return tryToParse(startPackage, filename, parserConfiguration);
}
/**
* Tries to parse all .java files in a package recursively, and returns all files ever parsed with this source root.
* It keeps track of all parsed files so you can write them out with a single saveAll() call. Note that the cache
* grows with every file parsed, so if you don't need saveAll(), or you don't ask SourceRoot to parse files multiple
* times (where the cache is useful) you might want to use the parse method with a callback.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public List<ParseResult<CompilationUnit>> tryToParse(String startPackage) throws IOException {
assertNotNull(startPackage);
logPackage(startPackage);
final Path path = packageAbsolutePath(root, startPackage);
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (!attrs.isDirectory() && file.toString().endsWith(".java")) {
Path relative = root.relativize(file.getParent());
tryToParse(relative.toString(), file.getFileName().toString());
}
return CONTINUE;
}
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return isSensibleDirectoryToEnter(dir) ? CONTINUE : SKIP_SUBTREE;
}
});
return getCache();
}
private static boolean isSensibleDirectoryToEnter(Path dir) throws IOException {
final String dirToEnter = dir.getFileName().toString();
// Don't enter directories that cannot be packages.
final boolean directoryIsAValidJavaIdentifier = JAVA_IDENTIFIER.matcher(dirToEnter).matches();
// Don't enter directories that are hidden, assuming that people don't store source files in hidden directories.
if (Files.isHidden(dir) || !directoryIsAValidJavaIdentifier) {
Log.trace("Not processing directory \"%s\"", dirToEnter);
return false;
}
return true;
}
/**
* Tries to parse all .java files under the source root recursively, and returns all files ever parsed with this
* source root. It keeps track of all parsed files so you can write them out with a single saveAll() call. Note that
* the cache grows with every file parsed, so if you don't need saveAll(), or you don't ask SourceRoot to parse
* files multiple times (where the cache is useful) you might want to use the parse method with a callback.
*/
public List<ParseResult<CompilationUnit>> tryToParse() throws IOException {
return tryToParse("");
}
/**
* Tries to parse all .java files in a package recursively using multiple threads, and returns all files ever parsed
* with this source root. A new thread is forked each time a new directory is visited and is responsible for parsing
* all .java files in that directory. <b>Note that</b> to ensure thread safety, a new parser instance is created for
* every file with the internal parser's (i.e. {@link #setJavaParser}) configuration. It keeps track of all parsed
* files so you can write them out with a single saveAll() call. Note that the cache grows with every file parsed,
* so if you don't need saveAll(), or you don't ask SourceRoot to parse files multiple times (where the cache is
* useful) you might want to use the parse method with a callback.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public List<ParseResult<CompilationUnit>> tryToParseParallelized(String startPackage) {
assertNotNull(startPackage);
logPackage(startPackage);
final Path path = packageAbsolutePath(root, startPackage);
ParallelParse parse = new ParallelParse(path, (file, attrs) -> {
if (!attrs.isDirectory() && file.toString().endsWith(".java")) {
Path relative = root.relativize(file.getParent());
try {
tryToParse(
relative.toString(),
file.getFileName().toString(),
parserConfiguration);
} catch (IOException e) {
Log.error(e);
}
}
return CONTINUE;
});
ForkJoinPool pool = new ForkJoinPool();
pool.invoke(parse);
return getCache();
}
/**
* Tries to parse all .java files under the source root recursively using multiple threads, and returns all files
* ever parsed with this source root. A new thread is forked each time a new directory is visited and is responsible
* for parsing all .java files in that directory. <b>Note that</b> to ensure thread safety, a new parser instance is
* created for every file with the internal parser's (i.e. {@link #setJavaParser}) configuration. It keeps track of
* all parsed files so you can write them out with a single saveAll() call. Note that the cache grows with every
* file parsed, so if you don't need saveAll(), or you don't ask SourceRoot to parse files multiple times (where the
* cache is useful) you might want to use the parse method with a callback.
*/
public List<ParseResult<CompilationUnit>> tryToParseParallelized() {
return tryToParseParallelized("");
}
/**
* Parses a .java files under the source root and returns its CompilationUnit. It keeps track of the parsed file so
* you can write it out with the saveAll() call. Note that the cache grows with every file parsed, so if you don't
* need saveAll(), or you don't ask SourceRoot to parse files multiple times (where the cache is useful) you might
* want to use the parse method with a callback.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
* @throws ParseProblemException when something went wrong.
*/
public CompilationUnit parse(String startPackage, String filename) {
assertNotNull(startPackage);
assertNotNull(filename);
try {
final ParseResult<CompilationUnit> result = tryToParse(startPackage, filename);
if (result.isSuccessful()) {
return result.getResult().get();
}
throw new ParseProblemException(result.getProblems());
} catch (IOException e) {
throw new ParseProblemException(e);
}
}
private FileVisitResult callback(Path absolutePath, ParserConfiguration configuration, Callback callback) throws IOException {
if (!Files.exists(absolutePath)) {
return TERMINATE;
}
Path localPath = root.relativize(absolutePath);
Log.trace("Parsing %s", localPath);
ParseResult<CompilationUnit> result = new JavaParser(configuration).parse(COMPILATION_UNIT, provider(absolutePath));
result.getResult().ifPresent(cu -> cu.setStorage(absolutePath));
switch (callback.process(localPath, absolutePath, result)) {
case SAVE:
result.getResult().ifPresent(cu -> save(cu, absolutePath));
case DONT_SAVE:
return CONTINUE;
case TERMINATE:
return TERMINATE;
default:
throw new AssertionError("Return an enum defined in SourceRoot.Callback.Result");
}
}
/**
* Locates the .java file with the provided package and file name, parses it and passes it to the
* callback. In comparison to the other parse methods, this is much more memory efficient, but saveAll() won't work.
*
* @param startPackage The package containing the file
* @param filename The name of the file
*/
public SourceRoot parse(String startPackage, String filename, ParserConfiguration configuration, Callback
callback) throws IOException {
assertNotNull(startPackage);
assertNotNull(filename);
assertNotNull(configuration);
assertNotNull(callback);
callback(fileInPackageAbsolutePath(root, startPackage, filename), configuration, callback);
return this;
}
/**
* Parses the provided .java file and passes it to the callback. In comparison to the other parse methods, this
* makes is much more memory efficient., but saveAll() won't work.
*/
public SourceRoot parse(String startPackage, String filename, Callback callback) throws IOException {
parse(startPackage, filename, parserConfiguration, callback);
return this;
}
/**
* Tries to parse all .java files in a package recursively and passes them one by one to the callback. In comparison
* to the other parse methods, this is much more memory efficient, but saveAll() won't work.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
* @deprecated pass ParserConfiguration instead of JavaParser
*/
@Deprecated
public SourceRoot parse(String startPackage, JavaParser javaParser, Callback callback) throws IOException {
return parse(startPackage, javaParser.getParserConfiguration(), callback);
}
/**
* Tries to parse all .java files in a package recursively and passes them one by one to the callback. In comparison
* to the other parse methods, this is much more memory efficient, but saveAll() won't work.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public SourceRoot parse(String startPackage, ParserConfiguration configuration, Callback callback) throws IOException {
assertNotNull(startPackage);
assertNotNull(configuration);
assertNotNull(callback);
logPackage(startPackage);
final Path path = packageAbsolutePath(root, startPackage);
if (Files.exists(path)) {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path absolutePath, BasicFileAttributes attrs) throws IOException {
if (!attrs.isDirectory() && absolutePath.toString().endsWith(".java")) {
return callback(absolutePath, configuration, callback);
}
return CONTINUE;
}
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return isSensibleDirectoryToEnter(dir) ? CONTINUE : SKIP_SUBTREE;
}
});
}
return this;
}
public SourceRoot parse(String startPackage, Callback callback) throws IOException {
parse(startPackage, parserConfiguration, callback);
return this;
}
private void logPackage(String startPackage) {
if (startPackage.isEmpty()) {
return;
}
Log.info("Parsing package \"%s\"", startPackage);
}
/**
* Tries to parse all .java files in a package recursively using multiple threads, and passes them one by one to the
* callback. A new thread is forked each time a new directory is visited and is responsible for parsing all .java
* files in that directory. <b>Note that</b> the provided {@link Callback} code must be made thread-safe. <b>Note
* that</b> to ensure thread safety, a new parser instance is created for every file with the provided {@link
* ParserConfiguration}. In comparison to the other parse methods, this is much more memory efficient, but saveAll()
* won't work.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public SourceRoot parseParallelized(String startPackage, ParserConfiguration configuration, Callback callback) {
assertNotNull(startPackage);
assertNotNull(configuration);
assertNotNull(callback);
logPackage(startPackage);
final Path path = packageAbsolutePath(root, startPackage);
if (Files.exists(path)) {
ParallelParse parse = new ParallelParse(path, (absolutePath, attrs) -> {
if (!attrs.isDirectory() && absolutePath.toString().endsWith(".java")) {
try {
return callback(absolutePath, configuration, callback);
} catch (IOException e) {
Log.error(e);
}
}
return CONTINUE;
});
ForkJoinPool pool = new ForkJoinPool();
pool.invoke(parse);
}
return this;
}
/**
* Tries to parse all .java files in a package recursively using multiple threads, and passes them one by one to the
* callback. A new thread is forked each time a new directory is visited and is responsible for parsing all .java
* files in that directory. <b>Note that</b> the provided {@link Callback} code must be made thread-safe. <b>Note
* that</b> to ensure thread safety, a new parser instance is created for every file. In comparison to the other
* parse methods, this is much more memory efficient, but saveAll() won't work.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public SourceRoot parseParallelized(String startPackage, Callback callback) throws IOException {
return parseParallelized(startPackage, new ParserConfiguration(), callback);
}
/**
* Tries to parse all .java files recursively using multiple threads, and passes them one by one to the callback. A
* new thread is forked each time a new directory is visited and is responsible for parsing all .java files in that
* directory. <b>Note that</b> the provided {@link Callback} code must be made thread-safe. <b>Note that</b> to
* ensure thread safety, a new parser instance is created for every file. In comparison to the other parse methods,
* this is much more memory efficient, but saveAll() won't work.
*/
public SourceRoot parseParallelized(Callback callback) throws IOException {
return parseParallelized("", new ParserConfiguration(), callback);
}
/**
* Add a newly created Java file to the cache of this source root. It will be saved when saveAll is called.
*
* @param startPackage files in this package and deeper are parsed. Pass "" to parse all files.
*/
public SourceRoot add(String startPackage, String filename, CompilationUnit compilationUnit) {
assertNotNull(startPackage);
assertNotNull(filename);
assertNotNull(compilationUnit);
Log.trace("Adding new file %s.%s", startPackage, filename);
final Path path = fileInPackageRelativePath(startPackage, filename);
final ParseResult<CompilationUnit> parseResult = new ParseResult<>(
compilationUnit,
new ArrayList<>(),
null,
null);
cache.put(path, parseResult);
return this;
}
/**
* Add a newly created Java file to the cache of this source root. It will be saved when saveAll is called. It needs
* to have its path set.
*/
public SourceRoot add(CompilationUnit compilationUnit) {
assertNotNull(compilationUnit);
if (compilationUnit.getStorage().isPresent()) {
final Path path = compilationUnit.getStorage().get().getPath();
Log.trace("Adding new file %s", path);
final ParseResult<CompilationUnit> parseResult = new ParseResult<>(
compilationUnit,
new ArrayList<>(),
null,
null);
cache.put(path, parseResult);
} else {
throw new AssertionError("Files added with this method should have their path set.");
}
return this;
}
/**
* Save the given compilation unit to the given path.
*/
private SourceRoot save(CompilationUnit cu, Path path) {
assertNotNull(cu);
assertNotNull(path);
cu.setStorage(path);
cu.getStorage().get().save(printer);
return this;
}
/**
* Save all previously parsed files back to a new path.
*/
public SourceRoot saveAll(Path root) {
assertNotNull(root);
Log.info("Saving all files (%s) to %s", cache.size(), root);
for (Map.Entry<Path, ParseResult<CompilationUnit>> cu : cache.entrySet()) {
final Path path = root.resolve(cu.getKey());
if (cu.getValue().getResult().isPresent()) {
Log.trace("Saving %s", path);
save(cu.getValue().getResult().get(), path);
}
}
return this;
}
/**
* Save all previously parsed files back to where they were found.
*/
public SourceRoot saveAll() {
return saveAll(root);
}
/**
* The Java files that have been parsed by this source root object, or have been added manually.
*/
public List<ParseResult<CompilationUnit>> getCache() {
return new ArrayList<>(cache.values());
}
/**
* The CompilationUnits of the Java files that have been parsed succesfully by this source root object, or have been
* added manually.
*/
public List<CompilationUnit> getCompilationUnits() {
return cache.values().stream()
.filter(ParseResult::isSuccessful)
.map(p -> p.getResult().get())
.collect(Collectors.toList());
}
/**
* The path that was passed in the constructor.
*/
public Path getRoot() {
return root;
}
/**
* @deprecated store ParserConfiguration now
*/
@Deprecated
public JavaParser getJavaParser() {
return new JavaParser(parserConfiguration);
}
/**
* Set the parser that is used for parsing by default.
*
* @deprecated store ParserConfiguration now
*/
@Deprecated
public SourceRoot setJavaParser(JavaParser javaParser) {
assertNotNull(javaParser);
this.parserConfiguration = javaParser.getParserConfiguration();
return this;
}
public ParserConfiguration getParserConfiguration() {
return parserConfiguration;
}
/**
* Set the parser configuration that is used for parsing when no configuration is passed to a method.
*/
public SourceRoot setParserConfiguration(ParserConfiguration parserConfiguration) {
assertNotNull(parserConfiguration);
this.parserConfiguration = parserConfiguration;
return this;
}
/**
* Set the printing function that transforms compilation units into a string to save.
*/
public SourceRoot setPrinter(Function<CompilationUnit, String> printer) {
assertNotNull(printer);
this.printer = printer;
return this;
}
/**
* Get the printing function.
*/
public Function<CompilationUnit, String> getPrinter() {
return printer;
}
/**
* Executes a recursive file tree walk using threads. A new thread is invoked for each new directory discovered
* during the walk. For each file visited, the user-provided {@link VisitFileCallback} is called with the current
* path and file attributes. Any shared resources accessed in a {@link VisitFileCallback} should be made
* thread-safe.
*/
private static class ParallelParse extends RecursiveAction {
private static final long serialVersionUID = 1L;
private final Path path;
private final VisitFileCallback callback;
ParallelParse(Path path, VisitFileCallback callback) {
this.path = path;
this.callback = callback;
}
@Override
protected void compute() {
final List<ParallelParse> walks = new ArrayList<>();
try {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
if (!SourceRoot.isSensibleDirectoryToEnter(dir)) {
return SKIP_SUBTREE;
}
if (!dir.equals(ParallelParse.this.path)) {
ParallelParse w = new ParallelParse(dir, callback);
w.fork();
walks.add(w);
return SKIP_SUBTREE;
} else {
return CONTINUE;
}
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
return callback.process(file, attrs);
}
});
} catch (IOException e) {
Log.error(e);
}
for (ParallelParse w : walks) {
w.join();
}
}
interface VisitFileCallback {
FileVisitResult process(Path file, BasicFileAttributes attrs);
}
}
}