diff options
author | Roel Spilker <r.spilker@gmail.com> | 2010-08-08 22:27:22 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2010-08-08 22:27:22 +0200 |
commit | d4247f2e8b048d6cae83d5f93d59c7591309e65c (patch) | |
tree | 248f17cc65855720b3e7d9127170eace931e2fdb /src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | |
parent | 2683c24ee96fd7228198512f5cfcb2fd0b0cfabd (diff) | |
download | lombok-d4247f2e8b048d6cae83d5f93d59c7591309e65c.tar.gz lombok-d4247f2e8b048d6cae83d5f93d59c7591309e65c.tar.bz2 lombok-d4247f2e8b048d6cae83d5f93d59c7591309e65c.zip |
Post-compilation works in both Eclipse and ecj
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 1486c608..1d2efea0 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -64,11 +64,39 @@ public class EclipsePatcher extends Agent { patchSetGeneratedFlag(sm); patchHideGeneratedNodes(sm); patchLiveDebug(sm); + patchPostCompileHookEclipse(sm); + } else { + patchPostCompileHookEcj(sm); } if (reloadExistingClasses) sm.reloadClasses(instrumentation); } + private static void patchPostCompileHookEclipse(ScriptManager sm) { + sm.addScript(ScriptBuilder.wrapMethodCall() + .target(new MethodTarget("org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder", "writeClassFileContents")) + .target(new MethodTarget("org.eclipse.jdt.internal.core.builder.AbstractImageBuilder", "writeClassFileContents")) + .methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.ClassFile", "getBytes", "byte[]")) + .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "runPostCompiler", "byte[]", "byte[]", "java.lang.String")) + .requestExtra(StackRequest.PARAM3) + .transplant() + .build()); + } + + private static void patchPostCompileHookEcj(ScriptManager sm) { + sm.addScript(ScriptBuilder.wrapMethodCall() + .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")) + .build()); + + sm.addScript(ScriptBuilder.wrapMethodCall() + .target(new MethodTarget("org.eclipse.jdt.internal.compiler.util.Util", "writeToDisk")) + .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")) + .build()); + } + private static void patchHideGeneratedNodes(ScriptManager sm) { sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode")) |