dispose explicitly because for some reasons flag dispose doesn't work

This commit is contained in:
Vladimir Krivosheev
2019-01-18 03:17:55 +01:00
parent 559b96a1f1
commit eb4c2f4656
8 changed files with 17 additions and 17 deletions
@@ -13,7 +13,6 @@ import com.intellij.openapi.diagnostic.DefaultLogger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
import com.intellij.openapi.roots.ProjectRootManager;
@@ -25,6 +24,7 @@ import com.intellij.psi.search.FilenameIndex;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.CompilerTester;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.TestDataProvider;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -105,7 +105,7 @@ public abstract class AbstractApplyAndRevertTestCase extends PlatformTestCase {
myCompilerTester.tearDown();
}
PathMacros.getInstance().setMacro(PathMacrosImpl.MAVEN_REPOSITORY, oldMacroValue);
ProjectManagerEx.getInstanceEx().forceCloseProject(myProject, true);
PlatformTestUtil.forceCloseProjectWithoutSaving(myProject);
myProject = null;
InspectionProfileImpl.INIT_INSPECTIONS = false;
}
@@ -6,12 +6,12 @@ import com.intellij.openapi.module.JavaModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import kotlin.Unit;
import java.io.File;
@@ -38,7 +38,7 @@ public class ModuleLoadingStressTest extends PlatformTestCase {
String projectFilePath = myProject.getProjectFilePath();
String moduleName = myModule.getName();
ProjectManagerEx.getInstanceEx().forceCloseProject(myProject, true);
PlatformTestUtil.forceCloseProjectWithoutSaving(myProject);
myProject = ProjectManager.getInstance().loadAndOpenProject(projectFilePath);
Module[] modules = ModuleManager.getInstance(myProject).getModules();
@@ -12,7 +12,6 @@ import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkTypeId;
@@ -29,6 +28,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.projectImport.ProjectImportProvider;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.Consumer;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ContainerUtil;
@@ -74,7 +74,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
myWizard = null;
}
if (myCreatedProject != null) {
ProjectManagerEx.getInstanceEx().forceCloseProject(myCreatedProject, true);
PlatformTestUtil.forceCloseProjectWithoutSaving(myCreatedProject);
myCreatedProject = null;
}
ApplicationManager.getApplication().runWriteAction(() -> {
@@ -8,7 +8,6 @@ import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.testFramework.LightPlatformTestCase;
@@ -178,7 +177,7 @@ public class LightFileTemplatesTest extends LightPlatformTestCase {
private static void closeProject(final Project project) {
if (project != null && !project.isDisposed()) {
ProjectManagerEx.getInstanceEx().forceCloseProject(project, true);
PlatformTestUtil.forceCloseProjectWithoutSaving(project);
}
}
@@ -10,7 +10,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.Disposer;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
@@ -100,8 +99,7 @@ public class ProjectOpeningTest extends PlatformTestCase {
static void closeProject(@Nullable Project project) {
if (project != null && !project.isDisposed()) {
ProjectManagerEx.getInstanceEx().forceCloseProject(project, false);
ApplicationManager.getApplication().runWriteAction(() -> Disposer.dispose(project));
PlatformTestUtil.forceCloseProjectWithoutSaving(project);
}
}
@@ -594,6 +594,12 @@ public class PlatformTestUtil {
}
}
public static void forceCloseProjectWithoutSaving(@NotNull Project project) {
ProjectManagerEx.getInstanceEx().forceCloseProject(project, false /* do not dispose */);
// explicitly dispose because `dispose` option for forceCloseProject doesn't work todo why?
getApplication().runWriteAction(() -> Disposer.dispose(project));
}
public static void saveProject(@NotNull Project project) {
saveProject(project, false);
}
@@ -12,13 +12,11 @@ import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.project.impl.ProjectLifecycleListener;
import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
@@ -254,8 +252,7 @@ public class GradleProjectOpenProcessorTest extends GradleImportingTestCase {
private static void closeProject(final Project project) {
if (project != null && !project.isDisposed()) {
ProjectManagerEx.getInstanceEx().forceCloseProject(project, false);
ApplicationManager.getApplication().runWriteAction(() -> Disposer.dispose(project));
PlatformTestUtil.forceCloseProjectWithoutSaving(project);
}
}
}
@@ -6,12 +6,12 @@ import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.roots.ModuleRootModificationUtil
import com.intellij.openapi.util.Computable
import com.intellij.openapi.vfs.VfsUtil
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.util.ui.UIUtil
import java.io.File
@@ -44,7 +44,7 @@ fun openProjectWithSdk(projectPath: String,
catch (e: Throwable) {
if (project != null) {
UIUtil.invokeAndWaitIfNeeded(Runnable {
ProjectManagerEx.getInstanceEx().forceCloseProject(project, true)
PlatformTestUtil.forceCloseProjectWithoutSaving(project)
})
}
throw e