Search in sources :

Example 6 with ProjectManagerImpl

use of com.intellij.openapi.project.impl.ProjectManagerImpl in project android by JetBrains.

the class GradleModuleImportTest method tearDown.

/**
   * {@link ProjectManagerEx}
   */
@Override
protected void tearDown() throws Exception {
    try {
        if (myFixture != null) {
            myFixture.tearDown();
            myFixture = null;
        }
        ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
        Project[] openProjects = projectManager.getOpenProjects();
        if (openProjects.length > 0) {
            final Project project = openProjects[0];
            ApplicationManager.getApplication().runWriteAction(new Runnable() {

                @Override
                public void run() {
                    Disposer.dispose(project);
                    ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
                    if (projectManager instanceof ProjectManagerImpl) {
                        Collection<Project> projectsStillOpen = projectManager.closeTestProject(project);
                        if (!projectsStillOpen.isEmpty()) {
                            Project project = projectsStillOpen.iterator().next();
                            projectsStillOpen.clear();
                            throw new AssertionError("Test project is not disposed: " + project + ";\n created in: " + PlatformTestCase.getCreationPlace(project));
                        }
                    }
                }
            });
        }
        if (dir != null && dir.isDirectory()) {
            ApplicationManager.getApplication().runWriteAction(new ThrowableComputable<Boolean, IOException>() {

                @Override
                public Boolean compute() throws IOException {
                    VirtualFile vfile = findFileByIoFile(dir, true);
                    if (vfile != null) {
                        vfile.delete(GradleModuleImportTest.this);
                    }
                    return true;
                }
            });
        }
    } finally {
        super.tearDown();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) IOException(java.io.IOException) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Example 7 with ProjectManagerImpl

use of com.intellij.openapi.project.impl.ProjectManagerImpl in project intellij-community by JetBrains.

the class PlatformTestCase method closeAndDisposeProjectAndCheckThatNoOpenProjects.

public static void closeAndDisposeProjectAndCheckThatNoOpenProjects(@NotNull final Project projectToClose) {
    RunAll runAll = new RunAll();
    ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
    if (projectManager instanceof ProjectManagerImpl) {
        for (Project project : projectManager.closeTestProject(projectToClose)) {
            runAll = runAll.append(() -> {
                throw new IllegalStateException("Test project is not disposed: " + project + ";\n created in: " + getCreationPlace(project));
            }).append(() -> ((ProjectManagerImpl) projectManager).closeProject(project, false, true, false));
        }
    }
    runAll.append(() -> WriteAction.run(() -> Disposer.dispose(projectToClose))).run();
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Example 8 with ProjectManagerImpl

use of com.intellij.openapi.project.impl.ProjectManagerImpl in project intellij-community by JetBrains.

the class LightPlatformTestCase method clearUncommittedDocuments.

public static void clearUncommittedDocuments(@NotNull Project project) {
    PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl) PsiDocumentManager.getInstance(project);
    documentManager.clearUncommittedDocuments();
    ProjectManagerImpl projectManager = (ProjectManagerImpl) ProjectManager.getInstance();
    if (projectManager.isDefaultProjectInitialized()) {
        Project defaultProject = projectManager.getDefaultProject();
        ((PsiDocumentManagerImpl) PsiDocumentManager.getInstance(defaultProject)).clearUncommittedDocuments();
    }
}
Also used : Project(com.intellij.openapi.project.Project) PsiDocumentManagerImpl(com.intellij.psi.impl.PsiDocumentManagerImpl) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Aggregations

Project (com.intellij.openapi.project.Project)8 ProjectManagerImpl (com.intellij.openapi.project.impl.ProjectManagerImpl)8 ProjectManagerEx (com.intellij.openapi.project.ex.ProjectManagerEx)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 DocumentReferenceManagerImpl (com.intellij.openapi.command.impl.DocumentReferenceManagerImpl)1 UndoManagerImpl (com.intellij.openapi.command.impl.UndoManagerImpl)1 ProjectManager (com.intellij.openapi.project.ProjectManager)1 LocalFileSystemImpl (com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl)1 PsiDocumentManagerImpl (com.intellij.psi.impl.PsiDocumentManagerImpl)1 PsiManagerImpl (com.intellij.psi.impl.PsiManagerImpl)1 FileBasedIndexImpl (com.intellij.util.indexing.FileBasedIndexImpl)1 IOException (java.io.IOException)1 Nullable (org.jetbrains.annotations.Nullable)1