aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok')
-rw-r--r--src/core/lombok/bytecode/PoolConstantsApp.java81
-rw-r--r--src/core/lombok/bytecode/PostCompilerApp.java17
-rw-r--r--src/core/lombok/core/LombokApp.java20
-rw-r--r--src/core/lombok/core/Main.java8
-rw-r--r--src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java2
6 files changed, 113 insertions, 19 deletions
diff --git a/src/core/lombok/bytecode/PoolConstantsApp.java b/src/core/lombok/bytecode/PoolConstantsApp.java
new file mode 100644
index 00000000..59c51a37
--- /dev/null
+++ b/src/core/lombok/bytecode/PoolConstantsApp.java
@@ -0,0 +1,81 @@
+package lombok.bytecode;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import lombok.core.LombokApp;
+
+import org.mangosdk.spi.ProviderFor;
+
+import com.zwitserloot.cmdreader.CmdReader;
+import com.zwitserloot.cmdreader.Description;
+import com.zwitserloot.cmdreader.InvalidCommandLineException;
+import com.zwitserloot.cmdreader.Mandatory;
+import com.zwitserloot.cmdreader.Sequential;
+import com.zwitserloot.cmdreader.Shorthand;
+
+@ProviderFor(LombokApp.class)
+public class PoolConstantsApp extends LombokApp {
+
+ @Override public String getAppName() {
+ return "Xprintpool";
+ }
+
+ @Override public List<String> getAppAliases() {
+ return Arrays.asList("Xprintpool");
+ }
+
+ @Override public String getAppDescription() {
+ return "Prints the content of the constant pool to standard out.";
+ }
+
+ @Override public boolean isDebugTool() {
+ return true;
+ }
+
+ public static class CmdArgs {
+ @Sequential
+ @Mandatory
+ @Description("paths to class files to be printed. If a directory is named, all files (recursively) in that directory will be printed.")
+ private List<String> classFiles = new ArrayList<String>();
+
+ @Shorthand({"h", "?"})
+ @Description("Shows this help text")
+ boolean help = false;
+ }
+
+ @Override public int runApp(List<String> raw) throws Exception {
+ CmdReader<CmdArgs> reader = CmdReader.of(CmdArgs.class);
+ CmdArgs args;
+ try {
+ args = reader.make(raw.toArray(new String[0]));
+ if (args.help) {
+ System.out.println(reader.generateCommandLineHelp("java -jar lombok.jar -printpool"));
+ return 0;
+ }
+ } catch (InvalidCommandLineException e) {
+ System.err.println(e.getMessage());
+ System.err.println(reader.generateCommandLineHelp("java -jar lombok.jar -printpool"));
+ return 1;
+ }
+
+ List<File> filesToProcess = PostCompilerApp.cmdArgsToFiles(args.classFiles);
+ int filesVisited = 0;
+ boolean moreThanOne = filesToProcess.size() > 1;
+ for (File file : filesToProcess) {
+ if (!file.exists() || !file.isFile()) {
+ System.out.printf("Cannot find file '%s'\n", file.getAbsolutePath());
+ continue;
+ }
+ filesVisited++;
+ if (moreThanOne) System.out.printf("Processing '%s'\n", file.getAbsolutePath());
+ System.out.println(new ClassFileMetaData(PostCompilerApp.readFile(file)).poolContent());
+ }
+
+ if (moreThanOne) System.out.printf("Total files visited: %d\n", filesVisited);
+
+ return filesVisited == 0 ? 1 : 0;
+ }
+}
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/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index 5b7cdcaa..5731769a 100644
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -332,7 +332,7 @@ public class HandleConstructor {
Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN), findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN));
if (copiedAnnotations.length != 0) parameter.annotations = copiedAnnotations;
- params.add(new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL));
+ params.add(parameter);
}
statement.arguments = assigns.isEmpty() ? null : assigns.toArray(new Expression[assigns.size()]);