Bug 507098 - No debug sources if workspace contains a feature project

Commit 6f0be40dffe59bd9768a90525acf6166e566effb coming from bug 473696
changed the behavior of the getAffectedProjects() so that it returns now
also feature (non-Java!) projects. This breaks PDESourcePathProvider
which tries to create and resolve Java projects (resulting in Java Model
Exception for feature projects). To avoid this, make sure the new code
adding features to the affected projects list is not used from
PDESourcePathProvider.computeUnresolvedClasspath().

Change-Id: Ifb7aea0ea3621ebe82142736e18ccde7546248be
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchPluginValidator.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchPluginValidator.java
index 0e509fa..d33d117 100644
--- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchPluginValidator.java
+++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchPluginValidator.java
@@ -89,7 +89,18 @@
 		return set;
 	}
 
+	/**
+	 * @return all affected projects, independently of their nature
+	 */
 	public static IProject[] getAffectedProjects(ILaunchConfiguration config) throws CoreException {
+		return getAffectedProjects(config, true);
+	}
+
+	/**
+	 * @param addFeatures {@code true} to add <b>feature</b> projects (if any) too, {@code false} to include only affected <b>Java</b> projects
+	 * @return affected Java and feature projects (last one optional)
+	 */
+	public static IProject[] getAffectedProjects(ILaunchConfiguration config, boolean addFeatures) throws CoreException {
 		// if restarting, no need to check projects for errors
 		if (config.getAttribute(IPDEConstants.RESTART, false))
 			return new IProject[0];
@@ -101,11 +112,13 @@
 				projects.add(project);
 		}
 
-		// add workspace feature project too (if any)
-		IProject[] allProjects = PDECore.getWorkspace().getRoot().getProjects();
-		for (int i = 0; i < allProjects.length; i++) {
-			if (WorkspaceModelManager.isFeatureProject(allProjects[i]) && !projects.contains(allProjects[i]))
-				projects.add(allProjects[i]);
+		if (addFeatures) {
+			// add workspace feature project too (if any)
+			IProject[] allProjects = PDECore.getWorkspace().getRoot().getProjects();
+			for (int i = 0; i < allProjects.length; i++) {
+				if (WorkspaceModelManager.isFeatureProject(allProjects[i]) && !projects.contains(allProjects[i]))
+					projects.add(allProjects[i]);
+			}
 		}
 		// add fake "Java Search" project
 		SearchablePluginsManager manager = PDECore.getDefault().getSearchablePluginsManager();
diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/PDESourcePathProvider.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/PDESourcePathProvider.java
index 7f77e81..29ea7bc 100644
--- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/PDESourcePathProvider.java
+++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/PDESourcePathProvider.java
@@ -83,7 +83,7 @@
 	 *
 	 */
 	private IProject[] getJavaProjects(ILaunchConfiguration configuration) throws CoreException {
-		IProject[] projects = LaunchPluginValidator.getAffectedProjects(configuration);
+		IProject[] projects = LaunchPluginValidator.getAffectedProjects(configuration, false);
 		return PDELaunchingPlugin.getWorkspace().computeProjectOrder(projects).projects;
 	}