private Integer calculateOccurrenceCount(@NotNull PsiElement element, boolean isConstructorSuggestion) {
    LanguageCompilerRefAdapter adapter = null;
    if (isConstructorSuggestion) {
      adapter = ReadAction.compute(() -> LanguageCompilerRefAdapter.findAdapter(element));
      if (adapter == null || !adapter.isClass(element)) {
        return null;
      }
    }

    CompilerElementInfo searchElementInfo = asCompilerElements(element, false, false);
    if (searchElementInfo == null) {
      return null;
    }

    if (!myReadDataLock.tryLock()) {
      return null;
    }

    try {
      if (myReader == null) return null;
      try {
        if (isConstructorSuggestion) {
          int constructorOccurrences = 0;
          for (PsiElement constructor : adapter.getInstantiableConstructors(element)) {
            final CompilerRef constructorRef = adapter.asCompilerRef(constructor, myReader.getNameEnumerator());
            if (constructorRef != null) {
              constructorOccurrences += myReader.getOccurrenceCount(constructorRef);
            }
          }
          final Integer anonymousCount = myReader.getAnonymousCount(
            (CompilerRef.CompilerClassHierarchyElementDef)searchElementInfo.searchElements.get(0),
            searchElementInfo.place == ElementPlace.SRC
          );
          return anonymousCount == null ? constructorOccurrences : (constructorOccurrences + anonymousCount);
        } else {
          return myReader.getOccurrenceCount(searchElementInfo.searchElements.get(0));
        }
      }
      catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    finally {
      myReadDataLock.unlock();
    }
  }
private Integer calculateOccurrenceCount(@NotNull PsiElement element, boolean isConstructorSuggestion)