mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 08:18:29 +00:00
[delombok] Added an option to emit only changed files.
This commit is contained in:
1 parent
f4bc0323dc
commit
de01d1eae1
1 file changed
+15
-1
@@ -86,6 +86,7 @@ public class Delombok {
|
||||
private PrintStream feedback = System.err;
|
||||
private boolean verbose;
|
||||
private boolean noCopy;
|
||||
private boolean onlyChanged;
|
||||
private boolean force = false;
|
||||
private String classpath, sourcepath, bootclasspath;
|
||||
private LinkedHashMap<File, File> fileToBase = new LinkedHashMap<File, File>();
|
||||
@@ -145,6 +146,10 @@ public class Delombok {
|
||||
@Shorthand("n")
|
||||
private boolean nocopy;
|
||||
|
||||
@Description("Output only changed files (implies -n)")
|
||||
@Shorthand("c")
|
||||
private boolean onlyChanged;
|
||||
|
||||
private boolean help;
|
||||
}
|
||||
|
||||
@@ -238,7 +243,8 @@ public class Delombok {
|
||||
}
|
||||
|
||||
if (args.verbose) delombok.setVerbose(true);
|
||||
if (args.nocopy) delombok.setNoCopy(true);
|
||||
if (args.nocopy || args.onlyChanged) delombok.setNoCopy(true);
|
||||
if (args.onlyChanged) delombok.setOnlyChanged(true);
|
||||
if (args.print) {
|
||||
delombok.setOutputToStandardOut();
|
||||
} else {
|
||||
@@ -364,6 +370,10 @@ public class Delombok {
|
||||
this.noCopy = noCopy;
|
||||
}
|
||||
|
||||
public void setOnlyChanged(boolean onlyChanged) {
|
||||
this.onlyChanged = onlyChanged;
|
||||
}
|
||||
|
||||
public void setOutput(File dir) {
|
||||
if (dir.isFile() || (!dir.isDirectory() && dir.getName().endsWith(".java"))) throw new IllegalArgumentException(
|
||||
"DELOMBOK: delombok will only write to a directory. " +
|
||||
@@ -585,6 +595,10 @@ public class Delombok {
|
||||
FormatPreferences fps = new FormatPreferences(formatPrefs);
|
||||
for (JCCompilationUnit unit : roots) {
|
||||
DelombokResult result = new DelombokResult(catcher.getComments(unit), unit, force || options.isChanged(unit), fps);
|
||||
if (onlyChanged && !result.isChanged() && !options.isChanged(unit)) {
|
||||
if (verbose) feedback.printf("File: %s [%s]\n", unit.sourcefile.getName(), "unchanged (skipped)");
|
||||
continue;
|
||||
}
|
||||
if (verbose) feedback.printf("File: %s [%s%s]\n", unit.sourcefile.getName(), result.isChanged() ? "delomboked" : "unchanged", force && !options.isChanged(unit) ? " (forced)" : "");
|
||||
Writer rawWriter;
|
||||
if (presetWriter != null) rawWriter = createUnicodeEscapeWriter(presetWriter);
|
||||
|
||||
Reference in new issue
Block a user