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

项目: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 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    文件:FormReferencesSearcher.java   
private static boolean processReferencesInUIForms(final Processor<PsiReference> processor,
                                                  PsiManager psiManager,
                                                  final PropertiesFile propFile,
                                                  final GlobalSearchScope globalSearchScope,
                                                  final LocalSearchScope filterScope) {
  final Project project = psiManager.getProject();
  GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope);
  final String baseName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return propFile.getResourceBundle().getBaseName();
    }
  });
  PsiFile containingFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
    @Override
    public PsiFile compute() {
      return propFile.getContainingFile();
    }
  });

  List<PsiFile> files = Arrays.asList(CacheManager.SERVICE.getInstance(project).getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true));
  return processReferencesInFiles(files, psiManager, baseName, containingFile, filterScope, processor);
}
项目:intellij    文件:GlobalWordIndexTest.java   
private void assertContainsWords(
    VirtualFile file,
    @MagicConstant(flagsFromClass = UsageSearchContext.class) short occurenceMask,
    String... words) {

  for (String word : words) {
    VirtualFile[] files =
        CacheManager.SERVICE
            .getInstance(getProject())
            .getVirtualFilesWithWord(
                word, occurenceMask, GlobalSearchScope.fileScope(getProject(), file), true);
    if (!Arrays.asList(files).contains(file)) {
      Assert.fail(String.format("Word '%s' not found in file '%s'", word, file));
    }
  }
}
项目: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 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    文件:FormReferencesSearcher.java   
private static boolean processReferencesInUIForms(final Processor<PsiReference> processor, final PropertiesFile propFile, final GlobalSearchScope globalSearchScope,
                                                 final LocalSearchScope filterScope) {
  final Project project = propFile.getProject();
  GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope);
  PsiManagerImpl manager = (PsiManagerImpl)propFile.getContainingFile().getManager();
  final String baseName = propFile.getResourceBundle().getBaseName();
  manager.startBatchFilesProcessingMode();

  try {
    PsiFile[] files = CacheManager.SERVICE.getInstance(project).getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true);

    for (PsiFile file : files) {
      ProgressManager.checkCanceled();

      if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue;
      if (!processReferences(processor, file, baseName, propFile.getContainingFile(), filterScope)) return false;
    }
  }
  finally {
    manager.finishBatchFilesProcessingMode();
  }

  return true;
}
项目: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 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    文件:DaemonAnalyzerTestCase.java   
@NotNull
protected Collection<HighlightInfo> checkHighlighting(@NotNull final ExpectedHighlightingData data) {
  data.init();
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  //to load text
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      TreeUtil.clearCaches((TreeElement)myFile.getNode());
    }
  });


  //to initialize caches
  if (!DumbService.isDumb(getProject())) {
    CacheManager.SERVICE.getInstance(myProject).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
  }
  final JavaPsiFacadeEx facade = getJavaFacade();
  if (facade != null) {
    facade.setAssertOnFileLoadingFilter(myVirtualFileFilter, myTestRootDisposable); // check repository work
  }

  try {
    Collection<HighlightInfo> infos = doHighlighting();

    String text = myEditor.getDocument().getText();
    data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text);
    data.checkResult(infos, text);
    return infos;
  }
  finally {
    if (facade != null) {
      facade.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myTestRootDisposable);
    }
  }
}
项目: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    文件:PsiSearchHelperImpl.java   
@Override
@NotNull
public PsiFile[] findFilesWithPlainTextWords(@NotNull String word) {
  return CacheManager.SERVICE.getInstance(myManager.getProject()).getFilesWithWord(word, UsageSearchContext.IN_PLAIN_TEXT,
                                                                                   GlobalSearchScope.projectScope(myManager.getProject()),
                                                                                   true);
}
项目:intellij-ce-playground    文件:PsiSearchHelperImpl.java   
@Override
public boolean processAllFilesWithWord(@NotNull String word,
                                       @NotNull GlobalSearchScope scope,
                                       @NotNull Processor<PsiFile> processor,
                                       final boolean caseSensitively) {
  return CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_CODE, scope, caseSensitively);
}
项目:intellij-ce-playground    文件:PsiSearchHelperImpl.java   
@Override
public boolean processAllFilesWithWordInText(@NotNull final String word,
                                             @NotNull final GlobalSearchScope scope,
                                             @NotNull final Processor<PsiFile> processor,
                                             final boolean caseSensitively) {
  return CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_PLAIN_TEXT, scope, caseSensitively);
}
项目:intellij-ce-playground    文件:CodeInsightTestFixtureImpl.java   
private long collectAndCheckHighlighting(@NotNull ExpectedHighlightingData data) {
  final Project project = getProject();
  PsiDocumentManager.getInstance(project).commitAllDocuments();

  PsiFileImpl file = (PsiFileImpl)getHostFile();
  FileElement hardRefToFileElement = file.calcTreeElement();//to load text

  //to initialize caches
  if (!DumbService.isDumb(project)) {
    CacheManager.SERVICE.getInstance(project).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true);
  }

  final long start = System.currentTimeMillis();
  final VirtualFileFilter fileTreeAccessFilter = myVirtualFileFilter;
  Disposable disposable = Disposer.newDisposable();
  if (fileTreeAccessFilter != null) {
    ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(fileTreeAccessFilter, disposable);
  }

  //    ProfilingUtil.startCPUProfiling();
  List<HighlightInfo> infos;
  try {
    infos = doHighlighting();
    removeDuplicatedRangesForInjected(infos);
  }
  finally {
    Disposer.dispose(disposable);
  }
  //    ProfilingUtil.captureCPUSnapshot("testing");
  final long elapsed = System.currentTimeMillis() - start;

  data.checkResult(infos, file.getText());
  hardRefToFileElement.hashCode(); // use it so gc won't collect it
  return elapsed;
}
项目:intellij-ce-playground    文件:AndroidFindStyleApplicationsProcessor.java   
private static void filterFilesToScan(CacheManager cacheManager,
                                      String s,
                                      Set<PsiFile> result,
                                      GlobalSearchScope scope) {
  for (String word : StringUtil.getWordsInStringLongestFirst(s)) {
    final PsiFile[] files = cacheManager.getFilesWithWord(word, UsageSearchContext.ANY, scope, true);
    result.retainAll(Arrays.asList(files));
  }
}
项目:intellij-ce-playground    文件:PatternEditorContextMembersProvider.java   
private static Set<String> calcDevPatternClassNames(@NotNull final Project project) {
  final List<String> roots = ContainerUtil.createLockFreeCopyOnWriteList();
  JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  PsiClass beanClass = psiFacade.findClass(PatternClassBean.class.getName(), GlobalSearchScope.allScope(project));
  if (beanClass != null) {
    GlobalSearchScope scope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), StdFileTypes.XML);
    final TextOccurenceProcessor occurenceProcessor = new TextOccurenceProcessor() {
      @Override
      public boolean execute(@NotNull PsiElement element, int offsetInElement) {
        XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
        String className = tag == null ? null : tag.getAttributeValue("className");
        if (StringUtil.isNotEmpty(className) && tag.getLocalName().endsWith("patternClass")) {
          roots.add(className);
        }
        return true;
      }
    };
    final StringSearcher searcher = new StringSearcher("patternClass", true, true);
    CacheManager.SERVICE.getInstance(beanClass.getProject()).processFilesWithWord(new Processor<PsiFile>() {
      @Override
      public boolean process(PsiFile psiFile) {
        LowLevelSearchUtil.processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true,
                                                                   new EmptyProgressIndicator());
        return true;
      }
    }, searcher.getPattern(), UsageSearchContext.IN_FOREIGN_LANGUAGES, scope, searcher.isCaseSensitive());
  }
  return ContainerUtil.newHashSet(roots);
}
项目:tools-idea    文件:DaemonAnalyzerTestCase.java   
@NotNull
protected Collection<HighlightInfo> checkHighlighting(@NotNull final ExpectedHighlightingData data) {
  data.init();
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  //to load text
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      TreeUtil.clearCaches((TreeElement)myFile.getNode());
    }
  });


  //to initialize caches
  if (!DumbService.isDumb(getProject())) {
    CacheManager.SERVICE.getInstance(myProject).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
  }
  final JavaPsiFacadeEx facade = getJavaFacade();
  if (facade != null) {
    facade.setAssertOnFileLoadingFilter(myFileTreeAccessFilter); // check repository work
  }

  Collection<HighlightInfo> infos = doHighlighting();

  if (facade != null) {
    facade.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
  }

  String text = myEditor.getDocument().getText();
  data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text);
  data.checkResult(infos, text);
  return infos;
}
项目: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    文件:PsiSearchHelperImpl.java   
@Override
@NotNull
public PsiFile[] findFilesWithPlainTextWords(@NotNull String word) {
  return CacheManager.SERVICE.getInstance(myManager.getProject()).getFilesWithWord(word, UsageSearchContext.IN_PLAIN_TEXT,
                                                                                   GlobalSearchScope.projectScope(myManager.getProject()),
                                                                                   true);
}
项目:tools-idea    文件:PsiSearchHelperImpl.java   
@Override
public boolean processAllFilesWithWord(@NotNull String word,
                                       @NotNull GlobalSearchScope scope,
                                       @NotNull Processor<PsiFile> processor,
                                       final boolean caseSensitively) {
  return CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_CODE, scope, caseSensitively);
}
项目:tools-idea    文件:PsiSearchHelperImpl.java   
@Override
public boolean processAllFilesWithWordInText(@NotNull final String word,
                                             @NotNull final GlobalSearchScope scope,
                                             @NotNull final Processor<PsiFile> processor,
                                             final boolean caseSensitively) {
  return CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_PLAIN_TEXT, scope, caseSensitively);
}
项目:tools-idea    文件:CodeInsightTestFixtureImpl.java   
private long collectAndCheckHighlightings(final ExpectedHighlightingData data) {
    final Project project = getProject();
    PsiDocumentManager.getInstance(project).commitAllDocuments();

    FileElement hardRefToFileElement = ((PsiFileImpl)myFile).calcTreeElement();//to load text

    //to initialize caches
    if (!DumbService.isDumb(project)) {
      CacheManager.SERVICE.getInstance(project).getFilesWithWord(XXX, UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true);
    }

    List<HighlightInfo> infos;
    final long start = System.currentTimeMillis();
    try {
      ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(myJavaFilesFilter);

//    ProfilingUtil.startCPUProfiling();
      infos = doHighlighting();
      removeDuplicatedRangesForInjected(infos);
//    ProfilingUtil.captureCPUSnapshot("testing");
    }
    finally {
      ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
    }
    final long elapsed = System.currentTimeMillis() - start;

    data.checkResult(infos, myEditor.getDocument().getText());
    hardRefToFileElement.hashCode(); // use it so gc won't collect it
    return elapsed;
  }
