PY-48100, IDEA-272966:

Use ```\\wsl$`` prefix instead of ``wsl://``.
Latter one was filtered out by WslFilter

GitOrigin-RevId: 0d0542b6b3be3e484b9eab7753c0508e6d69b83c
This commit is contained in:
Ilya.Kazakevich
2021-07-20 12:56:05 +00:00
committed by intellij-monorepo-bot
parent 83d84b859e
commit 34c23cd575
@@ -1,14 +1,18 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.remote.ext;
import com.intellij.execution.wsl.WSLDistribution;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkAdditionalData;
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
import com.intellij.remote.CredentialsType;
import com.intellij.remote.OutdatedCredentialsType;
import com.intellij.remote.RemoteSdkAdditionalData;
import kotlin.Pair;
import org.jdom.Element;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,6 +20,7 @@ import java.util.List;
import java.util.stream.Stream;
public abstract class CredentialsManager {
private final static String WSL_PATH_TO_REMOVE = "wsl://";
public static CredentialsManager getInstance() {
return ApplicationManager.getApplication().getService(CredentialsManager.class);
@@ -23,6 +28,22 @@ public abstract class CredentialsManager {
public abstract List<CredentialsType<?>> getAllTypes();
/**
* Change old (wsl://) prefix to the new one (\\wsl$\)
*
* @deprecated remove after everyone migrates to the new prefix
*/
@ApiStatus.ScheduledForRemoval(inVersion = "2022.1")
@Deprecated
public static void fixWslPrefix(@NotNull Sdk sdk) {
if (sdk instanceof ProjectJdkImpl) {
var path = sdk.getHomePath();
if (path != null && path.startsWith(WSL_PATH_TO_REMOVE)) {
((ProjectJdkImpl)sdk).setHomePath(WSLDistribution.UNC_PREFIX + path.substring(WSL_PATH_TO_REMOVE.length()));
}
}
}
public abstract void loadCredentials(String interpreterPath,
@Nullable Element element,
RemoteSdkAdditionalData data);