private static void registerListeners(PsiElement element,
                                        RefactoringElementListenerComposite result,
                                        PsiFile containingFile,
                                        @NotNull ReferenceKind referenceKind) {
    String oldName = getQualifiedName(element, referenceKind);
    for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(element.getProject())) {
      final NamedScope[] scopes = holder.getEditableScopes();
      for (int i = 0; i < scopes.length; i++) {
        final NamedScope scope = scopes[i];
        final PackageSet packageSet = scope.getValue();
        if (packageSet != null && (containingFile == null || packageSet.contains(containingFile, holder))) {
          registerListeners(packageSet, result, new OldScopeDescriptor(scope, i, holder), oldName, referenceKind);
        }
      }
    }
  }
private static void registerListeners(PsiElement element,
                                        RefactoringElementListenerComposite result,
                                        PsiFile containingFile,
                                        @NotNull ReferenceKind referenceKind)