protected void setValue(@Nullable final String value) {
    final XmlTag tag = ensureTagExists();
    final String attributeName = getXmlElementName();
    final String namespace = getXmlApiCompatibleNamespace(getParentHandler());
    final String oldValue = StringUtil.unescapeXml(tag.getAttributeValue(attributeName, namespace));
    final String newValue = XmlStringUtil.escapeString(value);
    if (Comparing.equal(oldValue, newValue, true)) return;

    getManager()
        .runChange(
            new Runnable() {
              public void run() {
                try {
                  XmlAttribute attribute = tag.setAttribute(attributeName, namespace, newValue);
                  setXmlElement(attribute);
                  getManager()
                      .cacheHandler(
                          DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY,
                          attribute,
                          AttributeChildInvocationHandler.this);
                } catch (IncorrectOperationException e) {
                  LOG.error(e);
                }
              }
            });
    final DomElement proxy = getProxy();
    final DomElement element = proxy;
    getManager()
        .fireEvent(oldValue != null ? new DomEvent(proxy, false) : new DomEvent(element, true));
  }
 public ProjectConfigurationProblem(
     ProjectStructureProblemDescription description, Project project) {
   super(
       StringUtil.unescapeXml(description.getMessage(true)),
       computeDescription(description),
       getSettings(project, description.getProblemLevel()).isIgnored(description));
   myDescription = description;
   myProject = project;
 }
  private static String encodeTooltip(String toolTip, String description) {
    if (toolTip == null || description == null) return toolTip;
    String unescaped = StringUtil.unescapeXml(XmlStringUtil.stripHtml(toolTip));

    String encoded =
        description.isEmpty()
            ? unescaped
            : StringUtil.replace(unescaped, description, DESCRIPTION_PLACEHOLDER);
    //noinspection StringEquality
    if (encoded == unescaped) {
      return toolTip;
    }
    if (encoded.equals(DESCRIPTION_PLACEHOLDER)) encoded = DESCRIPTION_PLACEHOLDER;
    return encoded;
  }
 private void annotateExternally(
     @NotNull PsiModifierListOwner listOwner,
     @NotNull String annotationFQName,
     @Nullable final XmlFile xmlFile,
     @NotNull PsiFile codeUsageFile,
     PsiNameValuePair[] values) {
   if (xmlFile == null) return;
   try {
     final XmlDocument document = xmlFile.getDocument();
     if (document != null) {
       final XmlTag rootTag = document.getRootTag();
       final String externalName = getExternalName(listOwner, false);
       if (rootTag != null) {
         for (XmlTag tag : rootTag.getSubTags()) {
           if (Comparing.strEqual(
               StringUtil.unescapeXml(tag.getAttributeValue("name")), externalName)) {
             for (XmlTag annTag : tag.getSubTags()) {
               if (Comparing.strEqual(annTag.getAttributeValue("name"), annotationFQName)) {
                 annTag.delete();
                 break;
               }
             }
             tag.add(
                 XmlElementFactory.getInstance(myPsiManager.getProject())
                     .createTagFromText(createAnnotationTag(annotationFQName, values)));
             return;
           }
         }
         @NonNls String text = "<item name=\'" + StringUtil.escapeXml(externalName) + "\'>\n";
         text += createAnnotationTag(annotationFQName, values);
         text += "</item>";
         rootTag.add(
             XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(text));
       }
     }
   } catch (IncorrectOperationException e) {
     LOG.error(e);
   } finally {
     dropCache();
     if (codeUsageFile.getVirtualFile().isInLocalFileSystem()) {
       UndoUtil.markPsiFileForUndo(codeUsageFile);
     }
   }
 }
 private boolean processExistingExternalAnnotations(
     @NotNull final PsiModifierListOwner listOwner,
     @NotNull final String annotationFQN,
     @NotNull final Processor<XmlTag> annotationTagProcessor) {
   try {
     final List<XmlFile> files = findExternalAnnotationsXmlFiles(listOwner);
     if (files == null) {
       notifyAfterAnnotationChanging(listOwner, annotationFQN, false);
       return false;
     }
     boolean processedAnything = false;
     for (final XmlFile file : files) {
       if (!file.isValid()) {
         continue;
       }
       if (ReadonlyStatusHandler.getInstance(myPsiManager.getProject())
           .ensureFilesWritable(file.getVirtualFile())
           .hasReadonlyFiles()) {
         continue;
       }
       final XmlDocument document = file.getDocument();
       if (document == null) {
         continue;
       }
       final XmlTag rootTag = document.getRootTag();
       if (rootTag == null) {
         continue;
       }
       final String externalName = getExternalName(listOwner, false);
       final String oldExternalName = getNormalizedExternalName(listOwner);
       for (final XmlTag tag : rootTag.getSubTags()) {
         final String className = StringUtil.unescapeXml(tag.getAttributeValue("name"));
         if (!Comparing.strEqual(className, externalName)
             && !Comparing.strEqual(className, oldExternalName)) {
           continue;
         }
         for (final XmlTag annotationTag : tag.getSubTags()) {
           if (!Comparing.strEqual(annotationTag.getAttributeValue("name"), annotationFQN)) {
             continue;
           }
           CommandProcessor.getInstance()
               .executeCommand(
                   myPsiManager.getProject(),
                   new Runnable() {
                     @Override
                     public void run() {
                       try {
                         annotationTagProcessor.process(annotationTag);
                         commitChanges(file);
                       } catch (IncorrectOperationException e) {
                         LOG.error(e);
                       }
                     }
                   },
                   ExternalAnnotationsManagerImpl.class.getName(),
                   null);
           processedAnything = true;
         }
       }
     }
     notifyAfterAnnotationChanging(listOwner, annotationFQN, processedAnything);
     return processedAnything;
   } finally {
     dropCache();
   }
 }
 public String unescapeText(String originalText) {
   return StringUtil.unescapeXml(originalText);
 }