From 20bd5dce06112d87261f2997c6a575662b42488f Mon Sep 17 00:00:00 2001
From: Roel Spilker <r.spilker@gmail.com>
Date: Wed, 21 Jan 2015 01:28:36 +0100
Subject: the previous basic for fix didn't really work, this one is better.

---
 src/eclipseAgent/lombok/eclipse/agent/PatchVal.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'src/eclipseAgent/lombok')

diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index 1379719d..30574ea6 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -129,8 +129,13 @@ public class PatchVal {
 		if (!isVal(local.type, scope)) return false;
 		
 		StackTraceElement[] st = new Throwable().getStackTrace();
-		if (st.length > 2 && st[2].getClassName().contains("ForStatement")) return false;
-		if (st.length > 8 && st[8].getClassName().contains("ForStatement")) return false;
+		for (int i = 0; i < st.length - 2 && i < 10; i++) {
+			if (st[i].getClassName().equals("lombok.launch.PatchFixesHider$Val")) {
+				if (st[i + 1].getClassName().equals("org.eclipse.jdt.internal.compiler.ast.LocalDeclaration") &&
+					st[i + 2].getClassName().equals("org.eclipse.jdt.internal.compiler.ast.ForStatement")) return false;
+				break;
+			}
+		}
 		
 		Expression init = local.initialization;
 		if (init == null && Reflection.initCopyField != null) {
-- 
cgit