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)));
}
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()));
}
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()));
}
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();
}
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()));
}
Aggregations