diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-01 13:53:07 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-01 13:53:07 +0100 |
commit | 199f7f74fd35462dced087280af066cf2cad7596 (patch) | |
tree | 6c0befb9bccede364c07bb843de4f4f5edb87404 /src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java | |
parent | 92e2afe9b0dccc7d0055b52d07ab3128c2adf4de (diff) | |
download | lombok-199f7f74fd35462dced087280af066cf2cad7596.tar.gz lombok-199f7f74fd35462dced087280af066cf2cad7596.tar.bz2 lombok-199f7f74fd35462dced087280af066cf2cad7596.zip |
Generalized the agent mechanism; now 1 lombok.jar can serve as the agent for BOTH netbeans AND eclipse, and is future-ready for an IntelliJ agent.
Diffstat (limited to 'src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java')
-rw-r--r-- | src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java b/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java index 2a87ad6c..bffedfc2 100644 --- a/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java +++ b/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java @@ -23,29 +23,29 @@ package lombok.netbeans.agent; import java.lang.instrument.Instrumentation; +import lombok.core.Agent; import lombok.patcher.Hook; import lombok.patcher.MethodTarget; import lombok.patcher.ScriptManager; import lombok.patcher.StackRequest; -import lombok.patcher.equinox.EquinoxClassLoader; import lombok.patcher.scripts.ScriptBuilder; -public class NetbeansPatcher { - private NetbeansPatcher() {} - - public static void agentmain(@SuppressWarnings("unused") String agentArgs, Instrumentation instrumentation) throws Exception { - registerPatchScripts(instrumentation, true); - } - - public static void premain(@SuppressWarnings("unused") String agentArgs, Instrumentation instrumentation) throws Exception { - registerPatchScripts(instrumentation, false); +/** + * This is a java-agent that patches some of netbeans's classes so that lombok is initialized as Javac TaskListener, + * allowing us to change AST nodes anytime netbeans parses source code. It also fixes some of the places in netbeans that + * can't deal with generated code. + * + * The hard work on figuring out where to patch has been done by Jan Lahoda (jlahoda@netbeans.org) + */ +public class NetbeansPatcher extends Agent { + @Override + public void runAgent(String agentArgs, Instrumentation instrumentation, boolean injected) throws Exception { + registerPatchScripts(instrumentation, injected); } private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses) { ScriptManager sm = new ScriptManager(); sm.registerTransformer(instrumentation); - EquinoxClassLoader.addPrefix("lombok."); - EquinoxClassLoader.registerScripts(sm); patchNetbeansJavac(sm); patchNetbeansMissingPositionAwareness(sm); |