Skip to content

Commit

Permalink
Merge branch 'v18.x_dev' into v18.x
Browse files Browse the repository at this point in the history
  • Loading branch information
S1artie committed Feb 25, 2019
2 parents da0ad39 + 32327bf commit 435b248
Showing 1 changed file with 9 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
package de.gebit.integrity.eclipse.classpath;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
Expand All @@ -22,7 +20,6 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.service.datalocation.Location;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

import de.gebit.integrity.eclipse.Activator;

Expand Down Expand Up @@ -137,45 +134,20 @@ private void addToList(List<IClasspathEntry> aList, String[][] someBundleNames)
}

private Bundle findBundle(String aSymbolicName) {
return findBundleRecursive(aSymbolicName, FrameworkUtil.getBundle(JavaCore.class), new HashSet<>());
}

private Bundle findBundleRecursive(String aSymbolicName, Bundle aRootBundle, Set<Bundle> someSeenBundles) {
Bundle tempBundleMatch = null;

if (aRootBundle.getBundleContext() == null) {
Bundle[] tempBundles = Platform.getBundles(aSymbolicName, null);
if (tempBundles == null) {
return null;
}

for (Bundle tempBundleCandidate : aRootBundle.getBundleContext().getBundles()) {
if (someSeenBundles.contains(tempBundleCandidate)) {
continue;
} else {
someSeenBundles.add(tempBundleCandidate);
}

if (tempBundleCandidate.getSymbolicName().equals(aSymbolicName)) {
if (tempBundleMatch != null) {
if (tempBundleMatch.getVersion().compareTo(tempBundleCandidate.getVersion()) < 0) {
// already-found matches' version is less than candidates' version
continue;
}
Bundle tempBundleMatch = null;
for (Bundle tempBundleCandidate : Platform.getBundles(aSymbolicName, null)) {
if (tempBundleMatch != null) {
if (tempBundleMatch.getVersion().compareTo(tempBundleCandidate.getVersion()) < 0) {
// already-found matches' version is less than candidates' version
continue;
}

tempBundleMatch = tempBundleCandidate;
} else {
Bundle tempRecursionCandidate
= findBundleRecursive(aSymbolicName, tempBundleCandidate, someSeenBundles);

if (tempRecursionCandidate != null) {
if (tempBundleMatch != null) {
if (tempBundleMatch.getVersion().compareTo(tempBundleCandidate.getVersion()) < 0) {
// already-found matches' version is less than candidates' version
continue;
}
}
tempBundleMatch = tempRecursionCandidate;
}
tempBundleMatch = tempBundleCandidate;
}
}

Expand Down

0 comments on commit 435b248

Please sign in to comment.