项目:tools-idea    文件:PatternEditorContextMembersProvider.java   
private static List<PsiElement> getRootsByClassNames(PsiFile file, String type) {
  final List<PsiElement> roots = ContainerUtil.createLockFreeCopyOnWriteList();

  final Project project = file.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  final PsiClass beanClass = psiFacade.findClass(PatternClassBean.class.getName(), GlobalSearchScope.allScope(project));
  if (beanClass != null) {
    final GlobalSearchScope scope =
      GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), StdFileTypes.XML);
    final TextOccurenceProcessor occurenceProcessor = new TextOccurenceProcessor() {
      @Override
      public boolean execute(PsiElement element, int offsetInElement) {
        final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
        final String className = tag == null ? null : tag.getAttributeValue("className");
        if (className != null && tag.getLocalName().endsWith("patternClass")) {
          ContainerUtil.addIfNotNull(psiFacade.findClass(className, GlobalSearchScope.allScope(project)), roots);
        }
        return true;
      }
    };
    final StringSearcher searcher = new StringSearcher("patternClass", true, true);
    CacheManager.SERVICE.getInstance(beanClass.getProject()).processFilesWithWord(new Processor<PsiFile>() {
      @Override
      public boolean process(PsiFile psiFile) {
        LowLevelSearchUtil
          .processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true, new EmptyProgressIndicator());
        return true;
      }
    }, searcher.getPattern(), UsageSearchContext.IN_FOREIGN_LANGUAGES, scope, searcher.isCaseSensitive());
  }
  final Class[] classes = PatternCompilerFactory.getFactory().getPatternClasses(type);
  if (classes.length != 0) {
    roots.add(getRootByClasses(classes, project));
  }
  return roots;
}
项目:consulo-ui-designer    文件:FormReferencesSearcher.java   
private static boolean processReferencesInUIForms(final Processor<PsiReference> processor,
        final PropertiesFile propFile,
        final GlobalSearchScope globalSearchScope,
        final LocalSearchScope filterScope)
{
    final Project project = propFile.getProject();
    GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope);
    PsiManagerImpl manager = (PsiManagerImpl) propFile.getContainingFile().getManager();
    final String baseName = propFile.getResourceBundle().getBaseName();
    manager.startBatchFilesProcessingMode();

    try
    {
        PsiFile[] files = CacheManager.getInstance(project).getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true);

        for(PsiFile file : files)
        {
            ProgressManager.checkCanceled();

            if(file.getFileType() != GuiFormFileType.INSTANCE)
            {
                continue;
            }
            if(!processReferences(processor, file, baseName, propFile.getContainingFile(), filterScope))
            {
                return false;
            }
        }
    }
    finally
    {
        manager.finishBatchFilesProcessingMode();
    }

    return true;
}
项目:consulo    文件:CodeInsightTestFixtureImpl.java   
private long collectAndCheckHighlighting(@Nonnull ExpectedHighlightingData data) {
    final Project project = getProject();
    PsiDocumentManager.getInstance(project).commitAllDocuments();

    PsiFileImpl file = (PsiFileImpl)getHostFile();
    FileElement hardRefToFileElement = file.calcTreeElement();//to load text

    //to initialize caches
    if (!DumbService.isDumb(project)) {
      CacheManager.getInstance(project).getFilesWithWord(XXX, UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true);
    }

    List<HighlightInfo> infos;
    final long start = System.currentTimeMillis();
    try {
      ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(myJavaFilesFilter, myTestRootDisposable);

//    ProfilingUtil.startCPUProfiling();
      infos = doHighlighting();
      removeDuplicatedRangesForInjected(infos);
//    ProfilingUtil.captureCPUSnapshot("testing");
    }
    finally {
      ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myTestRootDisposable);
    }
    final long elapsed = System.currentTimeMillis() - start;

    data.checkResult(infos, file.getText());
    hardRefToFileElement.hashCode(); // use it so gc won't collect it
    return elapsed;
  }
