aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2018-04-10 01:55:11 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2018-04-10 01:55:11 +0200
commitde01d1eae16a61e1d3b4cafedd32e59f98396000 (patch)
tree1a38536ed075895de3aaf44bef6ea59983f10778
parentf4bc0323dca86fb5559e753ef9f05af5672d27ef (diff)
downloadlombok-de01d1eae16a61e1d3b4cafedd32e59f98396000.tar.gz
lombok-de01d1eae16a61e1d3b4cafedd32e59f98396000.tar.bz2
lombok-de01d1eae16a61e1d3b4cafedd32e59f98396000.zip
[delombok] Added an option to emit only changed files.
-rw-r--r--src/delombok/lombok/delombok/Delombok.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java
index 0d887cb9..a53f5a10 100644
--- a/src/delombok/lombok/delombok/Delombok.java
+++ b/src/delombok/lombok/delombok/Delombok.java
@@ -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);