Search in sources :

Example 6 with CacheManager

use of com.intellij.psi.impl.cache.CacheManager in project intellij-community by JetBrains.

the class IdCacheTest method testUpdateCacheNoTodo.

public void testUpdateCacheNoTodo() throws Exception {
    createChildData(myRootDir, "4.java");
    final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
    final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
    checkResult(new String[] { "1.java", "2.java" }, convert(cache.getFilesWithWord("b", UsageSearchContext.ANY, scope, false)));
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) CacheManager(com.intellij.psi.impl.cache.CacheManager)

Example 7 with CacheManager

use of com.intellij.psi.impl.cache.CacheManager in project intellij-community by JetBrains.

the class IdCacheTest method testUpdateCache3.

public void testUpdateCache3() throws Exception {
    VirtualFile child = myRootDir.findChild("1.java");
    delete(child);
    final CacheManager cache2 = CacheManager.SERVICE.getInstance(myProject);
    final TodoCacheManager todocache2 = TodoCacheManager.SERVICE.getInstance(myProject);
    final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
    checkResult(ArrayUtil.EMPTY_STRING_ARRAY, convert(cache2.getFilesWithWord("xxx", UsageSearchContext.ANY, scope, false)));
    checkResult(ArrayUtil.EMPTY_STRING_ARRAY, convert(cache2.getFilesWithWord("a", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "2.java" }, convert(cache2.getFilesWithWord("b", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "2.java", "3.java" }, convert(cache2.getFilesWithWord("c", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "2.java", "3.java" }, convert(cache2.getFilesWithWord("d", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "3.java" }, convert(cache2.getFilesWithWord("e", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "3.java" }, convert(todocache2.getFilesWithTodoItems()));
    assertEquals(0, todocache2.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(2, todocache2.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) CacheManager(com.intellij.psi.impl.cache.CacheManager)

Example 8 with CacheManager

use of com.intellij.psi.impl.cache.CacheManager in project intellij-community by JetBrains.

the class IdCacheTest method testFileCreation.

public void testFileCreation() throws Exception {
    final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
    final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
    checkCache(cache, todocache);
    VirtualFile child = createChildData(myRootDir, "4.java");
    setFileText(child, "xxx //todo");
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
    checkResult(new String[] { "4.java" }, convert(cache.getFilesWithWord("xxx", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "1.java" }, convert(cache.getFilesWithWord("a", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "1.java", "2.java" }, convert(cache.getFilesWithWord("b", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "1.java", "2.java", "3.java" }, convert(cache.getFilesWithWord("c", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "2.java", "3.java" }, convert(cache.getFilesWithWord("d", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "3.java" }, convert(cache.getFilesWithWord("e", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "1.java", "3.java", "4.java" }, convert(todocache.getFilesWithTodoItems()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(2, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("4.java"), TodoIndexPatternProvider.getInstance()));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) CacheManager(com.intellij.psi.impl.cache.CacheManager)

Example 9 with CacheManager

use of com.intellij.psi.impl.cache.CacheManager in project intellij-community by JetBrains.

the class IdCacheTest method testCrash.

public void testCrash() throws Exception {
    final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
    cache.getFilesWithWord("xxx", UsageSearchContext.ANY, GlobalSearchScope.projectScope(myProject), false);
    System.gc();
}
Also used : TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) CacheManager(com.intellij.psi.impl.cache.CacheManager)

Example 10 with CacheManager

use of com.intellij.psi.impl.cache.CacheManager in project intellij-community by JetBrains.

the class IdCacheTest method testFileModification.

public void testFileModification() throws Exception {
    final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
    final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
    checkCache(cache, todocache);
    VirtualFile child = myRootDir.findChild("1.java");
    checkCache(cache, todocache);
    setFileText(child, "xxx");
    setFileText(child, "xxx");
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
    checkResult(new String[] { "1.java" }, convert(cache.getFilesWithWord("xxx", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] {}, convert(cache.getFilesWithWord("a", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "2.java" }, convert(cache.getFilesWithWord("b", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "2.java", "3.java" }, convert(cache.getFilesWithWord("c", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "2.java", "3.java" }, convert(cache.getFilesWithWord("d", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "3.java" }, convert(cache.getFilesWithWord("e", UsageSearchContext.ANY, scope, false)));
    checkResult(new String[] { "3.java" }, convert(todocache.getFilesWithTodoItems()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(2, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) TodoCacheManager(com.intellij.psi.impl.cache.TodoCacheManager) CacheManager(com.intellij.psi.impl.cache.CacheManager)

Aggregations

CacheManager (com.intellij.psi.impl.cache.CacheManager)10 TodoCacheManager (com.intellij.psi.impl.cache.TodoCacheManager)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)7 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 TrigramBuilder (com.intellij.openapi.util.text.TrigramBuilder)1 PsiFile (com.intellij.psi.PsiFile)1 PsiSearchHelperImpl (com.intellij.psi.impl.search.PsiSearchHelperImpl)1 HashMap (com.intellij.util.containers.HashMap)1 HashSet (com.intellij.util.containers.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 NotNull (org.jetbrains.annotations.NotNull)1