aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok
diff options
context:
space:
mode:
authorjvanderhel <Jappe.vanderhel@gmail.com>2011-11-13 00:24:36 +0100
committerjvanderhel <Jappe.vanderhel@gmail.com>2011-11-13 00:24:36 +0100
commitfd736cc76f6b1b505d73173f270100161988338d (patch)
treefc4dcf4c2a4ebc699cf0348aaba27fa740bc749b /src/eclipseAgent/lombok
parent1950820d35c1653389a22bddfa3916e125d4bc24 (diff)
downloadlombok-fd736cc76f6b1b505d73173f270100161988338d.tar.gz
lombok-fd736cc76f6b1b505d73173f270100161988338d.tar.bz2
lombok-fd736cc76f6b1b505d73173f270100161988338d.zip
disabling lombok for all postsavelisteners proved to cause some postsave actions to make the wrong decisions.
Patching ControlStatementFinder solves the same problem, with less side effects
Diffstat (limited to 'src/eclipseAgent/lombok')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java17
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java10
2 files changed, 21 insertions, 6 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index efeca326..3a85c6e9 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -106,12 +106,17 @@ public class EclipsePatcher extends Agent {
.callToWrap(new Hook("org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil", "parseCompilationUnit", "org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration", "char[]", "java.util.Map", "boolean"))
.symbol("lombok.disable")
.build());
-
- sm.addScript(ScriptBuilder.setSymbolDuringMethodCall()
- .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CleanUpPostSaveListener", "createAst"))
- .callToWrap(new Hook("org.eclipse.jdt.core.dom.ASTParser", "createAST", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.core.runtime.IProgressMonitor"))
- .symbol("lombok.disable")
- .build());
+
+ sm.addScript(ScriptBuilder.exitEarly()
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.DoStatement"))
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.EnhancedForStatement"))
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.ForStatement"))
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.IfStatement"))
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.WhileStatement"))
+ .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.Statement"))
+ .request(StackRequest.PARAM1)
+ .valueMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.Statement"))
+ .build());
}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
index 6d5fdaec..8da7f668 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
@@ -41,6 +41,16 @@ import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner;
public class PatchFixes {
+ public static boolean isGenerated(org.eclipse.jdt.core.dom.Statement statement) {
+ boolean result = false;
+ try {
+ result = ((Boolean)statement.getClass().getField("$isGenerated").get(statement)).booleanValue();
+ } catch (Exception e) {
+ // better to assume it isn't generated
+ }
+ return result;
+ }
+
public static int fixRetrieveStartingCatchPosition(int original, int start) {
return original == -1 ? start : original;
}