aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.classpath1
-rw-r--r--buildScripts/compile.ant.xml3
-rw-r--r--contrib/ecjsrc-3.5.1.zipbin0 -> 1297603 bytes
-rw-r--r--deps/lombok/ecj-3.5.1.jarbin0 -> 1674737 bytes
-rw-r--r--src/core/lombok/core/AnnotationProcessor.java144
-rw-r--r--src/core/lombok/core/SpiLoadUtil.java6
-rw-r--r--src/core/lombok/eclipse/Eclipse.java42
-rw-r--r--src/core/lombok/eclipse/HandlerLibrary.java4
-rw-r--r--src/core/lombok/eclipse/TransformEclipseAST.java16
-rw-r--r--src/core/lombok/eclipse/apt/Processor.java79
-rw-r--r--src/core/lombok/javac/apt/Processor.java34
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java27
12 files changed, 292 insertions, 64 deletions
diff --git a/.classpath b/.classpath
index 953e7d9a..82336e52 100644
--- a/.classpath
+++ b/.classpath
@@ -9,6 +9,7 @@
<classpathentry kind="src" path="test/delombok/src"/>
<classpathentry kind="src" path="test/core/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="lib" path="deps/lombok/ecj-3.5.1.jar" sourcepath="contrib/ecjsrc-3.5.1.zip"/>
<classpathentry kind="lib" path="deps/lombok/eclipse/org.eclipse.jdt.core_3.5.0.v_963.jar"/>
<classpathentry kind="lib" path="deps/lombok/eclipse/org.eclipse.jdt.ui_3.5.1.r351_v20090821-0800.jar"/>
<classpathentry kind="lib" path="deps/lombok/eclipse/org.eclipse.core.runtime_3.5.0.v20090525.jar"/>
diff --git a/buildScripts/compile.ant.xml b/buildScripts/compile.ant.xml
index 726cfcb4..7f8e2ba7 100644
--- a/buildScripts/compile.ant.xml
+++ b/buildScripts/compile.ant.xml
@@ -150,7 +150,7 @@ lombok code including the various agents.
<mkdir dir="build/lombok/META-INF" />
<mkdir dir="build/lombok/META-INF/services" />
- <echo file="build/lombok/META-INF/services/javax.annotation.processing.Processor">lombok.javac.apt.Processor</echo>
+ <echo file="build/lombok/META-INF/services/javax.annotation.processing.Processor">lombok.core.AnnotationProcessor</echo>
</target>
<target name="dist" description="Builds THE lombok.jar file which contains everything" depends="compile, version, -unpackLibs">
@@ -162,6 +162,7 @@ lombok code including the various agents.
<fileset dir="." includes="LICENCE" />
<manifest>
<attribute name="Premain-Class" value="lombok.core.Agent" />
+ <attribute name="Agent-Class" value="lombok.core.Agent" />
<attribute name="Can-Redefine-Classes" value="true" />
<attribute name="Main-Class" value="lombok.core.Main" />
<attribute name="Lombok-Version" value="${lombok.version}" />
diff --git a/contrib/ecjsrc-3.5.1.zip b/contrib/ecjsrc-3.5.1.zip
new file mode 100644
index 00000000..25041d24
--- /dev/null
+++ b/contrib/ecjsrc-3.5.1.zip
Binary files differ
diff --git a/deps/lombok/ecj-3.5.1.jar b/deps/lombok/ecj-3.5.1.jar
new file mode 100644
index 00000000..c32db12c
--- /dev/null
+++ b/deps/lombok/ecj-3.5.1.jar
Binary files differ
diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java
new file mode 100644
index 00000000..19748611
--- /dev/null
+++ b/src/core/lombok/core/AnnotationProcessor.java
@@ -0,0 +1,144 @@
+package lombok.core;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.Processor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+
+@SupportedAnnotationTypes("*")
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class AnnotationProcessor extends AbstractProcessor {
+ private static String trace(Throwable t) {
+ StringWriter w = new StringWriter();
+ t.printStackTrace(new PrintWriter(w, true));
+ return w.toString();
+ }
+
+ static abstract class ProcessorDescriptor {
+ abstract boolean want(ProcessingEnvironment procEnv, List<String> delayedWarnings);
+ abstract String getName();
+ abstract boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv);
+ }
+
+ private final List<ProcessorDescriptor> registered = Arrays.asList(new JavacDescriptor(), new EcjDescriptor());
+ private final List<ProcessorDescriptor> active = new ArrayList<ProcessorDescriptor>();
+ private final List<String> delayedWarnings = new ArrayList<String>();
+
+ static class JavacDescriptor extends ProcessorDescriptor {
+ private Processor processor;
+
+ @Override String getName() {
+ return "sun/apple javac 1.6";
+ }
+
+ @Override boolean want(ProcessingEnvironment procEnv, List<String> delayedWarnings) {
+ if (!procEnv.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) return false;
+
+ try {
+ processor = (Processor)Class.forName("lombok.javac.apt.Processor").newInstance();
+ } catch (Exception e) {
+ delayedWarnings.add("You found a bug in lombok; lombok.javac.apt.Processor is not available. Lombok will not run during this compilation: " + trace(e));
+ return false;
+ } catch (NoClassDefFoundError e) {
+ delayedWarnings.add("Can't load javac processor due to (most likely) a class loader problem: " + trace(e));
+ return false;
+ }
+
+ processor.init(procEnv);
+ return true;
+ }
+
+ @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ return processor.process(annotations, roundEnv);
+ }
+ }
+
+ static class EcjDescriptor extends ProcessorDescriptor {
+ private Processor processor;
+
+ @Override String getName() {
+ return "ECJ";
+ }
+
+ @Override boolean want(ProcessingEnvironment procEnv, List<String> delayedWarnings) {
+ if (!procEnv.getClass().getName().startsWith("org.eclipse.jdt.")) return false;
+ boolean inEclipse;
+ try {
+ Class.forName("org.eclipse.core.runtime.Platform"); //if this works, we're in eclipse.
+ inEclipse = true;
+ } catch (ClassNotFoundException e) {
+ inEclipse = false; //We're in ecj.
+ }
+
+ if (inEclipse) {
+ delayedWarnings.add("You should not install lombok.jar as an annotation processor in eclipse. Instead, run lombok.jar as a java application and follow the instructions.");
+ return false;
+ }
+
+ try {
+ processor = (Processor)Class.forName("lombok.eclipse.apt.Processor").newInstance();
+ } catch (Exception e) {
+ delayedWarnings.add("You found a bug in lombok; lombok.eclipse.apt.Processor is not available. Lombok will not run during this compilation: " + trace(e));
+ return false;
+ } catch (NoClassDefFoundError e) {
+ delayedWarnings.add("Can't load eclipse processor due to (most likely) a class loader problem: " + trace(e));
+ return false;
+ }
+
+ processor.init(procEnv);
+ return true;
+ }
+
+ @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ return processor.process(annotations, roundEnv);
+ }
+ }
+
+ @Override public void init(ProcessingEnvironment procEnv) {
+ super.init(procEnv);
+ for (ProcessorDescriptor proc : registered) {
+ if (proc.want(procEnv, delayedWarnings)) active.add(proc);
+ }
+
+ if (active.isEmpty() && delayedWarnings.isEmpty()) {
+ StringBuilder supported = new StringBuilder();
+ for (ProcessorDescriptor proc : registered) {
+ if (supported.length() > 0) supported.append(", ");
+ supported.append(proc.getName());
+ }
+ procEnv.getMessager().printMessage(Kind.WARNING, String.format("You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.\n" +
+ "Your processor is: %s\nLombok supports: %s", procEnv.getClass().getName(), supported));
+ }
+ }
+
+ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!delayedWarnings.isEmpty()) {
+ Set<? extends Element> rootElements = roundEnv.getRootElements();
+ if (!rootElements.isEmpty()) {
+ Element firstRoot = rootElements.iterator().next();
+ for (String warning : delayedWarnings) processingEnv.getMessager().printMessage(Kind.WARNING, warning, firstRoot);
+ delayedWarnings.clear();
+ }
+ }
+
+ boolean handled = false;
+ for (ProcessorDescriptor proc : active) {
+ handled |= proc.process(annotations, roundEnv);
+ }
+
+ return handled;
+ }
+}
diff --git a/src/core/lombok/core/SpiLoadUtil.java b/src/core/lombok/core/SpiLoadUtil.java
index c068bf61..143cba13 100644
--- a/src/core/lombok/core/SpiLoadUtil.java
+++ b/src/core/lombok/core/SpiLoadUtil.java
@@ -90,7 +90,8 @@ public class SpiLoadUtil {
* @param loader The classloader object to use to both the spi discovery files, as well as the loader to use
* to make the returned instances.
*/
- public static <C> Iterable<C> findServices(final Class<C> target, final ClassLoader loader) throws IOException {
+ public static <C> Iterable<C> findServices(final Class<C> target, ClassLoader loader) throws IOException {
+ if (loader == null) loader = ClassLoader.getSystemClassLoader();
Enumeration<URL> resources = loader.getResources("META-INF/services/" + target.getName());
final Set<String> entries = new LinkedHashSet<String>();
while (resources.hasMoreElements()) {
@@ -99,6 +100,7 @@ public class SpiLoadUtil {
}
final Iterator<String> names = entries.iterator();
+ final ClassLoader fLoader = loader;
return new Iterable<C> () {
@Override public Iterator<C> iterator() {
return new Iterator<C>() {
@@ -108,7 +110,7 @@ public class SpiLoadUtil {
@Override public C next() {
try {
- return target.cast(Class.forName(names.next(), true, loader).newInstance());
+ return target.cast(Class.forName(names.next(), true, fLoader).newInstance());
} catch (Throwable t) {
throw Lombok.sneakyThrow(t);
}
diff --git a/src/core/lombok/eclipse/Eclipse.java b/src/core/lombok/eclipse/Eclipse.java
index 3adaf417..019b37fd 100644
--- a/src/core/lombok/eclipse/Eclipse.java
+++ b/src/core/lombok/eclipse/Eclipse.java
@@ -30,7 +30,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import lombok.Lombok;
import lombok.core.AnnotationValues;
import lombok.core.TypeLibrary;
import lombok.core.TypeResolver;
@@ -105,18 +104,36 @@ public class Eclipse {
* Generates an error in the Eclipse error log. Note that most people never look at it!
*/
public static void error(CompilationUnitDeclaration cud, String message, String bundleName, Throwable error) {
- Bundle bundle = Platform.getBundle(bundleName);
- if (bundle == null) {
- System.err.printf("Can't find bundle %s while trying to report error:\n%s\n", bundleName, message);
- return;
+ try {
+ new EclipseWorkspaceLogger().error(message, bundleName, error);
+ } catch (NoClassDefFoundError e) { //standalone ecj does not jave Platform, ILog, IStatus, and friends.
+ new TerminalLogger().error(message, bundleName, error);
}
-
- ILog log = Platform.getLog(bundle);
-
- log.log(new Status(IStatus.ERROR, bundleName, message, error));
if (cud != null) EclipseAST.addProblemToCompilationResult(cud, false, message + " - See error log.", 0, 0);
}
+ private static class TerminalLogger {
+ @SuppressWarnings("unused") //to match signature of EclipseWorkspaceLogger.
+ void error(String message, String bundleName, Throwable error) {
+ System.err.println(message);
+ error.printStackTrace();
+ }
+ }
+
+ private static class EclipseWorkspaceLogger {
+ void error(String message, String bundleName, Throwable error) {
+ Bundle bundle = Platform.getBundle(bundleName);
+ if (bundle == null) {
+ System.err.printf("Can't find bundle %s while trying to report error:\n%s\n", bundleName, message);
+ return;
+ }
+
+ ILog log = Platform.getLog(bundle);
+
+ log.log(new Status(IStatus.ERROR, bundleName, message, error));
+ }
+ }
+
/**
* For 'speed' reasons, Eclipse works a lot with char arrays. I have my doubts this was a fruitful exercise,
* but we need to deal with it. This turns [[java][lang][String]] into "java.lang.String".
@@ -454,7 +471,7 @@ public class Eclipse {
try {
generatedByField = ASTNode.class.getDeclaredField("$generatedBy");
} catch (Throwable t) {
- throw Lombok.sneakyThrow(t);
+ //ignore - no $generatedBy exists when running in ecj.
}
}
@@ -462,7 +479,8 @@ public class Eclipse {
try {
return (ASTNode) generatedByField.get(node);
} catch (Exception t) {
- throw Lombok.sneakyThrow(t);
+ //ignore - no $generatedBy exists when running in ecj.
+ return null;
}
}
@@ -474,7 +492,7 @@ public class Eclipse {
try {
generatedByField.set(node, source);
} catch (Exception t) {
- throw Lombok.sneakyThrow(t);
+ //ignore - no $generatedBy exists when running in ecj.
}
return node;
diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java
index 36c41504..1be01459 100644
--- a/src/core/lombok/eclipse/HandlerLibrary.java
+++ b/src/core/lombok/eclipse/HandlerLibrary.java
@@ -96,7 +96,7 @@ public class HandlerLibrary {
/** Uses SPI Discovery to find implementations of {@link EclipseAnnotationHandler}. */
@SuppressWarnings("unchecked") private static void loadAnnotationHandlers(HandlerLibrary lib) {
try {
- for (EclipseAnnotationHandler<?> handler : SpiLoadUtil.findServices(EclipseAnnotationHandler.class)) {
+ for (EclipseAnnotationHandler<?> handler : SpiLoadUtil.findServices(EclipseAnnotationHandler.class, EclipseAnnotationHandler.class.getClassLoader())) {
try {
Class<? extends Annotation> annotationClass =
SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class);
@@ -117,7 +117,7 @@ public class HandlerLibrary {
/** Uses SPI Discovery to find implementations of {@link EclipseASTVisitor}. */
private static void loadVisitorHandlers(HandlerLibrary lib) {
try {
- for (EclipseASTVisitor visitor : SpiLoadUtil.findServices(EclipseASTVisitor.class)) {
+ for (EclipseASTVisitor visitor : SpiLoadUtil.findServices(EclipseASTVisitor.class, EclipseASTVisitor.class.getClassLoader())) {
lib.visitorHandlers.add(visitor);
}
} catch (Throwable t) {
diff --git a/src/core/lombok/eclipse/TransformEclipseAST.java b/src/core/lombok/eclipse/TransformEclipseAST.java
index 3b5482ca..dff11442 100644
--- a/src/core/lombok/eclipse/TransformEclipseAST.java
+++ b/src/core/lombok/eclipse/TransformEclipseAST.java
@@ -57,10 +57,10 @@ public class TransformEclipseAST {
static {
Field f = null;
- HandlerLibrary l = null;
+ HandlerLibrary h = null;
+
try {
- l = HandlerLibrary.load();
- f = CompilationUnitDeclaration.class.getDeclaredField("$lombokAST");
+ h = HandlerLibrary.load();
} catch (Throwable t) {
try {
Eclipse.error(null, "Problem initializing lombok", t);
@@ -70,8 +70,14 @@ public class TransformEclipseAST {
}
disableLombok = true;
}
+ try {
+ f = CompilationUnitDeclaration.class.getDeclaredField("$lombokAST");
+ } catch (Throwable t) {
+ //I guess we're in an ecj environment; we'll just not cache stuff then.
+ }
+
astCacheField = f;
- handlers = l;
+ handlers = h;
}
public static void transform_swapped(CompilationUnitDeclaration ast, Parser parser) {
@@ -86,7 +92,7 @@ public class TransformEclipseAST {
* Eclipse's parsers often operate in diet mode, which means many parts of the AST have been left blank.
* Be ready to deal with just about anything being null, such as the Statement[] arrays of the Method AST nodes.
*
- * @param parser The Eclipse parser object that generated the AST.
+ * @param parser The Eclipse parser object that generated the AST. Not actually used; mostly there to satisfy parameter rules for lombok.patcher scripts.
* @param ast The AST node belonging to the compilation unit (java speak for a single source file).
*/
public static void transform(Parser parser, CompilationUnitDeclaration ast) {
diff --git a/src/core/lombok/eclipse/apt/Processor.java b/src/core/lombok/eclipse/apt/Processor.java
new file mode 100644
index 00000000..1457589e
--- /dev/null
+++ b/src/core/lombok/eclipse/apt/Processor.java
@@ -0,0 +1,79 @@
+package lombok.eclipse.apt;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+
+import lombok.eclipse.TransformEclipseAST;
+import lombok.patcher.inject.LiveInjector;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfType;
+
+@SupportedAnnotationTypes("*")
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class Processor extends AbstractProcessor {
+ private BaseProcessingEnvImpl processingEnv;
+
+ @Override public synchronized void init(ProcessingEnvironment procEnv) {
+ super.init(procEnv);
+
+ this.processingEnv = (BaseProcessingEnvImpl)procEnv;
+
+ new LiveInjector().injectSelf();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ try {
+ Field unitsField = roundEnv.getClass().getDeclaredField("_units");
+ unitsField.setAccessible(true);
+ CompilationUnitDeclaration[] roots = (CompilationUnitDeclaration[]) unitsField.get(roundEnv);
+
+ if (roots == null) System.out.println("roots is null: " + roundEnv.processingOver());
+ else System.out.println("rootscount: " + roots.length);
+
+ if (roots != null) for (CompilationUnitDeclaration cud : roots) {
+ TransformEclipseAST.transform(null, cud);
+ }
+
+ Field f = processingEnv.getLookupEnvironment().getClass().getDeclaredField("stepCompleted");
+ f.setAccessible(true);
+ f.set(processingEnv.getLookupEnvironment(), 1);
+ if (roots != null) for (CompilationUnitDeclaration cud : roots) {
+ Field f2 = cud.scope.fPackage.getClass().getDeclaredField("knownTypes");
+ f2.setAccessible(true);
+ HashtableOfType turd = (HashtableOfType) f2.get(cud.scope.fPackage);
+ int idx = 0;
+ for (char[] x : turd.keyTable) {
+ if (CharOperation.equals(x, cud.types[0].name)) turd.keyTable[idx] = null;
+ idx++;
+ }
+ Method m = HashtableOfType.class.getDeclaredMethod("rehash");
+ m.setAccessible(true);
+ m.invoke(turd);
+ cud.scope = null;
+ cud.types[0].binding = null;
+ cud.types[0].scope = null;
+ processingEnv.getLookupEnvironment().buildTypeBindings(cud, null);
+ }
+
+ processingEnv.getLookupEnvironment().completeTypeBindings();
+ return false;
+ } catch (Throwable t) {
+ System.out.println("Scream and shout!");
+ t.printStackTrace();
+ return false;
+ }
+ }
+}
diff --git a/src/core/lombok/javac/apt/Processor.java b/src/core/lombok/javac/apt/Processor.java
index b779a680..31cedf03 100644
--- a/src/core/lombok/javac/apt/Processor.java
+++ b/src/core/lombok/javac/apt/Processor.java
@@ -32,7 +32,6 @@ import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
import lombok.javac.JavacTransformer;
@@ -55,47 +54,20 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class Processor extends AbstractProcessor {
- private ProcessingEnvironment rawProcessingEnv;
private JavacProcessingEnvironment processingEnv;
private JavacTransformer transformer;
private Trees trees;
- private String errorToShow;
/** {@inheritDoc} */
@Override public void init(ProcessingEnvironment procEnv) {
super.init(procEnv);
- this.rawProcessingEnv = procEnv;
- String className = procEnv.getClass().getName();
- if (className.startsWith("org.eclipse.jdt.")) {
- errorToShow = "You should not install lombok.jar as an annotation processor in eclipse. Instead, run lombok.jar as a java application and follow the instructions.";
- procEnv.getMessager().printMessage(Kind.WARNING, errorToShow);
- this.processingEnv = null;
- } else if (!procEnv.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) {
- procEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so lombok will not work properly.\n" +
- "Your processor class is: " + className);
- this.processingEnv = null;
- this.errorToShow = null;
- } else {
- this.processingEnv = (JavacProcessingEnvironment) procEnv;
- transformer = new JavacTransformer(procEnv.getMessager());
- trees = Trees.instance(procEnv);
- this.errorToShow = null;
- }
+ this.processingEnv = (JavacProcessingEnvironment) procEnv;
+ transformer = new JavacTransformer(procEnv.getMessager());
+ trees = Trees.instance(procEnv);
}
/** {@inheritDoc} */
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (processingEnv == null) {
- if (errorToShow != null) {
- Set<? extends Element> rootElements = roundEnv.getRootElements();
- if (!rootElements.isEmpty()) {
- rawProcessingEnv.getMessager().printMessage(Kind.WARNING, errorToShow, rootElements.iterator().next());
- errorToShow = null;
- }
- }
- return false;
- }
-
IdentityHashMap<JCCompilationUnit, Void> units = new IdentityHashMap<JCCompilationUnit, Void>();
for (Element element : roundEnv.getRootElements()) {
JCCompilationUnit unit = toUnit(element);
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index 741328f1..ce494daa 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -45,20 +45,25 @@ import lombok.patcher.scripts.ScriptBuilder;
public class EclipsePatcher extends Agent {
@Override
public void runAgent(String agentArgs, Instrumentation instrumentation, boolean injected) throws Exception {
- registerPatchScripts(instrumentation, injected);
+ registerPatchScripts(instrumentation, injected, injected);
}
- private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses) {
+ private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses, boolean ecjOnly) {
ScriptManager sm = new ScriptManager();
sm.registerTransformer(instrumentation);
- EquinoxClassLoader.addPrefix("lombok.");
- EquinoxClassLoader.registerScripts(sm);
+ if (!ecjOnly) {
+ EquinoxClassLoader.addPrefix("lombok.");
+ EquinoxClassLoader.registerScripts(sm);
+ }
- patchLombokizeAST(sm);
patchAvoidReparsingGeneratedCode(sm);
- patchCatchReparse(sm);
- patchSetGeneratedFlag(sm);
- patchHideGeneratedNodes(sm);
+
+ if (!ecjOnly) {
+ patchLombokizeAST(sm);
+ patchCatchReparse(sm);
+ patchSetGeneratedFlag(sm);
+ patchHideGeneratedNodes(sm);
+ }
if (reloadExistingClasses) sm.reloadClasses(instrumentation);
}
@@ -167,14 +172,14 @@ 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", "(Ljava/lang/Object;)Z"))
- .transplant().request(StackRequest.PARAM1).build());
+ .request(StackRequest.PARAM1).build());
sm.addScript(ScriptBuilder.exitEarly()
.target(new MethodTarget(PARSER_SIG1, "parse", "void",
"org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration",
"org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration", "boolean"))
.decisionMethod(new Hook("lombok/eclipse/agent/PatchFixes", "checkBit24", "(Ljava/lang/Object;)Z"))
- .transplant().request(StackRequest.PARAM1).build());
+ .request(StackRequest.PARAM1).build());
sm.addScript(ScriptBuilder.exitEarly()
.target(new MethodTarget(PARSER_SIG1, "parse", "void",
@@ -182,7 +187,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", "(Ljava/lang/Object;)Z"))
- .transplant().request(StackRequest.PARAM1).build());
+ .request(StackRequest.PARAM1).build());
}
private static void patchLombokizeAST(ScriptManager sm) {