From d4247f2e8b048d6cae83d5f93d59c7591309e65c Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Sun, 8 Aug 2010 22:27:22 +0200 Subject: Post-compilation works in both Eclipse and ecj --- src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java') diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index bb3d90f7..48103a98 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -22,10 +22,16 @@ package lombok.eclipse.agent; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; +import lombok.core.DiagnosticsReceiver; +import lombok.core.PostCompiler; + import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.SimpleName; @@ -107,4 +113,17 @@ public class PatchFixes { } return newSimpleNames; } + + public static byte[] runPostCompiler(byte[] bytes, String className) { + byte[] transformed = PostCompiler.applyTransformations(bytes, className, DiagnosticsReceiver.CONSOLE); + return transformed == null ? bytes : transformed; + } + + public static OutputStream runPostCompiler(OutputStream out) throws IOException { + return PostCompiler.wrapOutputStream(out, "TEST", DiagnosticsReceiver.CONSOLE); + } + + public static BufferedOutputStream runPostCompiler(BufferedOutputStream out) throws IOException { + return new BufferedOutputStream(PostCompiler.wrapOutputStream(out, "TEST", DiagnosticsReceiver.CONSOLE)); + } } -- cgit From 1f1fd17350bd61169e2aa01e5c3377801fb18a08 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Sun, 15 Aug 2010 22:38:32 +0200 Subject: Added name of compilation unit to error/warnings generated by postProcess. --- src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 3 ++- src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java') diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 1d2efea0..2ac24a48 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -93,7 +93,8 @@ public class EclipsePatcher extends Agent { sm.addScript(ScriptBuilder.wrapMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.compiler.util.Util", "writeToDisk")) .methodToWrap(new Hook("java.io.BufferedOutputStream", "", "void", "java.io.OutputStream", "int")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "runPostCompiler", "java.io.BufferedOutputStream", "java.io.BufferedOutputStream")) + .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) .build()); } diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index 48103a98..b9bfe22b 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -123,7 +123,8 @@ public class PatchFixes { return PostCompiler.wrapOutputStream(out, "TEST", DiagnosticsReceiver.CONSOLE); } - public static BufferedOutputStream runPostCompiler(BufferedOutputStream out) throws IOException { - return new BufferedOutputStream(PostCompiler.wrapOutputStream(out, "TEST", DiagnosticsReceiver.CONSOLE)); + public static BufferedOutputStream runPostCompiler(BufferedOutputStream out, String path, String name) throws IOException { + String fileName = path + "/" + name; + return new BufferedOutputStream(PostCompiler.wrapOutputStream(out, fileName, DiagnosticsReceiver.CONSOLE)); } } -- cgit