aboutsummaryrefslogtreecommitdiff
path: root/src_eclipseagent/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-10-11 07:54:25 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-10-11 07:54:25 +0200
commit310862d94e3a4705faf0d2b6ed9cdb40247b39ca (patch)
tree473e2aa65e2cf064181193a15bab633e81bb0c11 /src_eclipseagent/lombok
parente2ffd58f81b6762429d0f27dc9977aa0e1721ae6 (diff)
downloadlombok-310862d94e3a4705faf0d2b6ed9cdb40247b39ca.tar.gz
lombok-310862d94e3a4705faf0d2b6ed9cdb40247b39ca.tar.bz2
lombok-310862d94e3a4705faf0d2b6ed9cdb40247b39ca.zip
Integrated lombok.jar and lombok.eclipse.agent.jar into one jar that installs, is a javac apt processor, and an agent, all at once.
Diffstat (limited to 'src_eclipseagent/lombok')
-rw-r--r--src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java b/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java
index 6efddf61..d1759127 100644
--- a/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java
@@ -56,7 +56,7 @@ public class EclipsePatcher {
ScriptManager sm = new ScriptManager();
sm.registerTransformer(instrumentation);
EquinoxClassLoader.getInstance().addPrefix("lombok.");
- EquinoxClassLoader.getInstance().registerScripts(sm);
+ EquinoxClassLoader.registerScripts(sm);
patchLombokizeAST(sm);
patchAvoidReparsingGeneratedCode(sm);
@@ -66,7 +66,7 @@ public class EclipsePatcher {
if (reloadExistingClasses) sm.reloadClasses(instrumentation);
}
-
+
private static void patchHideGeneratedNodes(ScriptManager sm) {
sm.addScript(ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode"))
@@ -75,6 +75,19 @@ public class EclipsePatcher {
"([Lorg/eclipse/jdt/core/dom/SimpleName;)[Lorg/eclipse/jdt/core/dom/SimpleName;"))
.request(StackRequest.RETURN_VALUE).build());
+ patchRefactorScripts(sm);
+ patchFormatters(sm);
+ }
+
+ private static void patchFormatters(ScriptManager sm) {
+ sm.addScript(ScriptBuilder.setSymbolDuringMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy", "format", "void"))
+ .callToWrap(new Hook("org/eclipse/jdt/internal/corext/util/CodeFormatterUtil", "reformat",
+ "(ILjava/lang/String;IIILjava/lang/String;Ljava/util/Map;)Lorg/eclipse/text/edits/TextEdit;"))
+ .symbol("lombok.disable").build());
+ }
+
+ private static void patchRefactorScripts(ScriptManager sm) {
sm.addScript(ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ASTRewrite", "replace"))
.target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ASTRewrite", "remove"))
@@ -89,14 +102,14 @@ public class EclipsePatcher {
"([Lorg/eclipse/jdt/core/IMethod;)[Lorg/eclipse/jdt/core/IMethod;"))
.transplant().build());
}
-
+
private static void patchCatchReparse(ScriptManager sm) {
sm.addScript(ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveStartingCatchPosition"))
.wrapMethod(new Hook("lombok/eclipse/agent/PatchFixes", "fixRetrieveStartingCatchPosition", "(I)I"))
.transplant().request(StackRequest.PARAM1).build());
}
-
+
private static void patchSetGeneratedFlag(ScriptManager sm) {
sm.addScript(ScriptBuilder.addField()
.targetClass("org.eclipse.jdt.internal.compiler.ast.ASTNode")
@@ -150,7 +163,7 @@ public class EclipsePatcher {
"(Lorg/eclipse/jdt/core/dom/SimpleName;Ljava/lang/Object;)V"))
.transplant().build());
}
-
+
private static void patchAvoidReparsingGeneratedCode(ScriptManager sm) {
final String PARSER_SIG1 = "org.eclipse.jdt.internal.compiler.parser.Parser";
sm.addScript(ScriptBuilder.exitEarly()
@@ -175,7 +188,7 @@ public class EclipsePatcher {
.decisionMethod(new Hook("lombok/eclipse/agent/PatchFixes", "checkBit24", "(Ljava/lang/Object;)Z"))
.transplant().request(StackRequest.PARAM1).build());
}
-
+
private static void patchLombokizeAST(ScriptManager sm) {
sm.addScript(ScriptBuilder.addField()
.targetClass("org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration")