aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2012-01-09 19:46:42 +0100
committerRoel Spilker <r.spilker@gmail.com>2012-01-09 19:46:42 +0100
commit3796efe82e73fe60a15c0fd1a827dd417dfbcb57 (patch)
tree314ac2d8a50e5c4fa83aad5f22dde471e712a3b9 /src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
parent302761816eb1e58c77cedb73040ed2967208d1fa (diff)
parentbf354e3b5ced16913726afc8247b1dd0321c9d62 (diff)
downloadlombok-3796efe82e73fe60a15c0fd1a827dd417dfbcb57.tar.gz
lombok-3796efe82e73fe60a15c0fd1a827dd417dfbcb57.tar.bz2
lombok-3796efe82e73fe60a15c0fd1a827dd417dfbcb57.zip
Merge
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index 82425027..04f83e66 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -78,8 +78,6 @@ public class EclipsePatcher extends Agent {
EquinoxClassLoader.registerScripts(sm);
}
- patchAvoidReparsingGeneratedCode(sm);
-
if (!ecjOnly) {
patchCatchReparse(sm);
patchIdentifierEndReparse(sm);
@@ -99,6 +97,7 @@ public class EclipsePatcher extends Agent {
patchPostCompileHookEcj(sm);
}
+ patchAvoidReparsingGeneratedCode(sm);
patchLombokizeAST(sm);
patchEcjTransformers(sm, ecjOnly);
@@ -106,6 +105,27 @@ public class EclipsePatcher extends Agent {
}
private static void patchExtractInterface(ScriptManager sm) {
+ /* Fix sourceEnding for generated nodes to avoid null pointer */
+ sm.addScript(ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.compiler.SourceElementNotifier", "notifySourceElementRequestor", "void", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "org.eclipse.jdt.internal.compiler.ast.ImportReference"))
+ .methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt", "get", "int", "java.lang.Object"))
+ .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getSourceEndFixed", "int", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
+ .requestExtra(StackRequest.PARAM1)
+ .transplant().build());
+
+ /* Make sure the generated source element is found instead of the annotation */
+ sm.addScript(ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodDeclaration", "void",
+ "org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite",
+ "org.eclipse.jdt.core.dom.rewrite.ASTRewrite",
+ "org.eclipse.jdt.core.dom.AbstractTypeDeclaration",
+ "org.eclipse.jdt.core.dom.MethodDeclaration"
+ ))
+ .methodToWrap(new Hook("org.eclipse.jface.text.IDocument", "get", "java.lang.String", "int", "int"))
+ .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getRealMethodDeclarationSource", "java.lang.String", "java.lang.String", "org.eclipse.jdt.core.dom.MethodDeclaration"))
+ .requestExtra(StackRequest.PARAM4)
+ .build());
+
/* get real generated node in stead of a random one generated by the annotation */
sm.addScript(ScriptBuilder.replaceMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMemberDeclarations"))
@@ -114,13 +134,19 @@ public class EclipsePatcher extends Agent {
.replacementMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getRealMethodDeclarationNode", "org.eclipse.jdt.core.dom.MethodDeclaration", "org.eclipse.jdt.core.IMethod", "org.eclipse.jdt.core.dom.CompilationUnit"))
.build());
- /* Do not add @Override's for generated methods */
+ /* Do not add @Override's for generated methods */
sm.addScript(ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ListRewrite", "insertFirst"))
.decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isListRewriteOnGeneratedNode", "boolean", "org.eclipse.jdt.core.dom.rewrite.ListRewrite"))
.request(StackRequest.THIS)
.build());
+ /* Do not add comments for generated methods */
+ sm.addScript(ScriptBuilder.exitEarly()
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodComment"))
+ .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode"))
+ .request(StackRequest.PARAM2)
+ .build());
}
private static void patchSyntaxAndOccurrencesHighlighting(ScriptManager sm) {
@@ -172,7 +198,7 @@ public class EclipsePatcher extends Agent {
}
private static void patchSortMembersOperation(ScriptManager sm) {
- /* Fixes "sort members" action with @Data @Log
+ /* Fixes "sort members" action with @Data @Log
* I would have liked to patch sortMembers, but kept getting a VerifyError: Illegal type in constant pool
* So now I just patch all calling methods
*/
@@ -240,6 +266,7 @@ public class EclipsePatcher extends Agent {
.target(new MethodTarget("org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl", "outputClassFiles"))
.methodToWrap(new Hook("javax.tools.JavaFileObject", "openOutputStream", "java.io.OutputStream"))
.wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "runPostCompiler", "java.io.OutputStream", "java.io.OutputStream"))
+ .transplant()
.build());
sm.addScript(ScriptBuilder.wrapMethodCall()
@@ -247,29 +274,11 @@ public class EclipsePatcher extends Agent {
.methodToWrap(new Hook("java.io.BufferedOutputStream", "<init>", "void", "java.io.OutputStream", "int"))
.wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "runPostCompiler", "java.io.BufferedOutputStream", "java.io.BufferedOutputStream", "java.lang.String", "java.lang.String"))
.requestExtra(StackRequest.PARAM2, StackRequest.PARAM3)
+ .transplant()
.build());
}
private static void patchHideGeneratedNodes(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapMethodCall()
- .target(new MethodTarget("org.eclipse.jdt.internal.compiler.SourceElementNotifier", "notifySourceElementRequestor", "void", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "org.eclipse.jdt.internal.compiler.ast.ImportReference"))
- .methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt", "get", "int", "java.lang.Object"))
- .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getSourceEndFixed", "int", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
- .requestExtra(StackRequest.PARAM1)
- .transplant().build());
-
- sm.addScript(ScriptBuilder.wrapMethodCall()
- .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodDeclaration", "void",
- "org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite",
- "org.eclipse.jdt.core.dom.rewrite.ASTRewrite",
- "org.eclipse.jdt.core.dom.AbstractTypeDeclaration",
- "org.eclipse.jdt.core.dom.MethodDeclaration"
- ))
- .methodToWrap(new Hook("org.eclipse.jface.text.IDocument", "get", "java.lang.String", "int", "int"))
- .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getRealMethodDeclarationSource", "java.lang.String", "java.lang.String", "org.eclipse.jdt.core.dom.MethodDeclaration"))
- .requestExtra(StackRequest.PARAM4)
- .build());
-
sm.addScript(ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode"))
.target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByBinding"))
@@ -417,6 +426,7 @@ public class EclipsePatcher extends Agent {
"org.eclipse.jdt.internal.compiler.ast.MethodDeclaration",
"org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration"))
.decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "checkBit24", "boolean", "java.lang.Object"))
+ .transplant()
.request(StackRequest.PARAM1).build());
sm.addScript(ScriptBuilder.exitEarly()
@@ -424,6 +434,7 @@ public class EclipsePatcher extends Agent {
"org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration",
"org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration", "boolean"))
.decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "checkBit24", "boolean", "java.lang.Object"))
+ .transplant()
.request(StackRequest.PARAM1).build());
sm.addScript(ScriptBuilder.exitEarly()
@@ -432,6 +443,7 @@ public class EclipsePatcher extends Agent {
"org.eclipse.jdt.internal.compiler.ast.TypeDeclaration",
"org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration"))
.decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "checkBit24", "boolean", "java.lang.Object"))
+ .transplant()
.request(StackRequest.PARAM1).build());
}