-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
The GapPatternPostProcessor should check if files are actually .java files before renaming them (or more generally check if a match means that the file is to be renamed). The current processor will fail, for example, if both directories are empty and contain a .gitkeep file (will be renamed to .gitkeep.java).
Lines 125 to 139 in 10a33c3
| for (Path processFile: filesToPostProcess) { | |
| String oldClassName = processFile.getFileName().toString().replaceAll(".java", ""); | |
| String className = processFile.getFileName().toString().replaceAll(JAVAFILE_MATCHER_PATTERN, | |
| replacementPattern); | |
| Path targetPath = processFile.getParent().resolve(Paths.get(className + ".java")); | |
| LOG.info(String.format("Renaming %s to %s", processFile.toString(), targetPath.toString())); | |
| Files.move(processFile, targetPath, StandardCopyOption.REPLACE_EXISTING); | |
| String content = new String(Files.readAllBytes(targetPath), charset); | |
| content = content.replaceAll(String.format(searchPattern, oldClassName), | |
| replacementPattern); | |
| Files.write(targetPath, content.getBytes(charset)); | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels