mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-12449 Create Virtualenv: do not run skeleton generator when selecting not added base python interpreter
This commit is contained in:
@@ -137,7 +137,7 @@ public class PyActiveSdkConfigurable implements UnnamedConfigurable {
|
||||
@Override
|
||||
public void consume(Sdk sdk) {
|
||||
if (sdk == null) return;
|
||||
final PyRemovedSdkService sdkService = PyRemovedSdkService.getInstance();
|
||||
final PySdkService sdkService = PySdkService.getInstance();
|
||||
sdkService.restoreSdk(sdk);
|
||||
if (myProjectSdksModel.findSdk(sdk) == null) {
|
||||
myProjectSdksModel.addSdk(sdk);
|
||||
@@ -283,6 +283,7 @@ public class PyActiveSdkConfigurable implements UnnamedConfigurable {
|
||||
mySdkCombo.setSelectedItem(newSdk);
|
||||
myProjectSdksModel.apply();
|
||||
}
|
||||
PySdkService.getInstance().solidifySdk(item);
|
||||
}
|
||||
else {
|
||||
final Sdk sdk = myProjectSdksModel.findSdk(item);
|
||||
|
||||
+6
-5
@@ -24,10 +24,7 @@ import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.PyDetectedSdk;
|
||||
import com.jetbrains.python.sdk.PySdkUtil;
|
||||
import com.jetbrains.python.sdk.PythonSdkAdditionalData;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import com.jetbrains.python.sdk.*;
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
|
||||
import com.jetbrains.python.sdk.flavors.VirtualEnvSdkFlavor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -112,6 +109,7 @@ public class PyConfigurableInterpreterList {
|
||||
}
|
||||
});
|
||||
|
||||
final PySdkService sdkService = PySdkService.getInstance();
|
||||
final List<String> sdkHomes = new ArrayList<String>();
|
||||
sdkHomes.addAll(VirtualEnvSdkFlavor.INSTANCE.suggestHomePaths());
|
||||
for (PythonSdkFlavor flavor : PythonSdkFlavor.getApplicableFlavors()) {
|
||||
@@ -122,10 +120,13 @@ public class PyConfigurableInterpreterList {
|
||||
for (String sdkHome : SdkConfigurationUtil.filterExistingPaths(PythonSdkType.getInstance(), sdkHomes, getModel().getSdks())) {
|
||||
result.add(new PyDetectedSdk(sdkHome));
|
||||
}
|
||||
for (String sdkHome : SdkConfigurationUtil.filterExistingPaths(PythonSdkType.getInstance(), sdkService.getAddedSdks(), getModel().getSdks())) {
|
||||
result.add(new PyDetectedSdk(sdkHome));
|
||||
}
|
||||
Iterables.removeIf(result, new Predicate<Sdk>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Sdk input) {
|
||||
return input != null && PyRemovedSdkService.getInstance().isRemoved(input);
|
||||
return input != null && sdkService.isRemoved(input);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python.configuration;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@State(
|
||||
name = "PyRemovedSdkService",
|
||||
storages = {
|
||||
@Storage(
|
||||
file = StoragePathMacros.APP_CONFIG + "/removedInterpreters.xml"
|
||||
)}
|
||||
)
|
||||
public class PyRemovedSdkService implements PersistentStateComponent<PyRemovedSdkService> {
|
||||
|
||||
public static PyRemovedSdkService getInstance() {
|
||||
return ServiceManager.getService(PyRemovedSdkService.class);
|
||||
}
|
||||
|
||||
public Set<String> REMOVED_SDKS = new HashSet<String>();
|
||||
|
||||
public void removeSdk(@NotNull final Sdk sdk) {
|
||||
REMOVED_SDKS.add(sdk.getHomePath());
|
||||
}
|
||||
|
||||
public void restoreSdk(@NotNull final Sdk sdk) {
|
||||
final String homePath = sdk.getHomePath();
|
||||
if (REMOVED_SDKS.contains(homePath)) {
|
||||
REMOVED_SDKS.remove(homePath);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRemoved(@NotNull final Sdk sdk) {
|
||||
final String homePath = sdk.getHomePath();
|
||||
return REMOVED_SDKS.contains(homePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyRemovedSdkService getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(PyRemovedSdkService state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
|
||||
|
||||
private void addCreatedSdk(@Nullable final Sdk sdk, boolean newVirtualEnv) {
|
||||
if (sdk != null) {
|
||||
final PyRemovedSdkService sdkService = PyRemovedSdkService.getInstance();
|
||||
final PySdkService sdkService = PySdkService.getInstance();
|
||||
sdkService.restoreSdk(sdk);
|
||||
|
||||
boolean isVirtualEnv = PythonSdkType.isVirtualEnv(sdk);
|
||||
@@ -385,7 +385,7 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
|
||||
private void removeSdk() {
|
||||
final Sdk currentSdk = getSelectedSdk();
|
||||
if (currentSdk != null) {
|
||||
final PyRemovedSdkService sdkService = PyRemovedSdkService.getInstance();
|
||||
final PySdkService sdkService = PySdkService.getInstance();
|
||||
sdkService.removeSdk(currentSdk);
|
||||
myProjectSdksModel.removeSdk(currentSdk);
|
||||
if (myModificators.containsKey(currentSdk)) {
|
||||
|
||||
Reference in New Issue
Block a user