Java 类com.intellij.psi.search.UsageSearchContext 实例源码

项目:AppleScript-IDEA    文件:AppleScriptDictionaryComponentReferencesSearch.java   
private Boolean doExecute(ReferencesSearch.SearchParameters queryParameters, final Processor<PsiReference> consumer) {
  final PsiElement element = queryParameters.getElementToSearch(); //was selector_identifier->redefined in
  DictionaryComponent dictionaryComponent = null;
  if (element instanceof DictionaryComponent) {
    dictionaryComponent = (DictionaryComponent) element;
  }

  if (dictionaryComponent == null) return true;

  final List<String> parts = dictionaryComponent.getNameIdentifiers();
  if (parts.isEmpty())
    return true;
  final String componentName = dictionaryComponent.getName(); //or just getName()...
  final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(element.getProject());

  String searchWord = parts.get(0);
  return searchWord.isEmpty() || helper.processElementsWithWord(new MyOccurrenceProcessor(dictionaryComponent, componentName, consumer), 
      queryParameters.getScopeDeterminedByUser(), searchWord, UsageSearchContext.IN_CODE, true);

}
项目:intellij-ce-playground    文件:JavaFilterLexer.java   
@Override
public void advance() {
  final IElementType tokenType = myDelegate.getTokenType();

  if (tokenType == JavaTokenType.IDENTIFIER
      || tokenType == JavaTokenType.LONG_LITERAL
      || tokenType == JavaTokenType.INTEGER_LITERAL
      || tokenType == JavaTokenType.CHARACTER_LITERAL 
      || tokenType == JavaTokenType.ARROW 
      || tokenType == JavaTokenType.DOUBLE_COLON) {
    addOccurrenceInToken(UsageSearchContext.IN_CODE);
  }
  else if (tokenType == JavaTokenType.STRING_LITERAL) {
    scanWordsInToken(UsageSearchContext.IN_STRINGS | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, true);
  }
  else if (ElementType.JAVA_COMMENT_BIT_SET.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
    advanceTodoItemCountsInToken();
  }
  else if (!ourSkipWordsScanSet.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  myDelegate.advance();
}
项目: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    文件:PlainTextIndexer.java   
@Override
@NotNull
public Map<IdIndexEntry, Integer> map(@NotNull final FileContent inputData) {
  final IdDataConsumer consumer = new IdDataConsumer();
  final CharSequence chars = inputData.getContentAsText();
  IdTableBuilding.scanWords(new IdTableBuilding.ScanWordProcessor() {
    @Override
    public void run(final CharSequence chars11, @Nullable char[] charsArray, final int start, final int end) {
      if (charsArray != null) {
        consumer.addOccurrence(charsArray, start, end, (int)UsageSearchContext.IN_PLAIN_TEXT);
      }
      else {
        consumer.addOccurrence(chars11, start, end, (int)UsageSearchContext.IN_PLAIN_TEXT);
      }
    }
  }, chars, 0, chars.length());
  return consumer.getResult();
}
项目:intellij-ce-playground    文件:PyStringReferenceSearch.java   
public void processQuery(@NotNull final ReferencesSearch.SearchParameters params,
                         @NotNull final Processor<PsiReference> consumer) {
  final PsiElement element = params.getElementToSearch();
  if (!(element instanceof PyElement) && !(element instanceof PsiDirectory)) {
    return;
  }

  SearchScope searchScope = params.getEffectiveSearchScope();
  if (searchScope instanceof GlobalSearchScope) {
    searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)searchScope, PythonFileType.INSTANCE);
  }

  String name = PyUtil.computeElementNameForStringSearch(element);

  if (StringUtil.isEmpty(name)) {
    return;
  }
  params.getOptimizer().searchWord(name, searchScope, UsageSearchContext.IN_STRINGS, true, element);
}
项目:intellij-ce-playground    文件:PropertiesFilterLexer.java   
public void advance() {
  final IElementType tokenType = getDelegate().getTokenType();

  if (tokenType == PropertiesTokenTypes.KEY_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }
  else if (PropertiesTokenTypes.COMMENTS.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS | UsageSearchContext.IN_PLAIN_TEXT, false, false);
    advanceTodoItemCountsInToken();
  }
  else {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  getDelegate().advance();
}
项目:intellij-ce-playground    文件:GrLiteralMethodSearcher.java   
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
  final PsiMethod method = p.getMethod();
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) return;

  final String name = method.getName();
  if (StringUtil.isEmpty(name)) return;

  final boolean strictSignatureSearch = p.isStrictSignatureSearch();
  final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[]{method} : aClass.findMethodsByName(name, false);

  SearchScope accessScope = GroovyScopeUtil.getEffectiveScope(methods);
  final SearchScope restrictedByAccess = GroovyScopeUtil.restrictScopeToGroovyFiles(p.getEffectiveSearchScope(), accessScope);

  final String textToSearch = findLongestWord(name);

  p.getOptimizer().searchWord(textToSearch, restrictedByAccess, UsageSearchContext.IN_STRINGS, true, method,
                              new MethodTextOccurrenceProcessor(aClass, strictSignatureSearch, methods));
}
项目:intellij-ce-playground    文件:AccessorReferencesSearcher.java   
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
  final PsiElement element = queryParameters.getElementToSearch();
  if (element instanceof PsiMethod) {
    final String propertyName = GroovyPropertyUtils.getPropertyName((PsiMethod)element);
    if (propertyName == null) return;

    queryParameters.getOptimizer().searchWord(propertyName, GroovyScopeUtil
      .restrictScopeToGroovyFiles(queryParameters.getEffectiveSearchScope()),
                                              UsageSearchContext.IN_CODE, true, element);
  }
  else if (element instanceof GrField) {
    for (GrAccessorMethod method : ((GrField)element).getGetters()) {
      MethodReferencesSearch.search(method, queryParameters.getEffectiveSearchScope(), true).forEach(consumer);
    }

    final GrAccessorMethod setter = ((GrField)element).getSetter();
    if (setter != null) {
      MethodReferencesSearch.search(setter, queryParameters.getEffectiveSearchScope(), true).forEach(consumer);
    }
  }
}
项目:intellij-ce-playground    文件:AccessorMethodReferencesSearcher.java   
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
  final PsiMethod method = queryParameters.getMethod();

  final String propertyName;
  if (GdkMethodUtil.isCategoryMethod(method, null, null, PsiSubstitutor.EMPTY)) {
    final GrGdkMethod cat = GrGdkMethodImpl.createGdkMethod(method, false, null);
    propertyName = GroovyPropertyUtils.getPropertyName((PsiMethod)cat);
  }
  else {
    propertyName = GroovyPropertyUtils.getPropertyName(method);
  }

  if (propertyName == null) return;

  final SearchScope onlyGroovyFiles = GroovyScopeUtil.restrictScopeToGroovyFiles(queryParameters.getEffectiveSearchScope(), GroovyScopeUtil.getEffectiveScope(method));

  queryParameters.getOptimizer().searchWord(propertyName, onlyGroovyFiles, UsageSearchContext.IN_CODE, true, method);

  if (!GroovyPropertyUtils.isPropertyName(propertyName)) {
    queryParameters.getOptimizer().searchWord(StringUtil.decapitalize(propertyName), onlyGroovyFiles, UsageSearchContext.IN_CODE, true, method);
  }
}
项目:intellij-ce-playground    文件:GroovyFilterLexer.java   
@Override
public void advance() {
  final IElementType tokenType = getDelegate().getTokenType();

  if (tokenType == GroovyTokenTypes.mIDENT || TokenSets.KEYWORDS.contains(tokenType)) {
    addOccurrenceInToken(UsageSearchContext.IN_CODE);
  }
  else if (TokenSets.STRING_LITERALS.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_STRINGS | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, true);
  }
  else if (TokenSets.COMMENT_SET.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
    advanceTodoItemCountsInToken();
  }
  else {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  getDelegate().advance();
}
项目:intellij    文件:GlobalWordIndexTest.java   
@Test
public void testWordsInStrings() {
  VirtualFile file =
      workspace.createFile(
          new WorkspacePath("java/com/google/BUILD"),
          "name = \"long name with spaces\",",
          "src = [\"name_without_spaces\"]");
  assertContainsWords(
      file,
      UsageSearchContext.IN_STRINGS,
      "long",
      "name",
      "with",
      "spaces",
      "name_without_spaces");
}
项目: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));
    }
  }
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLPsiSearchHelper.java   
/**
 * Finds all fragment definition across files in the project
 *
 * @return a list of known fragment definitions, or an empty list if the index is not yet ready
 */
