From 28a5bce27afc1b25460d6fe3273ae2e0272dd53e Mon Sep 17 00:00:00 2001
From: aclement <aclement>
Date: Fri, 29 Apr 2005 14:03:55 +0000
Subject: More bullet proof and with added diagnostics.

---
 .../core/builder/IncrementalStateManager.java       | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java
index 8251f5c9f..4a657b5ed 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java
@@ -32,6 +32,7 @@ public class IncrementalStateManager {
 	// FIXME asc needs some memory mgmt (softrefs?) to recover memory
 	// SECRETAPI will consume more memory, so turn on at your own risk ;)  Set to 'true' when memory usage is understood
 	public  static boolean recordIncrementalStates = false;
+	public  static boolean debugIncrementalStates = false;
 	private static Hashtable incrementalStates = new Hashtable();
 	
 	public static void recordSuccessfulBuild(String buildConfig, AjState state) {
@@ -59,11 +60,27 @@ public class IncrementalStateManager {
 	
 	public static AjState findStateManagingOutputLocation(File location) {
 		Collection allStates = incrementalStates.values();
+		if (debugIncrementalStates) System.err.println("> findStateManagingOutputLocation("+location+") has "+allStates.size()+" states to look through");
 		for (Iterator iter = allStates.iterator(); iter.hasNext();) {
 			AjState element = (AjState) iter.next();
-			File outputDir = element.buildConfig.getOutputDir();
-			if (outputDir.equals(location)) return element;
+			AjBuildConfig ajbc = element.buildConfig;
+			if (ajbc==null) {
+				// FIXME asc why can it ever be null?
+				if (debugIncrementalStates) System.err.println("  No build configuration for state "+element);
+				continue;
+			}
+			File outputDir = ajbc.getOutputDir();
+			if (outputDir == null) {
+				// FIXME why can it ever be null? due to using outjar?
+				if (debugIncrementalStates) System.err.println("  output directory for "+ajbc+" is null");
+				continue;
+			}
+			if (outputDir.equals(location)) {
+				if (debugIncrementalStates) System.err.println("< findStateManagingOutputLocation("+location+") returning "+element);
+				return element;
+			}
 		}
+		if (debugIncrementalStates) System.err.println("< findStateManagingOutputLocation("+location+") returning null");
 		return null;
 	}
 	
-- 
cgit v1.2.3