diff options
author | Roel Spilker <r.spilker@gmail.com> | 2012-01-30 21:47:23 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2012-01-30 21:47:23 +0100 |
commit | 81f6149b08e46503ebe82407c09574d943295320 (patch) | |
tree | 4b766c355c831bb95580b3640faf3844daeeea86 | |
parent | 55384884d380fba1a5fe024e1d82329d71c36f02 (diff) | |
download | lombok-81f6149b08e46503ebe82407c09574d943295320.tar.gz lombok-81f6149b08e46503ebe82407c09574d943295320.tar.bz2 lombok-81f6149b08e46503ebe82407c09574d943295320.zip |
Made LombokApp an abstract class and added isDebugTool.
-rw-r--r-- | src/core/lombok/bytecode/PostCompilerApp.java | 17 | ||||
-rw-r--r-- | src/core/lombok/core/LombokApp.java | 20 | ||||
-rw-r--r-- | src/core/lombok/core/Main.java | 8 | ||||
-rw-r--r-- | src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java | 4 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/DelombokApp.java | 4 | ||||
-rw-r--r-- | src/installer/lombok/installer/Installer.java | 16 |
6 files changed, 37 insertions, 32 deletions
diff --git a/src/core/lombok/bytecode/PostCompilerApp.java b/src/core/lombok/bytecode/PostCompilerApp.java index 1e6475ea..d2c3157c 100644 --- a/src/core/lombok/bytecode/PostCompilerApp.java +++ b/src/core/lombok/bytecode/PostCompilerApp.java @@ -44,7 +44,7 @@ import com.zwitserloot.cmdreader.Sequential; import com.zwitserloot.cmdreader.Shorthand; @ProviderFor(LombokApp.class) -public class PostCompilerApp implements LombokApp { +public class PostCompilerApp extends LombokApp { @Override public List<String> getAppAliases() { return Arrays.asList("post", "postcompile"); } @@ -87,11 +87,8 @@ public class PostCompilerApp implements LombokApp { return 1; } - List<File> filesToProcess = new ArrayList<File>(); - for (String f : args.classFiles) addFiles(filesToProcess, f); - int filesVisited = 0, filesTouched = 0; - for (File file : filesToProcess) { + for (File file : cmdArgsToFiles(args.classFiles)) { if (!file.exists() || !file.isFile()) { System.out.printf("Cannot find file '%s'\n", file); continue; @@ -115,7 +112,13 @@ public class PostCompilerApp implements LombokApp { return filesVisited == 0 ? 1 : 0; } - private void addFiles(List<File> filesToProcess, String f) { + static List<File> cmdArgsToFiles(List<String> fileNames) { + List<File> filesToProcess = new ArrayList<File>(); + for (String f : fileNames) addFiles(filesToProcess, f); + return filesToProcess; + } + + static void addFiles(List<File> filesToProcess, String f) { File file = new File(f); if (file.isDirectory()) { addRecursively(filesToProcess, file); @@ -124,7 +127,7 @@ public class PostCompilerApp implements LombokApp { } } - private void addRecursively(List<File> filesToProcess, File file) { + static void addRecursively(List<File> filesToProcess, File file) { for (File f : file.listFiles()) { if (f.isDirectory()) addRecursively(filesToProcess, f); else if (f.getName().endsWith(".class")) filesToProcess.add(f); diff --git a/src/core/lombok/core/LombokApp.java b/src/core/lombok/core/LombokApp.java index 4aec37ad..f969aede 100644 --- a/src/core/lombok/core/LombokApp.java +++ b/src/core/lombok/core/LombokApp.java @@ -21,6 +21,7 @@ */ package lombok.core; +import java.util.Collections; import java.util.List; /** @@ -28,25 +29,34 @@ import java.util.List; * * @see lombok.core.Main.VersionApp */ -public interface LombokApp { +public abstract class LombokApp { /** * @param args The arguments; analogous to what's passed to {@code public static void main(String[] args)} methods. * @return The return value. Don't call {@code System.exit} yourself. */ - public int runApp(List<String> args) throws Exception; + public abstract int runApp(List<String> args) throws Exception; /** * @return Your app name. For example {@code delombok}. */ - public String getAppName(); + public abstract String getAppName(); /** * @return Description of this app, for the command line. */ - public String getAppDescription(); + public abstract String getAppDescription(); /** * @return When lombok.jar is executed with any of these strings as first argument, your app will be started. */ - public List<String> getAppAliases(); + public List<String> getAppAliases() { + return Collections.emptyList(); + } + + /** + * @return {@code true} if this app is an internal debugging tool and won't be listed by the default help message. + */ + public boolean isDebugTool() { + return false; + } } diff --git a/src/core/lombok/core/Main.java b/src/core/lombok/core/Main.java index 90928aa6..408bfd4a 100644 --- a/src/core/lombok/core/Main.java +++ b/src/core/lombok/core/Main.java @@ -44,7 +44,7 @@ public class Main { } @ProviderFor(LombokApp.class) - public static class VersionApp implements LombokApp { + public static class VersionApp extends LombokApp { @Override public String getAppName() { return "version"; } @@ -54,7 +54,7 @@ public class Main { } @Override public List<String> getAppAliases() { - return Arrays.asList("version", "-version", "--version"); + return Arrays.asList("-version", "--version"); } @Override public int runApp(List<String> args) { @@ -64,7 +64,7 @@ public class Main { } @ProviderFor(LombokApp.class) - public static class LicenseApp implements LombokApp { + public static class LicenseApp extends LombokApp { @Override public String getAppName() { return "license"; } @@ -74,7 +74,7 @@ public class Main { } @Override public List<String> getAppAliases() { - return Arrays.asList("license", "licence", "copyright", "copyleft", "gpl"); + return Arrays.asList("licence", "copyright", "copyleft", "gpl"); } @Override public int runApp(List<String> args) { diff --git a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java index 6815f5d9..4d5988af 100644 --- a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java +++ b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java @@ -49,7 +49,7 @@ import com.zwitserloot.cmdreader.Requires; import com.zwitserloot.cmdreader.Shorthand; @ProviderFor(LombokApp.class) -public class CreateLombokRuntimeApp implements LombokApp { +public class CreateLombokRuntimeApp extends LombokApp { private List<RuntimeDependencyInfo> infoObjects; @Override public String getAppName() { @@ -64,7 +64,7 @@ public class CreateLombokRuntimeApp implements LombokApp { } @Override public List<String> getAppAliases() { - return Arrays.asList("createRuntime", "runtime"); + return Arrays.asList("runtime"); } private static class CmdArgs { diff --git a/src/delombok/lombok/delombok/DelombokApp.java b/src/delombok/lombok/delombok/DelombokApp.java index 75286529..90a7b55e 100644 --- a/src/delombok/lombok/delombok/DelombokApp.java +++ b/src/delombok/lombok/delombok/DelombokApp.java @@ -40,7 +40,7 @@ import lombok.core.LombokApp; import org.mangosdk.spi.ProviderFor; @ProviderFor(LombokApp.class) -public class DelombokApp implements LombokApp { +public class DelombokApp extends LombokApp { @Override public int runApp(List<String> args) throws Exception { try { Class.forName("com.sun.tools.javac.main.JavaCompiler"); @@ -245,7 +245,7 @@ public class DelombokApp implements LombokApp { } @Override public List<String> getAppAliases() { - return Arrays.asList("unlombok", "delombok"); + return Arrays.asList("unlombok"); } @Override public String getAppDescription() { diff --git a/src/installer/lombok/installer/Installer.java b/src/installer/lombok/installer/Installer.java index 579216c0..29ffde89 100644 --- a/src/installer/lombok/installer/Installer.java +++ b/src/installer/lombok/installer/Installer.java @@ -111,7 +111,7 @@ public class Installer { } @ProviderFor(LombokApp.class) - public static class GraphicalInstallerApp implements LombokApp { + public static class GraphicalInstallerApp extends LombokApp { @Override public String getAppName() { return "installer"; } @@ -121,7 +121,7 @@ public class Installer { } @Override public List<String> getAppAliases() { - return Arrays.asList("installer", ""); + return Arrays.asList(""); } @Override public int runApp(List<String> args) throws Exception { @@ -130,7 +130,7 @@ public class Installer { } @ProviderFor(LombokApp.class) - public static class CommandLineInstallerApp implements LombokApp { + public static class CommandLineInstallerApp extends LombokApp { @Override public String getAppName() { return "install"; } @@ -139,17 +139,13 @@ public class Installer { return "Runs the 'handsfree' command line scriptable installer."; } - @Override public List<String> getAppAliases() { - return Arrays.asList("install"); - } - @Override public int runApp(List<String> args) throws Exception { return cliInstaller(false, args); } } @ProviderFor(LombokApp.class) - public static class CommandLineUninstallerApp implements LombokApp { + public static class CommandLineUninstallerApp extends LombokApp { @Override public String getAppName() { return "uninstall"; } @@ -158,10 +154,6 @@ public class Installer { return "Runs the 'handsfree' command line scriptable uninstaller."; } - @Override public List<String> getAppAliases() { - return Arrays.asList("uninstall"); - } - @Override public int runApp(List<String> args) throws Exception { return cliInstaller(true, args); } |