public List<JSGraphQLFragmentDefinitionPsiElement> getKnownFragmentDefinitions() {
    try {
        final List<JSGraphQLFragmentDefinitionPsiElement> fragmentDefinitions = Lists.newArrayList();
        PsiSearchHelper.SERVICE.getInstance(myProject).processElementsWithWord((psiElement, offsetInElement) -> {
            if (psiElement.getNode().getElementType() == JSGraphQLTokenTypes.KEYWORD && psiElement.getParent() instanceof JSGraphQLFragmentDefinitionPsiElement) {
                final JSGraphQLFragmentDefinitionPsiElement fragmentDefinition = (JSGraphQLFragmentDefinitionPsiElement) psiElement.getParent();
                final String fragmentName = fragmentDefinition.getName();
                if (fragmentName != null) {
                    fragmentDefinitions.add(fragmentDefinition);
                }
            }
            return true;
        }, searchScope, "fragment", UsageSearchContext.IN_CODE, true, true);
        return fragmentDefinitions;
    } catch (IndexNotReadyException e) {
        // can't search yet (e.g. during project startup)
    }
    return Collections.emptyList();
}
项目:tools-idea    文件:JavaFilterLexer.java   
@Override
public void advance() {
  final IElementType tokenType = myDelegate.getTokenType();

  if (tokenType == JavaTokenType.IDENTIFIER
      || tokenType == JavaTokenType.LONG_LITERAL
      || tokenType == JavaTokenType.INTEGER_LITERAL
      || tokenType == JavaTokenType.CHARACTER_LITERAL) {
    addOccurrenceInToken(UsageSearchContext.IN_CODE);
  }
  else if (tokenType == JavaTokenType.STRING_LITERAL) {
    scanWordsInToken(UsageSearchContext.IN_STRINGS | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, true);
  }
  else if (ElementType.JAVA_COMMENT_BIT_SET.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
    advanceTodoItemCountsInToken();
  }
  else if (!ourSkipWordsScanSet.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  myDelegate.advance();
}
项目: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    文件:IdTableBuilding.java   
@Override
@NotNull
public Map<IdIndexEntry, Integer> map(final FileContent inputData) {
  final IdDataConsumer consumer = new IdDataConsumer();
  final CharSequence chars = inputData.getContentAsText();
  scanWords(new ScanWordProcessor() {
    @Override
    public void run(final CharSequence chars11, @Nullable char[] charsArray, final int start, final int end) {
      if (charsArray != null) {
        consumer.addOccurrence(charsArray, start, end, (int)UsageSearchContext.IN_PLAIN_TEXT);
      } else {
        consumer.addOccurrence(chars11, start, end, (int)UsageSearchContext.IN_PLAIN_TEXT);
      }
    }
  }, chars, 0, chars.length());
  return consumer.getResult();
}
项目:tools-idea    文件:DataProviderSearcher.java   
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
  final PsiMethod method = queryParameters.getMethod();

  final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, DataProvider.class.getName());
  if (annotation == null) return;
  PsiNameValuePair[] values = annotation.getParameterList().getAttributes();
  for (PsiNameValuePair value : values) {
    if ("name".equals(value.getName())) {
      final PsiAnnotationMemberValue dataProviderMethodName = value.getValue();
      if (dataProviderMethodName != null) {
        final String providerName = StringUtil.unquoteString(dataProviderMethodName.getText());
        queryParameters.getOptimizer().searchWord(providerName, queryParameters.getScope(), UsageSearchContext.IN_STRINGS, true, method);
      }
    }
  }
}
项目:tools-idea    文件:PropertiesFilterLexer.java   
public void advance() {
  final IElementType tokenType = getDelegate().getTokenType();

  if (tokenType == PropertiesTokenTypes.KEY_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }
  else if (PropertiesTokenTypes.COMMENTS.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS | UsageSearchContext.IN_PLAIN_TEXT, false, false);
    advanceTodoItemCountsInToken();
  }
  else {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  getDelegate().advance();
}
项目:tools-idea    文件:GrLiteralMethodSearcher.java   
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
  final PsiMethod method = p.getMethod();
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) return;

  final String name = method.getName();
  if (StringUtil.isEmpty(name)) return;

  final boolean strictSignatureSearch = p.isStrictSignatureSearch();
  final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[]{method} : aClass.findMethodsByName(name, false);

  SearchScope accessScope = GroovyScopeUtil.getEffectiveScope(methods);
  final SearchScope restrictedByAccess = GroovyScopeUtil.restrictScopeToGroovyFiles(p.getScope(), accessScope);

  final String textToSearch = findLongestWord(name);

  p.getOptimizer().searchWord(textToSearch, restrictedByAccess, UsageSearchContext.IN_STRINGS, true,
                              new MethodTextOccurrenceProcessor(aClass, strictSignatureSearch, methods));
}
项目:tools-idea    文件:AccessorReferencesSearcher.java   
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
  final PsiElement element = queryParameters.getElementToSearch();
  if (element instanceof PsiMethod) {
    final String propertyName = GroovyPropertyUtils.getPropertyName((PsiMethod)element);
    if (propertyName == null) return;

    queryParameters.getOptimizer().searchWord(propertyName, GroovyScopeUtil
      .restrictScopeToGroovyFiles(queryParameters.getEffectiveSearchScope()),
                                              UsageSearchContext.IN_CODE, true, element);
  }
  else if (element instanceof GrField) {
    for (GrAccessorMethod method : ((GrField)element).getGetters()) {
      MethodReferencesSearch.search(method, queryParameters.getEffectiveSearchScope(), true).forEach(consumer);
    }

    final GrAccessorMethod setter = ((GrField)element).getSetter();
    if (setter != null) {
      MethodReferencesSearch.search(setter, queryParameters.getEffectiveSearchScope(), true).forEach(consumer);
    }
  }
}
项目:tools-idea    文件:AccessorMethodReferencesSearcher.java   
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
  final PsiMethod method = queryParameters.getMethod();

  final String propertyName;
  if (GdkMethodUtil.isCategoryMethod(method, null, null, PsiSubstitutor.EMPTY)) {
    final GrGdkMethod cat = GrGdkMethodImpl.createGdkMethod(method, false, null);
    propertyName = GroovyPropertyUtils.getPropertyName((PsiMethod)cat);
  }
  else {
    propertyName = GroovyPropertyUtils.getPropertyName(method);
  }

  if (propertyName == null) return;

  final SearchScope onlyGroovyFiles = GroovyScopeUtil.restrictScopeToGroovyFiles(queryParameters.getScope(), GroovyScopeUtil.getEffectiveScope(method));

  queryParameters.getOptimizer().searchWord(propertyName, onlyGroovyFiles, UsageSearchContext.IN_CODE, true, method);

  if (!GroovyPropertyUtils.isPropertyName(propertyName)) {
    queryParameters.getOptimizer().searchWord(StringUtil.decapitalize(propertyName), onlyGroovyFiles, UsageSearchContext.IN_CODE, true, method);
  }
}
项目:consulo    文件:PlainTextIndexer.java   
@Override
@Nonnull
public Map<IdIndexEntry, Integer> map(@Nonnull final FileContent inputData) {
  final IdDataConsumer consumer = new IdDataConsumer();
  final CharSequence chars = inputData.getContentAsText();
  IdTableBuilding.scanWords(new IdTableBuilding.ScanWordProcessor() {
    @Override
    public void run(final CharSequence chars11, @Nullable char[] charsArray, final int start, final int end) {
      if (charsArray != null) {
        consumer.addOccurrence(charsArray, start, end, (int)UsageSearchContext.IN_PLAIN_TEXT);
      }
      else {
        consumer.addOccurrence(chars11, start, end, (int)UsageSearchContext.IN_PLAIN_TEXT);
      }
    }
  }, chars, 0, chars.length());
  return consumer.getResult();
}
项目:consulo-java    文件:JavaFilterLexer.java   
@Override
public void advance()
{
    final IElementType tokenType = myDelegate.getTokenType();

    if(tokenType == JavaTokenType.IDENTIFIER || tokenType == JavaTokenType.LONG_LITERAL || tokenType == JavaTokenType.INTEGER_LITERAL || tokenType == JavaTokenType.CHARACTER_LITERAL || tokenType
            == JavaTokenType.ARROW || tokenType == JavaTokenType.DOUBLE_COLON)
    {
        addOccurrenceInToken(UsageSearchContext.IN_CODE);
    }
    else if(tokenType == JavaTokenType.STRING_LITERAL)
    {
        scanWordsInToken(UsageSearchContext.IN_STRINGS | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, true);
    }
    else if(ElementType.JAVA_COMMENT_BIT_SET.contains(tokenType))
    {
        scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
        advanceTodoItemCountsInToken();
    }
    else if(!ourSkipWordsScanSet.contains(tokenType))
    {
        scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
    }

    myDelegate.advance();
}
项目: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    文件:SimpleAccessorReferenceSearcher.java   
static void addPropertyAccessUsages(PsiMethod method, SearchScope scope, SearchRequestCollector collector) {
  final String propertyName = PropertyUtil.getPropertyName(method);
  if (StringUtil.isNotEmpty(propertyName)) {
    SearchScope additional = GlobalSearchScope.EMPTY_SCOPE;
    for (CustomPropertyScopeProvider provider : Extensions.getExtensions(CustomPropertyScopeProvider.EP_NAME)) {
      additional = additional.union(provider.getScope(method.getProject()));
    }
    final SearchScope propScope = scope.intersectWith(method.getUseScope()).intersectWith(additional);
    collector.searchWord(propertyName, propScope, UsageSearchContext.IN_FOREIGN_LANGUAGES, true, method);
  }
}
项目: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    文件:BaseFilterLexer.java   
private void processPossibleComplexFileName(CharSequence chars, char[] cachedArraySequence, int startOffset, int endOffset) {
  int offset = findCharsWithinRange(chars, startOffset, endOffset, "/\\");
  offset = Math.min(offset, endOffset);
  int start = startOffset;

  while(start < endOffset) {
    if (start != offset) {
      myOccurrenceConsumer.addOccurrence(chars, cachedArraySequence, start, offset, UsageSearchContext.IN_FOREIGN_LANGUAGES);
    }
    start = offset + 1;
    offset = Math.min(endOffset, findCharsWithinRange(chars, start, endOffset, "/\\"));
  }
}