IJPL-1044 wrap clinit instance requests in non-cancellable section

GitOrigin-RevId: f63849ca504a01dbae51faac27f29e69f43bff86
This commit is contained in:
Daniil Ovchinnikov
2024-06-25 20:12:17 +00:00
committed by intellij-monorepo-bot
parent 1d063c0d01
commit 07f7cdaf55
17 changed files with 108 additions and 46 deletions
@@ -1,7 +1,9 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.idea.maven.aether;
import com.intellij.openapi.application.ClassPathUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.util.ArrayUtil;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.eclipse.aether.*;
@@ -38,7 +40,6 @@ import org.eclipse.aether.util.version.GenericVersionScheme;
import org.eclipse.aether.version.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.diagnostic.Logger;
import java.io.File;
import java.util.*;
@@ -56,8 +57,8 @@ public final class ArtifactRepositoryManager {
private static final Logger LOG = Logger.getInstance(ArtifactRepositoryManager.class);
private final RepositorySystemSessionFactory mySessionFactory;
private static final RemoteRepository MAVEN_CENTRAL_REPOSITORY = createRemoteRepository(
"central", "https://repo1.maven.org/maven2/"
private static final RemoteRepository MAVEN_CENTRAL_REPOSITORY = Cancellation.forceNonCancellableSectionInClassInitializer(
() -> createRemoteRepository("central", "https://repo1.maven.org/maven2/")
);
private static final RemoteRepository JBOSS_COMMUNITY_REPOSITORY = createRemoteRepository(
"jboss.community", "https://repository.jboss.org/nexus/content/repositories/public/"
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.codeStyle;
import com.intellij.CodeStyleBundle;
@@ -11,6 +11,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.*;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectLocator;
import com.intellij.openapi.util.*;
@@ -61,7 +62,9 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
private final CustomCodeStyleSettingsManager myCustomCodeStyleSettingsManager = new CustomCodeStyleSettingsManager(this);
private static class DefaultsHolder {
private static final CodeStyleSettings myDefaults = new CodeStyleSettings(true, false);
private static final CodeStyleSettings myDefaults = Cancellation.forceNonCancellableSectionInClassInitializer(
() -> new CodeStyleSettings(true, false)
);
}
private final SoftMargins mySoftMargins = new SoftMargins();
@@ -1,10 +1,11 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.notification
import com.intellij.ide.plugins.PluginUtil
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.progress.Cancellation
import com.intellij.openapi.ui.MessageType
import com.intellij.openapi.util.NlsContexts.*
import org.jetbrains.annotations.ApiStatus
@@ -56,7 +57,11 @@ class NotificationGroup private constructor(val displayId: String,
var isHideFromSettings: Boolean = false
val pluginId: PluginId? = pluginId ?: ApplicationManager.getApplication()?.let { PluginUtil.getInstance().findPluginId(Throwable()) }
val pluginId: PluginId? = pluginId ?: ApplicationManager.getApplication()?.let {
Cancellation.forceNonCancellableSectionInClassInitializer {
PluginUtil.getInstance().findPluginId(Throwable())
}
}
init {
if (registerGroup) {
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.actions;
import com.intellij.find.findInProject.FindInProjectManager;
@@ -6,6 +6,7 @@ import com.intellij.ide.lightEdit.LightEdit;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationGroupManager;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
@@ -14,7 +15,10 @@ import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public class FindInPathAction extends AnAction implements DumbAware {
public static final NotificationGroup NOTIFICATION_GROUP = NotificationGroupManager.getInstance().getNotificationGroup("Find in Path");
public static final NotificationGroup NOTIFICATION_GROUP = Cancellation.forceNonCancellableSectionInClassInitializer(
() -> NotificationGroupManager.getInstance().getNotificationGroup("Find in Path")
);
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
@@ -8,6 +8,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.SystemInfoRt;
@@ -111,7 +112,7 @@ public final class JBCefApp {
myDebuggingPort.completeExceptionally(new UnsupportedOperationException());
}
else {
CefSettings settings = SettingsHelper.loadSettings(config);
CefSettings settings = Cancellation.forceNonCancellableSectionInClassInitializer(() -> SettingsHelper.loadSettings(config));
if (SystemInfoRt.isLinux && !settings.no_sandbox) {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
@@ -159,7 +160,7 @@ public final class JBCefApp {
}
BoolRef trackGPUCrashes = new BoolRef(false);
String[] args = SettingsHelper.loadArgs(config, settings, trackGPUCrashes);
String[] args = Cancellation.forceNonCancellableSectionInClassInitializer(() -> SettingsHelper.loadArgs(config, settings, trackGPUCrashes));
CefApp.addAppHandler(new MyCefAppHandler(args, trackGPUCrashes.get()));
myCefSettings = settings;
myCefApp = CefApp.getInstance(settings);
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.execution.testframework;
import com.intellij.execution.ExecutionBundle;
@@ -10,6 +10,7 @@ import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.NlsContexts;
@@ -30,7 +31,9 @@ import java.awt.*;
import java.util.List;
public final class TestsUIUtil {
public static final NotificationGroup NOTIFICATION_GROUP = NotificationGroupManager.getInstance().getNotificationGroup("Test Runner");
public static final NotificationGroup NOTIFICATION_GROUP = Cancellation.forceNonCancellableSectionInClassInitializer(
() -> NotificationGroupManager.getInstance().getNotificationGroup("Test Runner")
);
public static final Color PASSED_COLOR = new Color(0, 128, 0);
private static final @NonNls String TESTS = "tests";
@@ -1,6 +1,7 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.usages;
import com.intellij.openapi.progress.Cancellation;
import org.jetbrains.annotations.ApiStatus.Internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -10,7 +11,9 @@ import java.awt.*;
@Internal
public final class UsageNodePresentation {
public static final UsageNodePresentation EMPTY = new UsageNodePresentation(null, TextChunk.EMPTY_ARRAY, null);
public static final UsageNodePresentation EMPTY = Cancellation.forceNonCancellableSectionInClassInitializer(
() -> new UsageNodePresentation(null, TextChunk.EMPTY_ARRAY, null)
);
private final @Nullable Icon myIcon;
private final @Nullable Color myBackgroundColor;
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.progress;
import com.intellij.concurrency.ThreadContext;
@@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;
import java.util.concurrent.CancellationException;
import java.util.function.Supplier;
import static kotlinx.coroutines.JobKt.ensureActive;
@@ -89,4 +90,24 @@ public final class Cancellation {
}
};
}
/**
* Throwing {@code CancellationException} from {@code <clinit>} causes {@link ExceptionInInitializerError} and bricks the class forever.
* For example, requesting services or connecting a message bus are cancellable operations,
* and they must not be invoked from class initializers.
* Avoiding complex operations in initializers makes the classloading faster.
*
* @deprecated To prevent the new code from accidentally calling cancellable APIs,
* we need to enable the error logging by default.
* To do that, existing failures have to be fixed right away or suppressed.
* This method exists to suppress existing failures in our own tests.
* It serves as a point for finding all such cases by searching for its usages.
* This method will throw an error in coming releases.
* <a href="https://youtrack.jetbrains.com/issue/IJPL-1045">YouTrack issue.</a>
*/
@Internal
@Deprecated
public static <T> T forceNonCancellableSectionInClassInitializer(@NotNull Supplier<T> computable) {
return computeInNonCancelableSection(computable::get);
}
}
@@ -2,7 +2,10 @@
package org.jetbrains.kotlin.idea.actions
import com.intellij.ide.actions.*
import com.intellij.ide.actions.CreateFileFromTemplateAction
import com.intellij.ide.actions.CreateFileFromTemplateDialog
import com.intellij.ide.actions.CreateTemplateInPackageAction
import com.intellij.ide.actions.JavaCreateTemplateInPackageAction
import com.intellij.ide.fileTemplates.FileTemplate
import com.intellij.ide.fileTemplates.FileTemplateManager
import com.intellij.ide.fileTemplates.actions.AttributesDefaults
@@ -19,6 +22,7 @@ import com.intellij.openapi.editor.LogicalPosition
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.module.ModuleUtil
import com.intellij.openapi.module.ModuleUtilCore
import com.intellij.openapi.progress.Cancellation
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
@@ -35,11 +39,7 @@ import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.base.projectStructure.NewKotlinFileHook
import org.jetbrains.kotlin.idea.base.projectStructure.RootKindFilter
import org.jetbrains.kotlin.idea.base.projectStructure.languageVersionSettings
import org.jetbrains.kotlin.idea.base.projectStructure.matches
import org.jetbrains.kotlin.idea.base.projectStructure.toModuleGroup
import org.jetbrains.kotlin.idea.base.projectStructure.*
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinStatus
@@ -320,7 +320,11 @@ internal fun CreateFileFromTemplateDialog.Builder.addKind(t: KotlinFileTemplate)
internal enum class KotlinFileTemplate(@NlsContexts.ListItem val title: String, val icon: Icon, val fileName: String) {
Class(KotlinBundle.message("action.new.file.dialog.class.title"), KotlinIcons.CLASS, "Kotlin Class"),
File(KotlinBundle.message("action.new.file.dialog.file.title"), KotlinFileType.INSTANCE.icon, "Kotlin File"),
File(
KotlinBundle.message("action.new.file.dialog.file.title"),
Cancellation.forceNonCancellableSectionInClassInitializer { KotlinFileType.INSTANCE.icon },
"Kotlin File"
),
Interface(KotlinBundle.message("action.new.file.dialog.interface.title"), KotlinIcons.INTERFACE, "Kotlin Interface"),
SealedInterface(KotlinBundle.message("action.new.file.dialog.sealed.interface.title"), KotlinIcons.INTERFACE, "Kotlin Sealed Interface"),
DataClass(KotlinBundle.message("action.new.file.dialog.data.class.title"), KotlinIcons.CLASS, "Kotlin Data Class"),
@@ -1,10 +1,8 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.tools.projectWizard
import com.intellij.openapi.progress.Cancellation
import org.jetbrains.kotlin.tools.projectWizard.compatibility.DependencyVersionStore
import org.jetbrains.kotlin.tools.projectWizard.library.LibraryDescriptor
import org.jetbrains.kotlin.tools.projectWizard.library.LibraryType
@@ -48,7 +46,9 @@ object Dependencies {
return descriptor
}
val JUNIT = registerMavenLibrary(DefaultRepository.MAVEN_CENTRAL, "junit", "junit", "4.13.2")
val JUNIT = Cancellation.forceNonCancellableSectionInClassInitializer {
registerMavenLibrary(DefaultRepository.MAVEN_CENTRAL, "junit", "junit", "4.13.2")
}
val JUNIT5 = registerMavenLibrary(DefaultRepository.MAVEN_CENTRAL, "org.junit.jupiter", "junit-jupiter-engine", "5.8.2")
object ANDROID {
@@ -1,10 +1,8 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.tools.projectWizard
import com.intellij.openapi.progress.Cancellation
import org.jetbrains.kotlin.tools.projectWizard.compatibility.KotlinWizardVersionState
import org.jetbrains.kotlin.tools.projectWizard.compatibility.KotlinWizardVersionStore
import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
@@ -15,7 +13,10 @@ object Versions {
// However, we are keeping these fields for API compatibility reasons
private fun loadVersion(default: String, f: (KotlinWizardVersionState).() -> String?): Version {
val version = KotlinWizardVersionStore.getInstance().state?.let(f) ?: default
val store = Cancellation.forceNonCancellableSectionInClassInitializer {
KotlinWizardVersionStore.getInstance()
}
val version = store.state?.let(f) ?: default
return Version.fromString(version)
}
@@ -1,9 +1,10 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.idea.svn;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.FileStatusFactory;
@@ -27,5 +28,5 @@ public final class SvnFileStatus {
.createFileStatus("IDEA_SVN_FILESTATUS_OBSTRUCTED", SvnBundle.messagePointer("file.status.obstructed"), new Color(0x727238), OUR_PLUGIN_ID);
public static final FileStatus REPLACED = FileStatusFactory.getInstance()
.createFileStatus("IDEA_SVN_REPLACED", SvnBundle.messagePointer("file.status.replaced"), FileStatus.ADDED.getColor(), OUR_PLUGIN_ID);
.createFileStatus("IDEA_SVN_REPLACED", SvnBundle.messagePointer("file.status.replaced"), Cancellation.forceNonCancellableSectionInClassInitializer(() -> FileStatus.ADDED.getColor()), OUR_PLUGIN_ID);
}
@@ -4,6 +4,7 @@ package com.jetbrains.python
import com.intellij.lang.ASTNode
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.openapi.progress.Cancellation
import com.intellij.psi.PsiElement
import com.intellij.psi.tree.IElementType
import java.util.function.Function
@@ -122,6 +123,10 @@ abstract class PyElementTypesFacade {
abstract val asPatternConstructor: Function<in ASTNode, out PsiElement>
companion object {
val INSTANCE: PyElementTypesFacade by lazy { ApplicationManager.getApplication().service<PyElementTypesFacade>() }
val INSTANCE: PyElementTypesFacade by lazy {
Cancellation.forceNonCancellableSectionInClassInitializer {
ApplicationManager.getApplication().service<PyElementTypesFacade>()
}
}
}
}
@@ -3,6 +3,7 @@ package com.jetbrains.python.formatter;
import com.intellij.formatting.*;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
@@ -20,7 +21,9 @@ import static com.jetbrains.python.PyTokenTypes.*;
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public class PythonFormattingModelBuilder implements FormattingModelBuilder, CustomFormattingModelBuilder {
private static final boolean DUMP_FORMATTING_AST = false;
static final TokenSet STATEMENT_OR_DECLARATION = PythonDialectsTokenSetProvider.getInstance().getStatementTokens();
static final TokenSet STATEMENT_OR_DECLARATION = Cancellation.forceNonCancellableSectionInClassInitializer(
() -> PythonDialectsTokenSetProvider.getInstance().getStatementTokens()
);
private static final TokenSet STAR_PATTERNS = TokenSet.create(SINGLE_STAR_PATTERN, DOUBLE_STAR_PATTERN);
private static final TokenSet EXPRESSIONS_WITH_COLON = TokenSet.create(KEY_VALUE_EXPRESSION, KEY_VALUE_PATTERN, LAMBDA_EXPRESSION);
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.python.codeInsight.typing
import com.google.common.cache.Cache
@@ -15,6 +15,7 @@ import com.intellij.notification.NotificationType
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleUtilCore
import com.intellij.openapi.progress.Cancellation
import com.intellij.openapi.project.Project
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.util.Key
@@ -48,7 +49,9 @@ private class PyStubPackagesAdvertiser : PyInspection() {
"traits" to "traits") // top-level package to package on PyPI, sorted by the latter
private val BALLOON_SHOWING = Key.create<Boolean>("showingStubPackagesAdvertiserBalloon")
private val BALLOON_NOTIFICATIONS = NotificationGroupManager.getInstance().getNotificationGroup("Python Stub Packages Advertiser")
private val BALLOON_NOTIFICATIONS = Cancellation.forceNonCancellableSectionInClassInitializer {
NotificationGroupManager.getInstance().getNotificationGroup("Python Stub Packages Advertiser")
}
}
var ignoredPackages: MutableList<String> = mutableListOf()
@@ -11,7 +11,6 @@ import com.intellij.codeInspection.util.InspectionMessage;
import com.intellij.codeInspection.util.IntentionFamilyName;
import com.intellij.core.CoreBundle;
import com.intellij.execution.ExecutionException;
import com.intellij.icons.AllIcons;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.idea.ActionsBundle;
import com.intellij.model.SideEffectGuard;
@@ -20,10 +19,10 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.progress.Cancellation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.ui.DoNotAskOption;
import com.intellij.openapi.ui.MessageDialogBuilder;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.openapi.util.NlsSafe;
@@ -63,7 +62,9 @@ import static com.intellij.codeInspection.options.OptPane.pane;
public final class PyPackageRequirementsInspection extends PyInspection {
public JDOMExternalizableStringList ignoredPackages = new JDOMExternalizableStringList();
private static final @NotNull NotificationGroup BALLOON_NOTIFICATIONS = NotificationGroupManager.getInstance().getNotificationGroup("Package requirements");
private static final @NotNull NotificationGroup BALLOON_NOTIFICATIONS = Cancellation.forceNonCancellableSectionInClassInitializer(
() -> NotificationGroupManager.getInstance().getNotificationGroup("Package requirements")
);
@Override
public @NotNull OptPane getOptionsPane() {
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.python.sdk.pipenv
import com.google.gson.Gson
@@ -29,6 +29,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleUtil
import com.intellij.openapi.module.ModuleUtilCore
import com.intellij.openapi.progress.Cancellation
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
@@ -45,11 +46,11 @@ import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.PathUtil
import com.jetbrains.python.PyBundle
import com.jetbrains.python.icons.PythonIcons
import com.jetbrains.python.inspections.PyPackageRequirementsInspection
import com.jetbrains.python.packaging.*
import com.jetbrains.python.sdk.*
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor
import com.jetbrains.python.icons.PythonIcons
import org.jetbrains.annotations.SystemDependent
import org.jetbrains.annotations.TestOnly
import java.io.File
@@ -394,7 +395,9 @@ private val Document.virtualFile: VirtualFile?
private fun VirtualFile.getModule(project: Project): Module? =
ModuleUtil.findModuleForFile(this, project)
private val LOCK_NOTIFICATION_GROUP = NotificationGroupManager.getInstance().getNotificationGroup("Pipfile Watcher")
private val LOCK_NOTIFICATION_GROUP = Cancellation.forceNonCancellableSectionInClassInitializer {
NotificationGroupManager.getInstance().getNotificationGroup("Pipfile Watcher")
}
private val Sdk.packageManager: PyPackageManager
get() = PyPackageManagers.getInstance().forSdk(this)