From 99b4fac271f77951c3f1c376f31a925ef84f5651 Mon Sep 17 00:00:00 2001
From: Roel Spilker <r.spilker@gmail.com>
Date: Mon, 9 May 2011 21:21:33 +0200
Subject: Recurse directories while eclipse or sts is part of the directory
 name. Solves issue 210.

---
 .../lombok/installer/eclipse/EclipseFinder.java    | 42 +++++++++++++---------
 1 file changed, 25 insertions(+), 17 deletions(-)

(limited to 'src')

diff --git a/src/installer/lombok/installer/eclipse/EclipseFinder.java b/src/installer/lombok/installer/eclipse/EclipseFinder.java
index 4aac1b54..101b6347 100644
--- a/src/installer/lombok/installer/eclipse/EclipseFinder.java
+++ b/src/installer/lombok/installer/eclipse/EclipseFinder.java
@@ -58,7 +58,7 @@ public class EclipseFinder extends IdeFinder {
 	}
 	
 	protected List<String> getSourceDirsOnWindows() {
-		return Arrays.asList("\\", "\\Program Files", System.getProperty("user.home", "."));
+		return Arrays.asList("\\", "\\Program Files", "\\Program Files (x86)", System.getProperty("user.home", "."));
 	}
 	
 	protected List<String> getSourceDirsOnMac() {
@@ -96,27 +96,35 @@ public class EclipseFinder extends IdeFinder {
 				try {
 					File f = new File(letter + ":" + possibleSource);
 					if (!f.isDirectory()) continue;
-					for (File dir : f.listFiles()) {
-						if (!dir.isDirectory()) continue;
-						try {
-							if (dir.getName().toLowerCase().contains(getDirName())) {
-								String eclipseLocation = findEclipseOnWindows1(dir);
-								if (eclipseLocation != null) {
-									try {
-										IdeLocation newLocation = createLocation(eclipseLocation);
-										if (newLocation != null) locations.add(newLocation);
-									} catch (CorruptedIdeLocationException e) {
-										problems.add(e);
-									}
-								}
-							}
-						} catch (Exception ignore) {}
-					}
+					recurseDirectory(locations, problems, f);
 				} catch (Exception ignore) {}
 			}
 		}
 	}
 	
+	private void recurseDirectory(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems, File f) {
+		//Various try/catch/ignore statements are in this for loop. Weird conditions on the disk can cause exceptions,
+		//such as an unformatted drive causing a NullPointerException on listFiles. Best action is almost invariably to just
+		//continue onwards.
+		for (File dir : f.listFiles()) {
+			if (!dir.isDirectory()) continue;
+			try {
+				if (dir.getName().toLowerCase().contains(getDirName())) {
+					String eclipseLocation = findEclipseOnWindows1(dir);
+					if (eclipseLocation != null) {
+						try {
+							IdeLocation newLocation = createLocation(eclipseLocation);
+							if (newLocation != null) locations.add(newLocation);
+						} catch (CorruptedIdeLocationException e) {
+							problems.add(e);
+						}
+					}
+					recurseDirectory(locations, problems, dir);
+				}
+			} catch (Exception ignore) {}
+		}
+	}
+	
 	/** Checks if the provided directory contains 'eclipse.exe', and if so, returns the directory, otherwise null. */
 	private String findEclipseOnWindows1(File dir) {
 		if (new File(dir, getWindowsExecutableName()).isFile()) return dir.getAbsolutePath();
-- 
cgit