debugger: simplify agent path resolution

only two modes: agent is bundled with plugin and running from sources
running from sources is actually running from sources, but not from dev server (where real plugin layout is available, so no need)

this change implicitly downloads agent if Bazel build delegation is active (so, no .class files, just .jar)

GitOrigin-RevId: f1f6d837eeef656246616cbdfcbc2440f2d95222
This commit is contained in:
Leonid Shalupov
2025-08-25 10:56:13 +00:00
committed by intellij-monorepo-bot
parent 82a7339a70
commit cc6ce683ea
@@ -19,6 +19,7 @@ import com.intellij.execution.JavaExecutionUtil;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.execution.configurations.ParametersList;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.idea.AppMode;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.PathManager;
@@ -364,16 +365,11 @@ public final class AsyncStacksUtils {
@NativePath
private static @Nullable String getAgentArtifactPath(@Nullable Project project, @Nullable Disposable disposable) {
String relevantJarsRoot = PathManager.getArchivedCompliedClassesLocation();
Path classesRoot = Path.of(PathUtil.getJarPathForClass(DebuggerManagerImpl.class));
// isDirectory(classesRoot) is used instead of `PluginManagerCore.isRunningFromSources()`
// because we want to use installer's layout when running "IDEA (dev build)" run configuration
// where the layout is quite the same as in installers.
// but `PluginManagerCore.isRunningFromSources()` still returns `true` in this case
if (Files.isDirectory(classesRoot) || (relevantJarsRoot != null && classesRoot.startsWith(relevantJarsRoot))) {
if (PluginManagerCore.isRunningFromSources() && !AppMode.isDevServer()) {
return getArtifactPathForDownloadedAgent(project, disposable);
}
else {
Path classesRoot = Path.of(PathUtil.getJarPathForClass(DebuggerManagerImpl.class));
return getArtifactPathForBundledAgent(classesRoot, project, disposable);
}
}