Search in sources :

Example 6 with ProjectRootManagerEx

use of com.intellij.openapi.roots.ex.ProjectRootManagerEx in project intellij-community by JetBrains.

the class UpdateCacheTest method testAddExcludeRoot.

public void testAddExcludeRoot() throws Exception {
    // to initialize caches
    PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems();
    ProjectRootManagerEx rootManager = (ProjectRootManagerEx) ProjectRootManager.getInstance(myProject);
    final VirtualFile root = rootManager.getContentRoots()[0];
    final VirtualFile dir = root.findChild("aDir");
    new WriteCommandAction.Simple(getProject()) {

        @Override
        protected void run() throws Throwable {
            VirtualFile newFile = createChildData(dir, "New.java");
            setFileText(newFile, "class A{ Exception e;} //todo");
        }
    }.execute().throwException();
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    PsiTestUtil.addExcludedRoot(myModule, dir);
    PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
    assertNotNull(exceptionClass);
    checkUsages(exceptionClass, new String[] { "1.java" });
    checkTodos(new String[] {});
}
Also used : ProjectRootManagerEx(com.intellij.openapi.roots.ex.ProjectRootManagerEx) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 7 with ProjectRootManagerEx

use of com.intellij.openapi.roots.ex.ProjectRootManagerEx in project intellij-community by JetBrains.

the class UpdateCacheTest method testRemoveExcludeRoot.

public void testRemoveExcludeRoot() throws Exception {
    ProjectRootManagerEx rootManager = (ProjectRootManagerEx) ProjectRootManager.getInstance(myProject);
    final VirtualFile root = rootManager.getContentRoots()[0];
    final VirtualFile dir = root.findChild("aDir");
    PsiTestUtil.addExcludedRoot(myModule, dir);
    // to initialize caches
    PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems();
    new WriteCommandAction.Simple(getProject()) {

        @Override
        protected void run() throws Throwable {
            VirtualFile newFile = createChildData(dir, "New.java");
            setFileText(newFile, "class A{ Exception e;} //todo");
        }
    }.execute().throwException();
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    // to update caches
    PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems();
    PsiTestUtil.removeExcludedRoot(myModule, dir);
    PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
    assertNotNull(exceptionClass);
    checkUsages(exceptionClass, new String[] { "1.java", "2.java", "New.java" });
    checkTodos(new String[] { "2.java", "New.java" });
}
Also used : ProjectRootManagerEx(com.intellij.openapi.roots.ex.ProjectRootManagerEx) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 8 with ProjectRootManagerEx

use of com.intellij.openapi.roots.ex.ProjectRootManagerEx in project intellij-community by JetBrains.

the class UpdateCacheTest method testSCR6066.

public void testSCR6066() throws Exception {
    ProjectRootManagerEx rootManager = (ProjectRootManagerEx) ProjectRootManager.getInstance(myProject);
    final VirtualFile root = rootManager.getContentRoots()[0];
    // to initialize caches
    PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems();
    new WriteCommandAction.Simple(getProject()) {

        @Override
        protected void run() throws Throwable {
            VirtualFile newFile = createChildData(root, "New.java");
            setFileText(newFile, "class A{ Exception e;} //todo");
        }
    }.execute().throwException();
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    // to update caches
    PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems();
    PsiTestUtil.addExcludedRoot(myModule, root);
    PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
    assertNotNull(exceptionClass);
    checkUsages(exceptionClass, new String[] {});
    checkTodos(new String[] {});
}
Also used : ProjectRootManagerEx(com.intellij.openapi.roots.ex.ProjectRootManagerEx) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 9 with ProjectRootManagerEx

use of com.intellij.openapi.roots.ex.ProjectRootManagerEx in project intellij-community by JetBrains.

the class ModuleRootManagerImpl method makeRootsChange.

void makeRootsChange(@NotNull Runnable runnable) {
    ProjectRootManagerEx projectRootManagerEx = (ProjectRootManagerEx) ProjectRootManager.getInstance(myModule.getProject());
    // IMPORTANT: should be the first listener!
    projectRootManagerEx.makeRootsChange(runnable, false, myModule.isLoaded());
}
Also used : ProjectRootManagerEx(com.intellij.openapi.roots.ex.ProjectRootManagerEx)

Aggregations

ProjectRootManagerEx (com.intellij.openapi.roots.ex.ProjectRootManagerEx)9 Sdk (com.intellij.openapi.projectRoots.Sdk)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)2 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)1 JavaSdkVersion (com.intellij.openapi.projectRoots.JavaSdkVersion)1 InheritedJdkOrderEntry (com.intellij.openapi.roots.InheritedJdkOrderEntry)1 LanguageLevelProjectExtension (com.intellij.openapi.roots.LanguageLevelProjectExtension)1 RootPolicy (com.intellij.openapi.roots.RootPolicy)1 ProjectLibraryTable (com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable)1 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Nullable (org.jetbrains.annotations.Nullable)1