mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup [python]: remove unused methods from PythonSdkType, mark legacy methods "internal"
GitOrigin-RevId: f7d1c0a4effefd459b6d88dd4011c1a26a93a277
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2d70c0bb5a
commit
4a2ee0758f
@@ -106,6 +106,7 @@ public final class PySdkUtil {
|
||||
return getProcessOutput(cmd, homePath, extraEnv, timeout, null, true);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static ProcessOutput getProcessOutput(@NotNull GeneralCommandLine cmd, @Nullable String homePath,
|
||||
@Nullable @NonNls Map<String, String> extraEnv,
|
||||
int timeout,
|
||||
@@ -201,6 +202,7 @@ public final class PySdkUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static @NotNull Map<String, String> activateVirtualEnv(@NotNull Sdk sdk) {
|
||||
final Map<String, String> cached = sdk.getUserData(ENVIRONMENT_KEY);
|
||||
if (cached != null) return cached;
|
||||
|
||||
@@ -61,10 +61,7 @@ class PySdkPopupFactory(val module: Module) {
|
||||
val interpreterList = PyConfigurableInterpreterList.getInstance(module.project)
|
||||
val moduleSdksByTypes = SlowOperations.knownIssue("PY-76167").use {
|
||||
groupModuleSdksByTypes(interpreterList.getAllPythonSdks(module.project, module, false), module) {
|
||||
!it.sdkSeemsValid ||
|
||||
PythonSdkType.hasInvalidRemoteCredentials(it) ||
|
||||
PythonSdkType.isIncompleteRemote(it) ||
|
||||
!LanguageLevel.SUPPORTED_LEVELS.contains(PythonSdkType.getLanguageLevelForSdk(it))
|
||||
!it.sdkSeemsValid || !LanguageLevel.SUPPORTED_LEVELS.contains(PythonSdkType.getLanguageLevelForSdk(it))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ fun name(sdk: Sdk): Triple<String?, String, String?> = name(sdk, sdk.name)
|
||||
|
||||
fun name(sdk: Sdk, name: String): Triple<String?, String, String?> {
|
||||
val modifier = when {
|
||||
!sdk.sdkSeemsValid || PythonSdkType.hasInvalidRemoteCredentials(sdk) -> "invalid"
|
||||
PythonSdkType.isIncompleteRemote(sdk) -> "incomplete"
|
||||
!sdk.sdkSeemsValid -> "invalid"
|
||||
!LanguageLevel.SUPPORTED_LEVELS.contains(PySdkUtil.getLanguageLevelForSdk(sdk)) -> "unsupported"
|
||||
else -> null
|
||||
}
|
||||
@@ -93,10 +92,7 @@ fun icon(sdk: Sdk): Icon {
|
||||
val providedIcon = PySdkProvider.EP_NAME.extensions.firstNotNullOfOrNull { it.getSdkIcon(sdk) }
|
||||
|
||||
return when {
|
||||
(!sdk.sdkSeemsValid) ||
|
||||
PythonSdkType.isIncompleteRemote(sdk) ||
|
||||
PythonSdkType.hasInvalidRemoteCredentials(sdk) ||
|
||||
!LanguageLevel.SUPPORTED_LEVELS.contains(PySdkUtil.getLanguageLevelForSdk(sdk)) ->
|
||||
!sdk.sdkSeemsValid || !LanguageLevel.SUPPORTED_LEVELS.contains(PySdkUtil.getLanguageLevelForSdk(sdk)) ->
|
||||
wrapIconWithWarningDecorator(icon)
|
||||
sdk is PyDetectedSdk -> IconLoader.getTransparentIcon(icon)
|
||||
providedIcon != null -> providedIcon
|
||||
|
||||
@@ -151,6 +151,7 @@ public final class PythonSdkType extends SdkType {
|
||||
}
|
||||
|
||||
@RequiresBackgroundThread(generateAssertion = false) //No warning yet as there are usages: to be fixed
|
||||
@ApiStatus.Internal
|
||||
private static boolean isLocalPathValid(@NotNull Path path) {
|
||||
return PythonSdkFlavor.getFlavor(path.toString()) != null;
|
||||
}
|
||||
@@ -224,6 +225,7 @@ public final class PythonSdkType extends SdkType {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
private static boolean isLocatedInWsl(@NotNull VirtualFile file) {
|
||||
return SystemInfo.isWindows && isCustomPythonSdkHomePath(file.getPath());
|
||||
}
|
||||
@@ -252,6 +254,7 @@ public final class PythonSdkType extends SdkType {
|
||||
* @param commandLine what to patch
|
||||
* @param sdk SDK we're using
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void patchCommandLineForVirtualenv(@NotNull GeneralCommandLine commandLine,
|
||||
@NotNull Sdk sdk) {
|
||||
patchEnvironmentVariablesForVirtualenv(commandLine.getEnvironment(), sdk);
|
||||
@@ -297,6 +300,7 @@ public final class PythonSdkType extends SdkType {
|
||||
}
|
||||
|
||||
@RequiresBackgroundThread(generateAssertion = false) //because of process output
|
||||
@ApiStatus.Internal
|
||||
public static @Nullable String suggestBaseSdkName(@NotNull String sdkHome) {
|
||||
final PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(sdkHome);
|
||||
if (flavor == null) return null;
|
||||
@@ -411,6 +415,7 @@ public final class PythonSdkType extends SdkType {
|
||||
return true; // run setupSdkPaths only once (from PythonSdkDetailsStep). Skip this from showCustomCreateUI
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void notifyRemoteSdkSkeletonsFail(final InvalidSdkException e, final @Nullable Runnable restartAction) {
|
||||
NotificationListener notificationListener;
|
||||
String notificationMessage;
|
||||
@@ -437,6 +442,7 @@ public final class PythonSdkType extends SdkType {
|
||||
notification.notify(null);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static @NotNull VirtualFile getSdkRootVirtualFile(@NotNull VirtualFile path) {
|
||||
String suffix = path.getExtension();
|
||||
if (suffix != null) {
|
||||
@@ -504,19 +510,13 @@ public final class PythonSdkType extends SdkType {
|
||||
return homeDir != null && homeDir.isValid();
|
||||
}
|
||||
|
||||
public static boolean isIncompleteRemote(@NotNull Sdk sdk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static boolean isRunAsRootViaSudo(@NotNull Sdk sdk) {
|
||||
SdkAdditionalData data = sdk.getSdkAdditionalData();
|
||||
return data instanceof PyTargetAwareAdditionalData pyTargetAwareAdditionalData && pyTargetAwareAdditionalData.isRunAsRootViaSudo();
|
||||
}
|
||||
|
||||
public static boolean hasInvalidRemoteCredentials(@NotNull Sdk sdk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static @NotNull String getSdkKey(@NotNull Sdk sdk) {
|
||||
return sdk.getName();
|
||||
}
|
||||
@@ -527,11 +527,13 @@ public final class PythonSdkType extends SdkType {
|
||||
return !PythonSdkUtil.isRemote(sdk);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static @Nullable Sdk findLocalCPython(@Nullable Module module) {
|
||||
final Sdk moduleSDK = PythonSdkUtil.findPythonSdk(module);
|
||||
return findLocalCPythonForSdk(moduleSDK);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static @Nullable Sdk findLocalCPythonForSdk(@Nullable Sdk existingSdk) {
|
||||
if (existingSdk != null && !PythonSdkUtil.isRemote(existingSdk) && PythonSdkFlavor.getFlavor(existingSdk) instanceof CPythonSdkFlavor) {
|
||||
return existingSdk;
|
||||
@@ -561,6 +563,7 @@ public final class PythonSdkType extends SdkType {
|
||||
* @return if SDK is mock (used by tests only)
|
||||
*/
|
||||
@SuppressWarnings("TestOnlyProblems")
|
||||
@ApiStatus.Internal
|
||||
public static boolean isMock(@NotNull Sdk sdk) {
|
||||
return (sdk.getUserData(MOCK_PY_VERSION_KEY) != null) ||
|
||||
(sdk.getUserData(MOCK_SYS_PATH_KEY) != null) ||
|
||||
@@ -570,6 +573,7 @@ public final class PythonSdkType extends SdkType {
|
||||
/**
|
||||
* Returns mocked path (stored in sdk with {@link #MOCK_SYS_PATH_KEY} in test)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static @NotNull List<String> getMockPath(@NotNull Sdk sdk) {
|
||||
var workDir = Paths.get(Objects.requireNonNull(sdk.getHomePath())).getParent().toString();
|
||||
var mockPaths = sdk.getUserData(MOCK_SYS_PATH_KEY);
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.ui.dsl.builder.columns
|
||||
import com.intellij.ui.dsl.builder.panel
|
||||
import com.jetbrains.python.PyBundle
|
||||
import com.jetbrains.python.sdk.PySdkListCellRenderer
|
||||
import com.jetbrains.python.sdk.PythonSdkType
|
||||
import com.jetbrains.python.sdk.legacy.PythonSdkUtil
|
||||
import com.jetbrains.python.sdk.sdkSeemsValid
|
||||
import com.jetbrains.python.sdk.uv.isUv
|
||||
@@ -165,7 +164,7 @@ fun uvSdkList(): List<Sdk?> =
|
||||
PythonSdkUtil
|
||||
.getAllSdks()
|
||||
.filter { sdk ->
|
||||
sdk.isUv && sdk.sdkSeemsValid && !PythonSdkType.hasInvalidRemoteCredentials(sdk)
|
||||
sdk.isUv && sdk.sdkSeemsValid
|
||||
}
|
||||
|
||||
private val whiteSpaceRegex = Regex("\\s+")
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkAdditionalData;
|
||||
import com.intellij.remote.ext.CredentialsLanguageContribution;
|
||||
import com.intellij.testFramework.PlatformLiteFixture;
|
||||
import org.junit.Assert;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Alexander Koshevoy
|
||||
*/
|
||||
public class PythonSdkTypePlatformTest extends PlatformLiteFixture {
|
||||
@Mock private Sdk sdk;
|
||||
@Mock private SdkAdditionalData sdkAdditionalData;
|
||||
@Mock private CredentialsLanguageContribution credentialsLanguageContribution;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initApplication();
|
||||
MockitoAnnotations.initMocks(this);
|
||||
registerExtension(CredentialsLanguageContribution.EP_NAME, credentialsLanguageContribution);
|
||||
}
|
||||
|
||||
public void testLocalSdk() {
|
||||
when(sdk.getSdkAdditionalData()).thenReturn(sdkAdditionalData);
|
||||
Assert.assertFalse(PythonSdkType.hasInvalidRemoteCredentials(sdk));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user