private void searchWord(@NotNull String word,
                          @NotNull SearchScope searchScope,
                          short searchContext,
                          boolean caseSensitive,
                          String containerName,
                          PsiElement searchTarget,
                          @NotNull RequestResultProcessor processor) {
    if (!makesSenseToSearch(word, searchScope)) return;

    if (searchTarget != null &&
        searchScope instanceof GlobalSearchScope &&
        ((searchContext & UsageSearchContext.IN_CODE) != 0 || searchContext == UsageSearchContext.ANY)) {

      SearchScope restrictedCodeUsageSearchScope = ReadAction.compute(() -> {
        return ScopeOptimizer.calculateOverallRestrictedUseScope(PsiSearchHelper.CODE_USAGE_SCOPE_OPTIMIZER_EP_NAME.getExtensionList(),
                                                                 searchTarget);
      });
      if (restrictedCodeUsageSearchScope != null) {
        short exceptCodeSearchContext = searchContext == UsageSearchContext.ANY
                                        ? UsageSearchContext.IN_COMMENTS |
                                          UsageSearchContext.IN_STRINGS |
                                          UsageSearchContext.IN_FOREIGN_LANGUAGES |
                                          UsageSearchContext.IN_PLAIN_TEXT
                                        : (short)(searchContext ^ UsageSearchContext.IN_CODE);
        SearchScope searchCodeUsageEffectiveScope = searchScope.intersectWith(restrictedCodeUsageSearchScope);

        PsiSearchRequest inCode =
          new PsiSearchRequest(searchCodeUsageEffectiveScope, word, UsageSearchContext.IN_CODE, caseSensitive, containerName,
                               getSearchSession(), processor);
        PsiSearchRequest outsideCode =
          new PsiSearchRequest(searchScope, word, exceptCodeSearchContext, caseSensitive, containerName, getSearchSession(), processor);
        synchronized (lock) {
          myWordRequests.add(inCode);
          myWordRequests.add(outsideCode);
        }
        return;
      }
    }
    PsiSearchRequest request = new PsiSearchRequest(searchScope, word, searchContext, caseSensitive, containerName, getSearchSession(), processor);
    synchronized (lock) {
      myWordRequests.add(request);
    }
  }
private void searchWord(@NotNull String word,
                          @NotNull SearchScope searchScope,
                          short searchContext,
                          boolean caseSensitive,
                          String containerName,
                          PsiElement searchTarget,
                          @NotNull RequestResultProcessor processor)