[python] Do not try to store module settings if module does not support it, fix RIDER-65749

(cherry picked from commit 176cdfa247412ada05300429cde63a2c8fbb0c3c)

IJ-CR-21584

GitOrigin-RevId: 4ae79745171c032a76d00f79343220ac2e3118bf
This commit is contained in:
Evgeniy.Stepanov
2022-03-02 17:39:59 +01:00
committed by intellij-monorepo-bot
parent 6a227fff0b
commit a59e2445ef
3 changed files with 12 additions and 1 deletions

View File

@@ -169,6 +169,11 @@ public class ModuleImpl extends ComponentManagerImpl implements ModuleEx {
return Objects.requireNonNull(getService(IComponentStore.class));
}
@Override
public boolean canStoreSettings() {
return !(getStore() instanceof NonPersistentModuleStore);
}
@Override
@NotNull
public Path getModuleNioFile() {

View File

@@ -32,6 +32,9 @@ public interface ModuleEx extends Module {
return 0;
}
/**
* @return true if this module can store settings in its IComponentStore
*/
@ApiStatus.Internal
default boolean canStoreSettings() {
return true;

View File

@@ -3,6 +3,7 @@ package com.jetbrains.python.defaultProjectAwareService;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.impl.ModuleEx;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,7 +30,9 @@ public final class PyDefaultProjectAwareServiceClasses<
* Use it for "getInstance" function. Returns module-level if module is set, app level otherwise
*/
public SERVICE getService(@Nullable Module module) {
return (module != null ? getModuleService(module) : getAppService());
if (module == null) return getAppService();
if (module instanceof ModuleEx && !((ModuleEx)module).canStoreSettings()) return getAppService();
return getModuleService(module);
}
@NotNull