From 088f7bfbba75088e59b70f3cb51aae010b1d2893 Mon Sep 17 00:00:00 2001 From: jvanderhel Date: Thu, 24 Nov 2011 21:01:09 +0100 Subject: Some more save actions fixed --- src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 11 +++++++++-- src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 14 ++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 0ad7102b..c98aea11 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -115,9 +115,16 @@ public class EclipsePatcher extends Agent { .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")) + .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$ThisQualifierVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.MethodInvocation")) + .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$ThisQualifierVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.FieldAccess")) + .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$CodeStyleVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.MethodInvocation")) + .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$CodeStyleVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.TypeDeclaration")) + .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$CodeStyleVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.QualifiedName")) + .target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.CodeStyleFix$CodeStyleVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName")) + // if a generated node has children we can just ignore them as well; + .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) .request(StackRequest.PARAM1) - .valueMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.Statement")) + .valueMethod(new Hook("lombok.eclipse.agent.PatchFixes", "returnFalse", "boolean", "java.lang.Object")) .build()); } diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index 69024afa..0fc48807 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -43,16 +43,22 @@ import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent; import org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner; public class PatchFixes { - public static boolean isGenerated(org.eclipse.jdt.core.dom.Statement statement) { + public static boolean isGenerated(org.eclipse.jdt.core.dom.ASTNode node) { boolean result = false; try { - result = ((Boolean)statement.getClass().getField("$isGenerated").get(statement)).booleanValue(); + result = ((Boolean)node.getClass().getField("$isGenerated").get(node)).booleanValue(); + if (!result && node.getParent() != null && node.getParent() instanceof org.eclipse.jdt.core.dom.QualifiedName) + result = isGenerated(node.getParent()); } catch (Exception e) { // better to assume it isn't generated } return result; } - + + public static boolean returnFalse(java.lang.Object object) { + return false; + } + public static int fixRetrieveStartingCatchPosition(int original, int start) { return original == -1 ? start : original; } @@ -216,4 +222,4 @@ public class PatchFixes { return replace; } -} +} \ No newline at end of file -- cgit From 20b729509f351c812ec2753a80364dd859b70f34 Mon Sep 17 00:00:00 2001 From: jvanderhel Date: Thu, 24 Nov 2011 21:02:50 +0100 Subject: Fix for issue 51. We now ignore unchanged generated nodes, so their position isn't used to determine insertion point --- src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index 0fc48807..fd02e0e0 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -110,19 +110,14 @@ public class PatchFixes { List modifiedChildren = new ArrayList(); for (int i=0; i