Search in sources :

Example 1 with ProjectManagerImpl

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

the class ApplicationImpl method disposeSelf.

private boolean disposeSelf(final boolean checkCanCloseProject) {
    final ProjectManagerImpl manager = (ProjectManagerImpl) ProjectManagerEx.getInstanceEx();
    if (manager != null) {
        final boolean[] canClose = { true };
        for (final Project project : manager.getOpenProjects()) {
            try {
                CommandProcessor.getInstance().executeCommand(project, () -> {
                    if (!manager.closeProject(project, true, true, checkCanCloseProject)) {
                        canClose[0] = false;
                    }
                }, ApplicationBundle.message("command.exit"), null);
            } catch (Throwable e) {
                LOG.error(e);
            }
            if (!canClose[0]) {
                return false;
            }
        }
    }
    runWriteAction(() -> Disposer.dispose(this));
    Disposer.assertIsEmpty();
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Example 2 with ProjectManagerImpl

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

the class PlatformTestCase method cleanupApplicationCaches.

public static void cleanupApplicationCaches(Project project) {
    if (project != null && !project.isDisposed()) {
        UndoManagerImpl globalInstance = (UndoManagerImpl) UndoManager.getGlobalInstance();
        if (globalInstance != null) {
            globalInstance.dropHistoryInTests();
        }
        ((UndoManagerImpl) UndoManager.getInstance(project)).dropHistoryInTests();
        ((DocumentReferenceManagerImpl) DocumentReferenceManager.getInstance()).cleanupForNextTest();
        ((PsiManagerImpl) PsiManager.getInstance(project)).cleanupForNextTest();
    }
    final ProjectManager projectManager = ProjectManager.getInstance();
    assert projectManager != null : "The ProjectManager is not initialized yet";
    ProjectManagerImpl projectManagerImpl = (ProjectManagerImpl) projectManager;
    if (projectManagerImpl.isDefaultProjectInitialized()) {
        Project defaultProject = projectManager.getDefaultProject();
        ((PsiManagerImpl) PsiManager.getInstance(defaultProject)).cleanupForNextTest();
    }
    AsyncHighlighterUpdater.completeAsyncTasks();
    ((FileBasedIndexImpl) FileBasedIndex.getInstance()).cleanupForNextTest();
    LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl) LocalFileSystem.getInstance();
    if (localFileSystem != null) {
        localFileSystem.cleanupForNextTest();
    }
}
Also used : UndoManagerImpl(com.intellij.openapi.command.impl.UndoManagerImpl) Project(com.intellij.openapi.project.Project) DocumentReferenceManagerImpl(com.intellij.openapi.command.impl.DocumentReferenceManagerImpl) PsiManagerImpl(com.intellij.psi.impl.PsiManagerImpl) FileBasedIndexImpl(com.intellij.util.indexing.FileBasedIndexImpl) LocalFileSystemImpl(com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl) ProjectManager(com.intellij.openapi.project.ProjectManager) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Example 3 with ProjectManagerImpl

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

the class DummyCachingFileSystem method getProject.

@Nullable
public Project getProject(@Nullable String projectId) {
    Project project = ((ProjectManagerImpl) ProjectManager.getInstance()).findOpenProjectByHash(projectId);
    if (ApplicationManager.getApplication().isUnitTestMode() && project != null) {
        registerDisposeCallback(project);
        DISPOSE_CALLBACK.set(project, Boolean.TRUE);
    }
    return project;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ProjectManagerImpl

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

the class DaemonRespondToChangesTest method tearDown.

@Override
protected void tearDown() throws Exception {
    try {
        Project project = getProject();
        if (project != null) {
            doPostponedFormatting(project);
            ((ProjectManagerImpl) ProjectManagerEx.getInstanceEx()).closeProject(project, false, false, false);
        }
    } finally {
        myDaemonCodeAnalyzer = null;
        super.tearDown();
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Example 5 with ProjectManagerImpl

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

the class ThemeEditorVirtualFileTest method testRightProject.

/**
   * Tests that the theme editor works with the right virtual file
   * when there are several projects with the same name open.
   */
public void testRightProject() throws IOException {
    ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
    Project otherProject = projectManager.newProject(getProject().getName(), FileUtilRt.generateRandomTemporaryPath().getPath(), true, true);
    try {
        assertNotNull(otherProject);
        projectManager.openProject(otherProject);
        ThemeEditorVirtualFile themeEditorVirtualFile = ThemeEditorVirtualFile.getThemeEditorFile(myModule.getProject());
        VirtualFile virtualFile = themeEditorVirtualFile.getFileSystem().findFileByPath(themeEditorVirtualFile.getPath());
        assertEquals(themeEditorVirtualFile, virtualFile);
    } finally {
        if (otherProject != null) {
            ((ProjectManagerImpl) projectManager).forceCloseProject(otherProject, true);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) 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