[jps] IDEA-376790 Generalize path mapping for WSL and non‑local Eel projects

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.


(cherry picked from commit ff5c0ad873f513c0e34b3dc01a8b79904c8e7650)

IJ-CR-179667

GitOrigin-RevId: d106a542c08ac8ca2565f7691db6c3a9e9d8702a
This commit is contained in:
Alexander Koshevoy
2025-10-24 21:59:36 +00:00
committed by intellij-monorepo-bot
parent c387d5039b
commit 313180c930
@@ -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<String, String> 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<String, String> 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<String, String> 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<String, String> pathMapper;
if (canUseEel() && !EelPathUtils.isProjectLocal(project)) {
pathMapper = e -> asEelPath(Path.of(e)).toString();
}
else {
pathMapper = wslDistribution != null ? wslDistribution::getWslPath : Function.identity();
}
Function<String, String> 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()));
}