Bug 547217 - UI freezes on
FindClassResolutionsOperation.findValidPackagesContainingSimpleType

Reverted findValidPackagesContainingSimpleType() to search only in
existing Java workspace projects and not in the entire platform.
Searching in the entire platform kills the (currently synchronous)
content assist by freezing UI.

Change-Id: Ib6a885b98c4652ddca71c2ee3f32c6c49e77e721
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/FindClassResolutionsOperation.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/FindClassResolutionsOperation.java
index cf98d77..fc1fbe9 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/FindClassResolutionsOperation.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/FindClassResolutionsOperation.java
@@ -256,10 +256,23 @@
 			ImportPackageSpecification[] importPkgs, Set<IPackageFragment> packagesToExport, IProgressMonitor monitor) {
 		SubMonitor subMonitor = SubMonitor.convert(monitor);
 
+		IPluginModelBase[] activeModels = PluginRegistry.getActiveModels();
+		Set<IJavaProject> javaProjects = new LinkedHashSet<>(activeModels.length * 2);
+
+		for (IPluginModelBase model : activeModels) {
+			IResource resource = model.getUnderlyingResource();
+			if (resource != null && resource.isAccessible()) {
+				IJavaProject javaProject = JavaCore.create(resource.getProject());
+				if (javaProject.exists()) {
+					javaProjects.add(javaProject);
+				}
+			}
+		}
 		final IJavaProject currentJavaProject = JavaCore.create(fProject);
+		javaProjects.remove(currentJavaProject); // no need to search in current project itself
 
 		try {
-			IJavaSearchScope searchScope = PDESearchScope.create();
+			IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(javaProjects.toArray(new IJavaElement[javaProjects.size()]));
 
 			final Map<String, IPackageFragment> packages = new HashMap<>();
 			final Map<String, String> qualifiedTypeNames = new HashMap<>();