Recurse Source File Directories
Closed this issue · 2 comments
JakeWharton commented
I would very much like to see GuiceyDataGenerator
recurse into subdirectories when parsing directories.
Here is an updated parseDirectory
method:
private void parseDirectory(File directory, TypeParser parser) {
for (File file : directory.listFiles()) {
if (file.isFile()) {
for (String extension : _fileExtensions) {
if (file.getName().endsWith(extension)) {
parseFile(file, parser);
break;
}
}
} else if (file.isDirectory()) {
parseDirectory(file, parser);
}
}
}
JakeWharton commented
I just noticed that you have this block in parseFile
of the same file:
if (file.isDirectory()) {
parseDirectory(file, typeParser);
This will (likely) never get hit as-is because of the extension checking in the current parseDirectory
method. The only way it would happen is if one of the subdirectories names ended in one of the extensions.
If you implement the method above, you can remove these two lines from parseFile
.
JakeWharton commented
I'll be doing this on a fork (among other upgrades) and sending pull requests soon.