private static String getStringToReplace(
      PsiElement element,
      String newName,
      boolean nonJava,
      final RenamePsiElementProcessor theProcessor) {
    if (element instanceof PsiMetaOwner) {
      final PsiMetaOwner psiMetaOwner = (PsiMetaOwner) element;
      final PsiMetaData metaData = psiMetaOwner.getMetaData();
      if (metaData != null) {
        return metaData.getName();
      }
    }

    if (theProcessor != null) {
      String result = theProcessor.getQualifiedNameAfterRename(element, newName, nonJava);
      if (result != null) {
        return result;
      }
    }

    if (element instanceof PsiNamedElement) {
      return newName;
    } else {
      LOG.error("Unknown element type");
      return null;
    }
  }
 @Nullable
 private XmlNSDescriptor getNSDescriptorFromMetaData(
     @Nullable PsiMetaOwner metaOwner, boolean nonEmpty) {
   if (metaOwner == null) return null;
   XmlNSDescriptor descriptor = (XmlNSDescriptor) metaOwner.getMetaData();
   if (descriptor == null) return null;
   if (nonEmpty && descriptor.getRootElementsDescriptors(this).length == 0) {
     return null;
   }
   return descriptor;
 }