项目:consulo    文件:PsiSearchHelperImpl.java   
@Override
@Nonnull
public PsiFile[] findFilesWithPlainTextWords(@Nonnull String word) {
  return CacheManager.getInstance(myManager.getProject()).getFilesWithWord(word, UsageSearchContext.IN_PLAIN_TEXT,
                                                                                   GlobalSearchScope.projectScope(myManager.getProject()),
                                                                                   true);
}
项目:consulo    文件:PsiSearchHelperImpl.java   
@Override
public boolean processAllFilesWithWord(@Nonnull String word,
                                       @Nonnull GlobalSearchScope scope,
                                       @Nonnull Processor<PsiFile> processor,
                                       final boolean caseSensitively) {
  return CacheManager.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_CODE, scope, caseSensitively);
}
项目:consulo    文件:PsiSearchHelperImpl.java   
@Override
public boolean processAllFilesWithWordInText(@Nonnull final String word,
                                             @Nonnull final GlobalSearchScope scope,
                                             @Nonnull final Processor<PsiFile> processor,
                                             final boolean caseSensitively) {
  return CacheManager.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_PLAIN_TEXT, scope, caseSensitively);
}
项目:consulo-java    文件:DaemonAnalyzerTestCase.java   
@NotNull
protected Collection<HighlightInfo> checkHighlighting(@NotNull final ExpectedHighlightingData data)
{
    data.init();
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();

    //to load text
    ApplicationManager.getApplication().runWriteAction(new Runnable()
    {
        @Override
        public void run()
        {
            TreeUtil.clearCaches((TreeElement) myFile.getNode());
        }
    });


    //to initialize caches
    if(!DumbService.isDumb(getProject()))
    {
        CacheManager.getInstance(myProject).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
    }
    final JavaPsiFacadeEx facade = getJavaFacade();
    if(facade != null)
    {
        facade.setAssertOnFileLoadingFilter(myFileTreeAccessFilter, null); // check repository work
    }

    Collection<HighlightInfo> infos = doHighlighting();

    if(facade != null)
    {
        facade.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, null);
    }

    String text = myEditor.getDocument().getText();
    data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text);
    data.checkResult(infos, text);
    return infos;
}
项目: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()));
}