Logging to track Boot LS start/stop

This commit is contained in:
aboyko
2023-03-27 16:58:40 -04:00
parent 01caab7cac
commit ebddbc6e12
2 changed files with 9 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2022 VMware, Inc. * Copyright (c) 2022, 2023 VMware, Inc.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@@ -40,6 +40,7 @@ public class BootProjectTracker {
@Override @Override
public void classpathChanged(IJavaProject jp) { public void classpathChanged(IJavaProject jp) {
logger.log("Classpath changed for project: " + jp.getElementName());
processProject(jp); processProject(jp);
} }
}); });
@@ -56,10 +57,12 @@ public class BootProjectTracker {
private void processProject(IJavaProject jp) { private void processProject(IJavaProject jp) {
if (isSpringProject(jp)) { if (isSpringProject(jp)) {
if (springProjects.add(jp)) { if (springProjects.add(jp)) {
logger.log("Boot project ADDED: " + jp.getElementName());
fireEvent(); fireEvent();
} }
} else { } else {
if (springProjects.remove(jp)) { if (springProjects.remove(jp)) {
logger.log("Boot project REMOVED: " + jp.getElementName());
fireEvent(); fireEvent();
} }
} }

View File

@@ -35,7 +35,7 @@ public class JdtLsExtensionPlugin extends Plugin {
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
instance = this; instance = this;
super.start(context); super.start(context);
Logger logger = Logger.forEclipsePlugin(() -> this); Logger logger = Logger.forEclipsePlugin(() -> JdtLsExtensionPlugin.getInstance());
initializationFuture().thenAccept(v -> { initializationFuture().thenAccept(v -> {
Consumer<Set<IJavaProject>> l = bootProjects -> { Consumer<Set<IJavaProject>> l = bootProjects -> {
boolean currentBootProjectsPresent = !bootProjects.isEmpty(); boolean currentBootProjectsPresent = !bootProjects.isEmpty();
@@ -43,11 +43,15 @@ public class JdtLsExtensionPlugin extends Plugin {
bootProjectPresent = currentBootProjectsPresent; bootProjectPresent = currentBootProjectsPresent;
try { try {
if (bootProjectPresent) { if (bootProjectPresent) {
logger.log("About to START Boot LS since Boot project has been detected in the workspace");
JavaLanguageServerPlugin.getInstance().getClientConnection() JavaLanguageServerPlugin.getInstance().getClientConnection()
.executeClientCommand("vscode-spring-boot.ls.start"); .executeClientCommand("vscode-spring-boot.ls.start");
logger.log("Boot LS START command executed successfully");
} else { } else {
logger.log("About to STOP Boot LS since no Boot projects have been detected in the workspace");
JavaLanguageServerPlugin.getInstance().getClientConnection() JavaLanguageServerPlugin.getInstance().getClientConnection()
.executeClientCommand("vscode-spring-boot.ls.stop"); .executeClientCommand("vscode-spring-boot.ls.stop");
logger.log("Boot LS STOP command executed successfully");
} }
} catch (Exception e) { } catch (Exception e) {
logger.log(e); logger.log(e);