aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2011-11-28 10:09:00 -0800
committerReinier Zwitserloot <reinier@zwitserloot.com>2011-11-28 10:09:00 -0800
commit6d6a191c67827b626c67ddfbce071c17be58723b (patch)
tree746624d260e6fe336833463ed732096d4faf7b31 /src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
parenteb8af8128d12859e8b3bed7b83d26c2dd20c09f4 (diff)
parent20b729509f351c812ec2753a80364dd859b70f34 (diff)
downloadlombok-6d6a191c67827b626c67ddfbce071c17be58723b.tar.gz
lombok-6d6a191c67827b626c67ddfbce071c17be58723b.tar.bz2
lombok-6d6a191c67827b626c67ddfbce071c17be58723b.zip
Merge pull request #15 from jvanderhel/Issue_51
Proposed fix for Issue 51 and 301
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
index 69024afa..fd02e0e0 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;
}
@@ -104,19 +110,14 @@ public class PatchFixes {
List<RewriteEvent> modifiedChildren = new ArrayList<RewriteEvent>();
for (int i=0; i<children.length; i++) {
RewriteEvent child = children[i];
- boolean isGenerated = false;
- try {
- org.eclipse.jdt.core.dom.ASTNode originalValue = (org.eclipse.jdt.core.dom.ASTNode)child.getOriginalValue();
- isGenerated = (Boolean) originalValue.getClass().getField("$isGenerated").get(originalValue);
- } catch (Exception e) {
- // If this fails, better to break some refactor scripts than to crash eclipse.
- }
- if (isGenerated
- && (child.getChangeKind() == RewriteEvent.REPLACED || child.getChangeKind() == RewriteEvent.REMOVED)
- && child.getOriginalValue() instanceof org.eclipse.jdt.core.dom.MethodDeclaration
- ) {
- if (child.getNewValue() != null)
+ boolean isGenerated = isGenerated( (org.eclipse.jdt.core.dom.ASTNode)child.getOriginalValue() );
+ if (isGenerated) {
+ if ((child.getChangeKind() == RewriteEvent.REPLACED || child.getChangeKind() == RewriteEvent.REMOVED)
+ && child.getOriginalValue() instanceof org.eclipse.jdt.core.dom.MethodDeclaration
+ && child.getNewValue() != null
+ ) {
modifiedChildren.add(new NodeRewriteEvent(null, child.getNewValue()));
+ }
} else {
newChildren.add(child);
}
@@ -216,4 +217,4 @@ public class PatchFixes {
return replace;
}
-}
+} \ No newline at end of file