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 /src/core | |
parent | 55384884d380fba1a5fe024e1d82329d71c36f02 (diff) | |
download | lombok-81f6149b08e46503ebe82407c09574d943295320.tar.gz lombok-81f6149b08e46503ebe82407c09574d943295320.tar.bz2 lombok-81f6149b08e46503ebe82407c09574d943295320.zip |
Made LombokApp an abstract class and added isDebugTool.
Diffstat (limited to 'src/core')
-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 |
4 files changed, 31 insertions, 18 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 { |