use of com.intellij.psi.impl.cache.TodoCacheManager 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.TodoCacheManager 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