Make python disposable name more descriptive and not looking like interface
authorSemyon Proshev <Semyon.Proshev@jetbrains.com>
Fri, 16 Oct 2020 14:28:22 +0000 (17:28 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Fri, 16 Oct 2020 14:44:56 +0000 (14:44 +0000)
GitOrigin-RevId: 5009db52c121efbbf04952d3843b64ff4dc5888d

python/ide/impl/src/com/jetbrains/python/newProject/welcome/PyWelcome.kt
python/openapi/src/com/jetbrains/python/PythonPluginDisposable.java [moved from python/openapi/src/com/jetbrains/python/PyDisposable.java with 66% similarity]
python/python-psi-impl/src/com/jetbrains/python/psi/resolve/PythonSdkPathCache.java
python/python-sdk/src/com/jetbrains/python/sdk/PythonSdkAdditionalData.java
python/src/com/jetbrains/commandInterface/console/CommandConsole.java
python/src/com/jetbrains/python/codeInsight/mlcompletion/prev2calls/PrevCallsModelsProviderService.kt
python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java
python/src/com/jetbrains/python/console/PythonConsoleToolWindowFactory.kt
python/src/com/jetbrains/python/debugger/containerview/PyDataView.java
python/src/com/jetbrains/python/sdk/configuration/PyProjectSdkConfiguration.kt

index 30f455c47f4b1daaab44585c3b85e18013fcef99..1701a95a79586f8c95b46ba26320f37e40a71f5a 100644 (file)
@@ -36,7 +36,7 @@ import com.intellij.psi.PsiFile
 import com.intellij.psi.PsiManager
 import com.intellij.ui.components.JBCheckBox
 import com.intellij.xdebugger.XDebuggerUtil
-import com.jetbrains.python.PyDisposable
+import com.jetbrains.python.PythonPluginDisposable
 import com.jetbrains.python.newProject.welcome.PyWelcomeCollector.Companion.ProjectType
 import com.jetbrains.python.newProject.welcome.PyWelcomeCollector.Companion.ProjectViewPoint
 import com.jetbrains.python.newProject.welcome.PyWelcomeCollector.Companion.ProjectViewResult
@@ -132,12 +132,12 @@ private object PyWelcome {
   private fun prepareFileAndOpen(project: Project, baseDir: VirtualFile): CancellablePromise<PsiFile?> {
     return AppUIExecutor
       .onWriteThread()
-      .expireWith(PyDisposable.getInstance(project))
+      .expireWith(PythonPluginDisposable.getInstance(project))
       .submit(
         Callable {
           WriteAction.compute<PsiFile?, Exception> {
             prepareFile(project, baseDir)?.also {
-              AppUIExecutor.onUiThread().expireWith(PyDisposable.getInstance(project)).execute { it.navigate(true) }
+              AppUIExecutor.onUiThread().expireWith(PythonPluginDisposable.getInstance(project)).execute { it.navigate(true) }
             }
           }
         }
@@ -184,7 +184,7 @@ private object PyWelcome {
         DumbAwareRunnable {
           AppUIExecutor
             .onUiThread(ModalityState.NON_MODAL)
-            .expireWith(PyDisposable.getInstance(project))
+            .expireWith(PythonPluginDisposable.getInstance(project))
             .submit {
               val fileToChoose = (file ?: firstUserFile(project, baseDir, module)) ?: return@submit
 
similarity index 66%
rename from python/openapi/src/com/jetbrains/python/PyDisposable.java
rename to python/openapi/src/com/jetbrains/python/PythonPluginDisposable.java
index 29b98824f26ffbbb369ec80aae36aac547d47a0d..e508a43724f40c6e6b171b48d8e3c92a91d3ff82 100644 (file)
@@ -8,16 +8,16 @@ import com.intellij.openapi.project.Project;
 import org.jetbrains.annotations.NotNull;
 
 /**
- * The service is intended to be used instead of a project as a parent disposable.
+ * The service is intended to be used instead of a project/application as a parent disposable.
  */
 @Service
-public final class PyDisposable implements Disposable {
+public final class PythonPluginDisposable implements Disposable {
   public static @NotNull Disposable getInstance() {
-    return ApplicationManager.getApplication().getService(PyDisposable.class);
+    return ApplicationManager.getApplication().getService(PythonPluginDisposable.class);
   }
 
   public static @NotNull Disposable getInstance(@NotNull Project project) {
-    return project.getService(PyDisposable.class);
+    return project.getService(PythonPluginDisposable.class);
   }
 
   @Override
index d1ecc316b6a8ccbc9004cf45b0e60da0caa540e4..a855d54fcaeb7908172b780ec28d039cb6b0da3b 100644 (file)
@@ -26,7 +26,7 @@ import com.intellij.openapi.util.Key;
 import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.messages.MessageBusConnection;
-import com.jetbrains.python.PyDisposable;
+import com.jetbrains.python.PythonPluginDisposable;
 import com.jetbrains.python.packaging.PyPackageManager;
 import com.jetbrains.python.psi.impl.PyBuiltinCache;
 import org.jetbrains.annotations.NotNull;
@@ -66,7 +66,7 @@ public class PythonSdkPathCache extends PythonPathCache implements Disposable {
     if (project.isDisposed()) {
       return;
     }
-    Disposer.register(PyDisposable.getInstance(project), this);
+    Disposer.register(PythonPluginDisposable.getInstance(project), this);
     final MessageBusConnection connection = project.getMessageBus().connect(this);
     connection.subscribe(ProjectJdkTable.JDK_TABLE_TOPIC, new ProjectJdkTable.Listener() {
       @Override
index 4311cc001a6fc770e4eaa2cff814b7fb54e31bfc..4cdde4151dbba2863d052195216294d10e33c368 100644 (file)
@@ -12,7 +12,7 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer;
 import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
-import com.jetbrains.python.PyDisposable;
+import com.jetbrains.python.PythonPluginDisposable;
 import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
 import org.jdom.Element;
 import org.jetbrains.annotations.NonNls;
@@ -39,14 +39,14 @@ public class PythonSdkAdditionalData implements SdkAdditionalData {
 
   public PythonSdkAdditionalData(@Nullable PythonSdkFlavor flavor) {
     myFlavor = flavor;
-    myAddedPaths = VirtualFilePointerManager.getInstance().createContainer(PyDisposable.getInstance());
-    myExcludedPaths = VirtualFilePointerManager.getInstance().createContainer(PyDisposable.getInstance());
+    myAddedPaths = VirtualFilePointerManager.getInstance().createContainer(PythonPluginDisposable.getInstance());
+    myExcludedPaths = VirtualFilePointerManager.getInstance().createContainer(PythonPluginDisposable.getInstance());
   }
 
   protected PythonSdkAdditionalData(@NotNull PythonSdkAdditionalData from) {
     myFlavor = from.getFlavor();
-    myAddedPaths = from.myAddedPaths.clone(PyDisposable.getInstance());
-    myExcludedPaths = from.myExcludedPaths.clone(PyDisposable.getInstance());
+    myAddedPaths = from.myAddedPaths.clone(PythonPluginDisposable.getInstance());
+    myExcludedPaths = from.myExcludedPaths.clone(PythonPluginDisposable.getInstance());
     myAssociatedModulePath = from.myAssociatedModulePath;
   }
 
index a4966a44c187fa433dc1fd05d970748f7949d86b..db25f7b035786050a8afa4b0aed1ce366201860b 100644 (file)
@@ -35,7 +35,7 @@ import com.intellij.testFramework.LightVirtualFile;
 import com.intellij.util.Consumer;
 import com.jetbrains.commandInterface.commandLine.CommandLineLanguage;
 import com.jetbrains.commandInterface.commandLine.psi.CommandLineFile;
-import com.jetbrains.python.PyDisposable;
+import com.jetbrains.python.PythonPluginDisposable;
 import com.jetbrains.python.psi.PyUtil;
 import com.jetbrains.toolWindowWithActions.ConsoleWithProcess;
 import kotlin.jvm.functions.Function1;
@@ -161,7 +161,7 @@ final class CommandConsole extends LanguageConsoleImpl implements Consumer<Strin
     console.switchToCommandMode();
     console.getComponent(); // For some reason console does not have component until this method is called which leads to some errros.
     console.getConsoleEditor().getSettings().setAdditionalLinesCount(2); // to prevent PY-15583
-    Disposer.register(PyDisposable.getInstance(module.getProject()), console); // To dispose console when project disposes
+    Disposer.register(PythonPluginDisposable.getInstance(module.getProject()), console); // To dispose console when project disposes
     console.addMessageFilter(new UrlFilter());
     return console;
   }
index b85a324b835ed6121e10b714f46c82ba368cca3f..37560611d1329d1b31a4234fcd6c0a46161fb048 100644 (file)
@@ -11,7 +11,7 @@ import com.intellij.openapi.components.service
 import com.intellij.openapi.diagnostic.Logger
 import com.intellij.util.ui.update.MergingUpdateQueue
 import com.intellij.util.ui.update.Update
-import com.jetbrains.python.PyDisposable
+import com.jetbrains.python.PythonPluginDisposable
 import java.util.concurrent.ExecutionException
 
 @Service
@@ -23,7 +23,7 @@ class PrevCallsModelsProviderService {
     .softValues()
     .maximumSize(40)
     .build(object: CacheLoader<String, PrevCallsModel>() {
-      override fun load(expression: String): PrevCallsModel? {
+      override fun load(expression: String): PrevCallsModel {
         val result = PrevCallsModelsLoader.getModelForExpression(expression)
         if (result == null) throw ModelNotFoundException()
         return result
@@ -31,7 +31,7 @@ class PrevCallsModelsProviderService {
     })
 
   private val modelsLoadingQueue = MergingUpdateQueue("ModelsLoadingQueue", 1000, true, null,
-                                                      PyDisposable.getInstance(), null, false)
+                                                      PythonPluginDisposable.getInstance(), null, false)
   private fun createUpdate(identity: Any, runnable: () -> Unit) = object : Update(identity) {
     override fun canEat(update: Update?) = this == update
     override fun run() = runnable()
index 3ee804b6cf5b2d9f0a3e416f973f770823a500d3..c17b8705768726e747b84bc6a39f2f307f71ff6b 100644 (file)
@@ -72,7 +72,7 @@ import com.intellij.xdebugger.XDebugProcessStarter;
 import com.intellij.xdebugger.XDebugSession;
 import com.intellij.xdebugger.XDebuggerManager;
 import com.jetbrains.python.PyBundle;
-import com.jetbrains.python.PyDisposable;
+import com.jetbrains.python.PythonPluginDisposable;
 import com.jetbrains.python.console.actions.ShowVarsAction;
 import com.jetbrains.python.console.pydev.ConsoleCommunicationListener;
 import com.jetbrains.python.debugger.PyDebugRunner;
@@ -265,7 +265,7 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner {
 
   @Override
   public void run(boolean requestEditorFocus) {
-    TransactionGuard.submitTransaction(PyDisposable.getInstance(myProject), () -> FileDocumentManager.getInstance().saveAllDocuments());
+    TransactionGuard.submitTransaction(PythonPluginDisposable.getInstance(myProject), () -> FileDocumentManager.getInstance().saveAllDocuments());
 
     ApplicationManager.getApplication().executeOnPooledThread(
       () -> ProgressManager.getInstance().run(new Task.Backgroundable(myProject, PyBundle.message("connecting.to.console.title"), false) {
@@ -778,7 +778,7 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner {
 
     final RunContentDescriptor contentDescriptor =
       new RunContentDescriptor(myConsoleView, myProcessHandler, mainPanel, myConsoleInitTitle, null);
-    Disposer.register(PyDisposable.getInstance(myProject), contentDescriptor);
+    Disposer.register(PythonPluginDisposable.getInstance(myProject), contentDescriptor);
 
     contentDescriptor.setFocusComputable(() -> myConsoleView.getConsoleEditor().getContentComponent());
     contentDescriptor.setAutoFocusContent(true);
index dafba2dd75d8291b94ca44651e462fc305ec1490..245ef31bc4f73d8dbfe8e223cad684d343623955 100644 (file)
@@ -6,7 +6,7 @@ import com.intellij.openapi.project.DumbAware
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.wm.ToolWindow
 import com.intellij.openapi.wm.ToolWindowFactory
-import com.jetbrains.python.PyDisposable
+import com.jetbrains.python.PythonPluginDisposable
 import org.jetbrains.annotations.NonNls
 
 class PythonConsoleToolWindowFactory : ToolWindowFactory, DumbAware {
@@ -16,7 +16,7 @@ class PythonConsoleToolWindowFactory : ToolWindowFactory, DumbAware {
     // we need it to distinguish Console toolwindows started by Console Runner from ones started by toolwindow activation
     if (isStartedFromRunner != "true") {
       val runner = PythonConsoleRunnerFactory.getInstance().createConsoleRunner(project, null)
-      TransactionGuard.submitTransaction(PyDisposable.getInstance(project), Runnable { runner.runSync(true) })
+      TransactionGuard.submitTransaction(PythonPluginDisposable.getInstance(project), Runnable { runner.runSync(true) })
     }
   }
 
index feb3d319fe755a08ca60d96fff571a2622e74a44..1f17b426054a045ebba810b1563ea60fac57198a 100644 (file)
@@ -22,7 +22,7 @@ import com.intellij.ui.tabs.impl.JBEditorTabs;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.xdebugger.XDebuggerManager;
 import com.jetbrains.python.PyBundle;
-import com.jetbrains.python.PyDisposable;
+import com.jetbrains.python.PythonPluginDisposable;
 import com.jetbrains.python.console.PydevConsoleCommunication;
 import com.jetbrains.python.debugger.PyDebugProcess;
 import com.jetbrains.python.debugger.PyDebugValue;
@@ -159,7 +159,7 @@ public final class PyDataView implements DumbAware {
   }
 
   public void init(@NotNull ToolWindow toolWindow) {
-    myTabs = new JBRunnerTabs(myProject, PyDisposable.getInstance(myProject));
+    myTabs = new JBRunnerTabs(myProject, PythonPluginDisposable.getInstance(myProject));
     myTabs.setDataProvider(dataId -> {
       if (PlatformDataKeys.HELP_ID.is(dataId)) {
         return HELP_ID;
index 454fa609d024d2c851c04c0c668057cfbd907af3..d347122e501f84c0827e46fd8e00ea15604f160e 100644 (file)
@@ -19,8 +19,8 @@ import com.intellij.openapi.util.Disposer
 import com.intellij.openapi.util.use
 import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
 import com.jetbrains.python.PyBundle
-import com.jetbrains.python.PyDisposable
 import com.jetbrains.python.PySdkBundle
+import com.jetbrains.python.PythonPluginDisposable
 import com.jetbrains.python.inspections.PyInspectionExtension
 import com.jetbrains.python.inspections.PyPackageRequirementsInspection
 import com.jetbrains.python.psi.PyFile
@@ -65,7 +65,7 @@ object PyProjectSdkConfiguration {
     val project = module.project
 
     val lifetime = Disposer.newDisposable(
-      PyDisposable.getInstance(project),
+      PythonPluginDisposable.getInstance(project),
       "Configuring sdk using ${extension.javaClass.name} extension"
     )