@Override
  public void processQuery(
      @NotNull final MethodReferencesSearch.SearchParameters p,
      @NotNull final Processor<PsiReference> consumer) {
    SearchScope scope = p.getEffectiveSearchScope();
    if (!(scope instanceof GlobalSearchScope)) {
      return;
    }

    final PsiMethod method = p.getMethod();

    final PsiAnnotation stepAnnotation = CucumberJavaUtil.getCucumberStepAnnotation(method);
    final String regexp =
        stepAnnotation != null
            ? CucumberJavaUtil.getPatternFromStepDefinition(stepAnnotation)
            : null;
    if (regexp == null) {
      return;
    }
    final String word = CucumberUtil.getTheBiggestWordToSearchByIndex(regexp);
    if (StringUtil.isEmpty(word)) {
      return;
    }

    final GlobalSearchScope restrictedScope =
        GlobalSearchScope.getScopeRestrictedByFileTypes(
            (GlobalSearchScope) scope, GherkinFileType.INSTANCE);
    ReferencesSearch.search(
            new ReferencesSearch.SearchParameters(method, restrictedScope, false, p.getOptimizer()))
        .forEach(consumer);
  }
  public static boolean isAnnoRefAnywhereInXml(
      @NotNull Project project, @NotNull Module module, @NotNull String refId) {
    if (module == null) {
      throw new IllegalArgumentException(
          String.format(
              "Argument %s for @NotNull parameter of %s.%s must not be null",
              new Object[] {
                "0",
                "com.idi.intellij.plugin.query.sqlref.util.AnnoRefModelUtil",
                "isAnnoRefAnywhereInXml"
              }));
    }
    GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
    GlobalSearchScope searchScope =
        GlobalSearchScope.getScopeRestrictedByFileTypes(scope, XmlFileType.INSTANCE);
    PsiFile[] files =
        CacheManager.SERVICE
            .getInstance(module.getProject())
            .getFilesWithWord(refId, Short.valueOf("255"), searchScope, true);

    for (PsiFile file : files) {
      if (((file instanceof XmlFile))
          && (AnnRefApplication.getInstance(project, SQLRefDataAccessor.class)
              .isPropitiousXmlFile(file))) {
        return true;
      }
    }
    return false;
  }
 public boolean execute(
     ReferencesSearch.SearchParameters params, final Processor<PsiReference> consumer) {
   final PsiElement elem = params.getElementToSearch();
   SearchScope scope = params.getEffectiveSearchScope();
   if (elem instanceof PsiNamedElement
       /* An optimization for Java refactorings */
       && !(elem instanceof PsiVariable)) {
     final PsiNamedElement symbolToSearch = (PsiNamedElement) elem;
     final String name = symbolToSearch.getName();
     if (name != null) {
       RequestResultProcessor processor =
           new RequestResultProcessor() {
             @Override
             public boolean processTextOccurrence(
                 @NotNull PsiElement element,
                 int offsetInElement,
                 @NotNull Processor<PsiReference> consumer) {
               if (element instanceof ClSymbol) {
                 ClSymbol refSymbol = (ClSymbol) element;
                 for (PsiReference ref : refSymbol.getReferences()) {
                   if (ref.getRangeInElement().contains(offsetInElement)
                       &&
                       // atom may refer to definition or to the symbol in it
                       (ref.resolve() == symbolToSearch
                           || ref.resolve() == symbolToSearch.getParent())) {
                     if (!consumer.process(ref)) return false;
                   }
                 }
               }
               return true;
             }
           };
       if (scope instanceof GlobalSearchScope) {
         scope =
             GlobalSearchScope.getScopeRestrictedByFileTypes(
                 (GlobalSearchScope) scope, ClojureFileType.CLOJURE_FILE_TYPE);
       }
       for (String word : StringUtil.getWordsIn(name)) {
         params.getOptimizer().searchWord(word, scope, UsageSearchContext.ANY, true, processor);
       }
     }
   }
   return true;
 }
 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);
 }
 private static SearchScope createProjectXmlFilesScope(PsiElement element) {
   return GlobalSearchScope.getScopeRestrictedByFileTypes(
       GlobalSearchScope.allScope(element.getProject()), XmlFileType.INSTANCE);
 }
 @NotNull
 private static SearchScope getResolveSearchScope(@NotNull PsiFile file) {
   return GlobalSearchScope.getScopeRestrictedByFileTypes(
       GlobalSearchScope.projectScope(file.getProject()), file.getFileType());
 }