Bug 486979 [type hierarchy] Subtype hierarchy broken when a *.java file
is open but not in a Java project (WIP)
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
index e3b247b..536ede1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -317,6 +317,7 @@
IJavaProject currentProject = null;
for (int i = 0; i < length; i++) {
loopMonitor.setWorkRemaining(length - i + 1);
+ IJavaProject nextProject = null;
try {
String resourcePath = allPotentialSubTypes[i];
@@ -340,15 +341,19 @@
currentProject = project;
potentialSubtypes = new ArrayList(5);
} else if (!currentProject.equals(project)) {
+ nextProject = project;
// build current project
buildForProject((JavaProject)currentProject, potentialSubtypes, workingCopies, localTypes, loopMonitor.split(1));
- currentProject = project;
potentialSubtypes = new ArrayList(5);
}
potentialSubtypes.add(handle);
} catch (JavaModelException e) {
continue;
+ } finally {
+ if (nextProject != null) {
+ currentProject = nextProject;
+ }
}
}