From aab0ef5f5a308bb755e07bc082b5f5c7c5bbae63 Mon Sep 17 00:00:00 2001 From: Alexander Koshevoy Date: Wed, 22 Oct 2025 16:53:04 +0200 Subject: [PATCH] =?UTF-8?q?[jps]=20IDEA-376790=20Generalize=20path=20mappi?= =?UTF-8?q?ng=20for=20WSL=20and=20non=E2=80=91local=20Eel=20projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unifies path‑mapper selection so builds work consistently for remote Eel projects in addition to WSL. When the "wsl.use.remote.agent.for.nio.filesystem" registry key is `false`, WSL‑over‑Eel is disabled, and we intentionally fall back to legacy `WslDistribution` mapping. This preserves existing local/WSL behavior while enabling remote Eel workflows. These changes also address a likely issue in `com.intellij.compiler.server.BuildManager.scheduleBuild()` method where `currentFSChanges` previously relied on a WSL‑only mapper. It now uses the unified mapper that supports both Eel and the alternate WSL path conversion. GitOrigin-RevId: ff5c0ad873f513c0e34b3dc01a8b79904c8e7650 --- .../compiler/server/BuildManager.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index f795c25d9fee..cef89df212f4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -515,12 +515,13 @@ public final class BuildManager implements Disposable { boolean changed = data.addDeleted(Iterators.filter(paths.deleted(), PATH_FILTER::test)); changed |= data.addChanged(Iterators.filter(paths.changed(), PATH_FILTER::test)); if (changed) { - RequestFuture future = myBuildsInProgress.get(entry.getKey()); + final String projectPath = entry.getKey(); + RequestFuture future = myBuildsInProgress.get(projectPath); if (future != null && !future.isCancelled() && !future.isDone()) { final UUID sessionId = future.getRequestID(); final Channel channel = myMessageDispatcher.getConnectedChannel(sessionId); if (channel != null) { - CmdlineRemoteProto.Message.ControllerMessage.FSEvent event = data.createNextEvent(wslPathMapper(entry.getKey())); + CmdlineRemoteProto.Message.ControllerMessage.FSEvent event = data.createNextEvent(getPathMapperForProject(projectPath)); final CmdlineRemoteProto.Message.ControllerMessage message = CmdlineRemoteProto.Message.ControllerMessage.newBuilder().setType( CmdlineRemoteProto.Message.ControllerMessage.Type.FS_EVENT @@ -547,6 +548,25 @@ public final class BuildManager implements Disposable { return ContainerUtil.find(ProjectManager.getInstance().getOpenProjects(), project -> projectPath.equals(getProjectPath(project))); } + private static @NotNull Function getPathMapperForProject(@NotNull Project project) { + if (canUseEel() && !EelPathUtils.isProjectLocal(project)) { + return e -> asEelPath(Path.of(e)).toString(); + } + // This handles paths for WSL projects even if "wsl.use.remote.agent.for.nio.filesystem" registry flag is disabled + // and `EelPathUtils.isPathLocal(path)` previously returned `true` + WSLDistribution distribution = findWSLDistribution(project); + return wslPathMapper(distribution); + } + + private static @NotNull Function getPathMapperForProject(@NotNull String projectPath) { + if (canUseEel() && !EelPathUtils.isPathLocal(Path.of(projectPath))) { + return e -> asEelPath(Path.of(e)).toString(); + } + // This handles paths for WSL projects even if "wsl.use.remote.agent.for.nio.filesystem" registry flag is disabled + // and `EelPathUtils.isPathLocal(path)` previously returned `true` + return wslPathMapper(projectPath); + } + private static @NotNull Function wslPathMapper(@Nullable WSLDistribution distribution) { return distribution == null ? Function.identity() : @@ -857,14 +877,8 @@ public final class BuildManager implements Disposable { } final BuilderMessageHandler handler = new NotifyingMessageHandler(project, messageHandler, pathMapperBack, isAutomake); - Function pathMapper; - if (canUseEel() && !EelPathUtils.isProjectLocal(project)) { - pathMapper = e -> asEelPath(Path.of(e)).toString(); - } - else { - pathMapper = wslDistribution != null ? wslDistribution::getWslPath : Function.identity(); - } + Function pathMapper = getPathMapperForProject(project); final DelegateFuture _future = new DelegateFuture(); // by using the same queue that processes events, @@ -924,7 +938,7 @@ public final class BuildManager implements Disposable { Iterators.collect(Iterators.map(data.myDeleted, InternedPath::getValue), new HashSet<>())); } needRescan = data.getAndResetRescanFlag(); - currentFSChanges = needRescan ? null : data.createNextEvent(wslPathMapper(wslDistribution)); + currentFSChanges = needRescan ? null : data.createNextEvent(pathMapper); if (LOG.isDebugEnabled()) { LOG.debug("Sending to starting build, ordinal=" + (currentFSChanges == null ? null : currentFSChanges.getOrdinal())); }