Java 类com.intellij.psi.impl.cache.TodoCacheManager 实例源码

项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testUpdateCache2() throws Exception {
  VirtualFile child = myRootDir.findChild("1.java");
  VfsUtil.saveText(child, "xxx");

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  FileDocumentManager.getInstance().saveAllDocuments();

  final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
  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()));
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testUpdateCache3() throws Exception {
  VirtualFile child = myRootDir.findChild("1.java");
  child.delete(null);

  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()));
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testUpdateOnTodoChange() throws Exception {
  TodoPattern pattern = new TodoPattern("newtodo", TodoAttributesUtil.createDefault(), true);
  TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns();
  TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[]{pattern});

  try{
    final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
    checkResult(new String[]{"2.java"}, convert(todocache.getFilesWithTodoItems()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
  }
  finally{
    TodoConfiguration.getInstance().setTodoPatterns(oldPatterns);
  }
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
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);

  VfsUtil.saveText(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()));
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testFileDeletion() 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");
  child.delete(null);

  final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
  checkResult(new String[]{}, 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("2.java"), TodoIndexPatternProvider.getInstance()));
  assertEquals(2, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testFileCreation() throws Exception {
  final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
  checkCache(cache, todocache);

  VirtualFile child = myRootDir.createChildData(null, "4.java");
  VfsUtil.saveText(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()));
}
项目:intellij-ce-playground    文件:IndexPatternSearcher.java   
@Override
public boolean execute(@NotNull final IndexPatternSearch.SearchParameters queryParameters,
                       @NotNull final Processor<IndexPatternOccurrence> consumer) {
  final PsiFile file = queryParameters.getFile();
  VirtualFile virtualFile = file.getVirtualFile();
  if (file instanceof PsiBinaryFile || file instanceof PsiCompiledElement || virtualFile == null) {
    return true;
  }

  final TodoCacheManager cacheManager = TodoCacheManager.SERVICE.getInstance(file.getProject());
  final IndexPatternProvider patternProvider = queryParameters.getPatternProvider();
  int count = patternProvider != null
              ? cacheManager.getTodoCount(virtualFile, patternProvider)
              : cacheManager.getTodoCount(virtualFile, queryParameters.getPattern());
  return count == 0 || executeImpl(queryParameters, consumer);
}
项目:tools-idea    文件:IdCacheTest.java   
public void testUpdateCache2() throws Exception {
  VirtualFile child = myRootDir.findChild("1.java");
  VfsUtil.saveText(child, "xxx");

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  FileDocumentManager.getInstance().saveAllDocuments();

  final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
  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()));
}
项目:tools-idea    文件:IdCacheTest.java   
public void testUpdateCache3() throws Exception {
  VirtualFile child = myRootDir.findChild("1.java");
  child.delete(null);

  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()));
}
项目:tools-idea    文件:IdCacheTest.java   
public void testUpdateOnTodoChange() throws Exception {
  TodoPattern pattern = new TodoPattern("newtodo", TodoAttributes.createDefault(), true);
  TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns();
  TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[]{pattern});

  try{
    final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
    checkResult(new String[]{"2.java"}, convert(todocache.getFilesWithTodoItems()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
  }
  finally{
    TodoConfiguration.getInstance().setTodoPatterns(oldPatterns);
  }
}
项目:tools-idea    文件:IdCacheTest.java   
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);

  VfsUtil.saveText(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()));
}
项目:tools-idea    文件:IdCacheTest.java   
public void testFileDeletion() 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");
  child.delete(null);

  final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
  checkResult(new String[]{}, 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("2.java"), TodoIndexPatternProvider.getInstance()));
  assertEquals(2, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
}
项目:tools-idea    文件:IdCacheTest.java   
public void testFileCreation() throws Exception {
  final CacheManager cache = CacheManager.SERVICE.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.SERVICE.getInstance(myProject);
  checkCache(cache, todocache);

  VirtualFile child = myRootDir.createChildData(null, "4.java");
  VfsUtil.saveText(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()));
}
项目:tools-idea    文件:IndexPatternSearcher.java   
@Override
public boolean execute(@NotNull final IndexPatternSearch.SearchParameters queryParameters,
                       @NotNull final Processor<IndexPatternOccurrence> consumer) {
  final PsiFile file = queryParameters.getFile();
  VirtualFile virtualFile = file.getVirtualFile();
  if (file instanceof PsiBinaryFile || file instanceof PsiCompiledElement || virtualFile == null) {
    return true;
  }

  final TodoCacheManager cacheManager = TodoCacheManager.SERVICE.getInstance(file.getProject());
  final IndexPatternProvider patternProvider = queryParameters.getPatternProvider();
  int count = patternProvider != null
              ? cacheManager.getTodoCount(virtualFile, patternProvider)
              : cacheManager.getTodoCount(virtualFile, queryParameters.getPattern());
  return count == 0 || executeImpl(queryParameters, consumer);
}
项目:consulo    文件:IndexPatternSearcher.java   
@Override
public boolean execute(@Nonnull final IndexPatternSearch.SearchParameters queryParameters,
                       @Nonnull final Processor<IndexPatternOccurrence> consumer) {
  final PsiFile file = queryParameters.getFile();
  VirtualFile virtualFile = file.getVirtualFile();
  if (file instanceof PsiBinaryFile || file instanceof PsiCompiledElement || virtualFile == null) {
    return true;
  }

  final TodoCacheManager cacheManager = TodoCacheManager.getInstance(file.getProject());
  final IndexPatternProvider patternProvider = queryParameters.getPatternProvider();
  int count = patternProvider != null
              ? cacheManager.getTodoCount(virtualFile, patternProvider)
              : cacheManager.getTodoCount(virtualFile, queryParameters.getPattern());
  return count == 0 || executeImpl(queryParameters, consumer);
}
项目:consulo-java    文件:IdCacheTest.java   
public void testUpdateCache2() throws Exception {
  VirtualFile child = myRootDir.findChild("1.java");
  VfsUtil.saveText(child, "xxx");

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  FileDocumentManager.getInstance().saveAllDocuments();

  final CacheManager cache = CacheManager.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.getInstance(myProject);
  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()));
}
项目:consulo-java    文件:IdCacheTest.java   
public void testUpdateCache3() throws Exception {
  VirtualFile child = myRootDir.findChild("1.java");
  child.delete(null);

  final CacheManager cache2 = CacheManager.getInstance(myProject);
  final TodoCacheManager todocache2 = TodoCacheManager.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()));
}
项目:consulo-java    文件:IdCacheTest.java   
public void testUpdateOnTodoChange() throws Exception {
  TodoPattern pattern = new TodoPattern("newtodo", TodoAttributesUtil.createDefault(), true);
  TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns();
  TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[]{pattern});

  try{
    final TodoCacheManager todocache = TodoCacheManager.getInstance(myProject);
    checkResult(new String[]{"2.java"}, convert(todocache.getFilesWithTodoItems()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("1.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(1, todocache.getTodoCount(myRootDir.findChild("2.java"), TodoIndexPatternProvider.getInstance()));
    assertEquals(0, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
  }
  finally{
    TodoConfiguration.getInstance().setTodoPatterns(oldPatterns);
  }
}
项目:consulo-java    文件:IdCacheTest.java   
public void testFileModification() throws Exception {
  final CacheManager cache = CacheManager.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.getInstance(myProject);
  checkCache(cache, todocache);

  VirtualFile child = myRootDir.findChild("1.java");

  checkCache(cache, todocache);

  VfsUtil.saveText(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()));
}
项目:consulo-java    文件:IdCacheTest.java   
public void testFileDeletion() throws Exception {
  final CacheManager cache = CacheManager.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.getInstance(myProject);
  checkCache(cache, todocache);

  VirtualFile child = myRootDir.findChild("1.java");
  child.delete(null);

  final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
  checkResult(new String[]{}, 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("2.java"), TodoIndexPatternProvider.getInstance()));
  assertEquals(2, todocache.getTodoCount(myRootDir.findChild("3.java"), TodoIndexPatternProvider.getInstance()));
}
项目:consulo-java    文件:IdCacheTest.java   
public void testFileCreation() throws Exception {
  final CacheManager cache = CacheManager.getInstance(myProject);
  final TodoCacheManager todocache = TodoCacheManager.getInstance(myProject);
  checkCache(cache, todocache);

  VirtualFile child = myRootDir.createChildData(null, "4.java");
  VfsUtil.saveText(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()));
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
private void checkCache(CacheManager cache, TodoCacheManager todocache) {
  final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
  checkResult(ArrayUtil.EMPTY_STRING_ARRAY, 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"}, 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()));
}
项目:intellij-ce-playground    文件:PsiTodoSearchHelperImpl.java   
@Override
public int getTodoItemsCount(@NotNull PsiFile file, @NotNull TodoPattern pattern) {
  int count = TodoCacheManager.SERVICE.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), pattern.getIndexPattern());
  if (count != -1) return count;
  TodoItem[] items = findTodoItems(file);
  count = 0;
  for (TodoItem item : items) {
    if (item.getPattern().equals(pattern)) count++;
  }
  return count;
}
项目:tools-idea    文件:IdCacheTest.java   
private void checkCache(CacheManager cache, TodoCacheManager todocache) {
  final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
  checkResult(ArrayUtil.EMPTY_STRING_ARRAY, 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"}, 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()));
}
项目:tools-idea    文件:PsiTodoSearchHelperImpl.java   
@Override
public int getTodoItemsCount(@NotNull PsiFile file, @NotNull TodoPattern pattern) {
  int count = TodoCacheManager.SERVICE.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), pattern.getIndexPattern());
  if (count != -1) return count;
  TodoItem[] items = findTodoItems(file);
  count = 0;
  for (TodoItem item : items) {
    if (item.getPattern().equals(pattern)) count++;
  }
  return count;
}
项目:consulo    文件:PsiTodoSearchHelperImpl.java   
@Override
public int getTodoItemsCount(@Nonnull PsiFile file, @Nonnull TodoPattern pattern) {
  int count = TodoCacheManager.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), pattern.getIndexPattern());
  if (count != -1) return count;
  TodoItem[] items = findTodoItems(file);
  count = 0;
  for (TodoItem item : items) {
    if (item.getPattern().equals(pattern)) count++;
  }
  return count;
}
项目:consulo-java    文件:IdCacheTest.java   
private void checkCache(CacheManager cache, TodoCacheManager todocache) {
  final GlobalSearchScope scope = GlobalSearchScope.projectScope(myProject);
  checkResult(ArrayUtil.EMPTY_STRING_ARRAY, 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"}, 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()));
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testBuildCache() throws Exception {
  checkCache(CacheManager.SERVICE.getInstance(myProject), TodoCacheManager.SERVICE.getInstance(myProject));
}
项目:intellij-ce-playground    文件:IdCacheTest.java   
public void testUpdateCache1() throws Exception {
  myRootDir.createChildData(null, "4.java");
  Thread.sleep(1000);
  checkCache(CacheManager.SERVICE.getInstance(myProject), TodoCacheManager.SERVICE.getInstance(myProject));
}
项目:intellij-ce-playground    文件:IndexPatternSearchImpl.java   
@Override
protected int getOccurrencesCountImpl(@NotNull PsiFile file, @NotNull IndexPatternProvider provider) {
  int count = TodoCacheManager.SERVICE.getInstance(file.getProject()).getTodoCount(file.getVirtualFile(), provider);
  if (count != -1) return count;
  return search(file, provider).findAll().size();
}
项目:intellij-ce-playground    文件:IndexPatternSearchImpl.java   
@Override
protected int getOccurrencesCountImpl(@NotNull PsiFile file, @NotNull IndexPattern pattern) {
  int count = TodoCacheManager.SERVICE.getInstance(file.getProject()).getTodoCount(file.getVirtualFile(), pattern);
  if (count != -1) return count;
  return search(file, pattern).findAll().size();
}
项目:intellij-ce-playground    文件:PsiTodoSearchHelperImpl.java   
@Override
@NotNull
public PsiFile[] findFilesWithTodoItems() {
  return TodoCacheManager.SERVICE.getInstance(myManager.getProject()).getFilesWithTodoItems();
}
项目:intellij-ce-playground    文件:PsiTodoSearchHelperImpl.java   
@Override
public int getTodoItemsCount(@NotNull PsiFile file) {
  int count = TodoCacheManager.SERVICE.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), TodoIndexPatternProvider.getInstance());
  if (count != -1) return count;
  return findTodoItems(file).length;
}
项目:tools-idea    文件:IdCacheTest.java   
public void testBuildCache() throws Exception {
  checkCache(CacheManager.SERVICE.getInstance(myProject), TodoCacheManager.SERVICE.getInstance(myProject));
}
项目:tools-idea    文件:IdCacheTest.java   
public void testUpdateCache1() throws Exception {
  myRootDir.createChildData(null, "4.java");
  Thread.sleep(1000);
  checkCache(CacheManager.SERVICE.getInstance(myProject), TodoCacheManager.SERVICE.getInstance(myProject));
}
项目:tools-idea    文件:IndexPatternSearchImpl.java   
@Override
protected int getOccurrencesCountImpl(PsiFile file, IndexPatternProvider provider) {
  int count = TodoCacheManager.SERVICE.getInstance(file.getProject()).getTodoCount(file.getVirtualFile(), provider);
  if (count != -1) return count;
  return search(file, provider).findAll().size();
}
项目:tools-idea    文件:IndexPatternSearchImpl.java   
@Override
protected int getOccurrencesCountImpl(PsiFile file, IndexPattern pattern) {
  int count = TodoCacheManager.SERVICE.getInstance(file.getProject()).getTodoCount(file.getVirtualFile(), pattern);
  if (count != -1) return count;
  return search(file, pattern).findAll().size();
}
项目:tools-idea    文件:PsiTodoSearchHelperImpl.java   
@Override
@NotNull
public PsiFile[] findFilesWithTodoItems() {
  return TodoCacheManager.SERVICE.getInstance(myManager.getProject()).getFilesWithTodoItems();
}
项目:tools-idea    文件:PsiTodoSearchHelperImpl.java   
@Override
public int getTodoItemsCount(@NotNull PsiFile file) {
  int count = TodoCacheManager.SERVICE.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), TodoIndexPatternProvider.getInstance());
  if (count != -1) return count;
  return findTodoItems(file).length;
}
项目:consulo    文件:IndexPatternSearchImpl.java   
@Override
protected int getOccurrencesCountImpl(@Nonnull PsiFile file, @Nonnull IndexPatternProvider provider) {
  int count = TodoCacheManager.getInstance(file.getProject()).getTodoCount(file.getVirtualFile(), provider);
  if (count != -1) return count;
  return search(file, provider).findAll().size();
}