Skip to content

Commit

Permalink
Don't refresh org.eclipse.jdt.ls.core
Browse files Browse the repository at this point in the history
  • Loading branch information
snjeza committed Nov 9, 2023
1 parent 2412ed9 commit 4a20e73
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.ls.core.internal.IConstants;
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.osgi.container.ModuleContainer;
import org.eclipse.osgi.util.ManifestElement;
Expand Down Expand Up @@ -106,7 +107,7 @@ public static void loadBundles(Collection<String> bundleLocations) throws CoreEx
MultiStatus status = new MultiStatus(context.getBundle().getSymbolicName(), IStatus.OK, "Load bundle list", null);
Set<Bundle> bundlesToStart = new HashSet<>();
Set<Bundle> toRefresh = new HashSet<>();
FrameworkWiring frameworkWiring = context.getBundle(0).adapt(FrameworkWiring.class);
FrameworkWiring frameworkWiring = getFrameworkWiring();
for (String bundleLocation : bundleLocations) {
try {
if (StringUtils.isEmpty(bundleLocation)) {
Expand Down Expand Up @@ -205,10 +206,29 @@ private static void installBundle(BundleContext context, Set<Bundle> bundlesToSt
* @throws BundleException
*/
private static void uninstallBundle(Set<Bundle> bundlesToStart, Set<Bundle> toRefresh, Bundle bundle) throws BundleException {
bundle.uninstall();
JavaLanguageServerPlugin.logInfo("Uninstalled " + bundle.getLocation());
toRefresh.add(bundle);
bundlesToStart.remove(bundle);
if (checkBundle(bundle)) {
bundle.uninstall();
JavaLanguageServerPlugin.logInfo("Uninstalled " + bundle.getLocation());
toRefresh.add(bundle);
bundlesToStart.remove(bundle);
}
}

private static boolean checkBundle(Bundle bundle) throws BundleException {
Collection<Bundle> bundles = getFrameworkWiring().getDependencyClosure(Collections.singletonList(bundle));
for (Bundle b : bundles) {
if (IConstants.PLUGIN_ID.equals(b.getSymbolicName())) {
JavaLanguageServerPlugin.logError("Cannot refresh the " + IConstants.PLUGIN_ID + " bundle.");
return false;
}
}
return true;
}

private static FrameworkWiring getFrameworkWiring() {
BundleContext context = JavaLanguageServerPlugin.getBundleContext();
FrameworkWiring frameworkWiring = context.getBundle(0).adapt(FrameworkWiring.class);
return frameworkWiring;
}

private static Bundle[] getBundles(String symbolicName, FrameworkWiring fwkWiring) {
Expand Down

0 comments on commit 4a20e73

Please sign in to comment.