示例#1
0
 private ASTNode expandTag() throws IncorrectOperationException {
   ASTNode endTagStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(this);
   if (endTagStart == null) {
     final XmlTagImpl tagFromText =
         (XmlTagImpl)
             XmlElementFactory.getInstance(getProject())
                 .createTagFromText("<" + getName() + "></" + getName() + ">");
     final ASTNode startTagStart = XmlChildRole.START_TAG_END_FINDER.findChild(tagFromText);
     endTagStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(tagFromText);
     final LeafElement emptyTagEnd =
         (LeafElement) XmlChildRole.EMPTY_TAG_END_FINDER.findChild(this);
     if (emptyTagEnd != null) removeChild(emptyTagEnd);
     addChildren(startTagStart, null, null);
   }
   return endTagStart;
 }
示例#2
0
  public XmlAttribute setAttribute(String qname, String value) throws IncorrectOperationException {
    final XmlAttribute attribute = getAttribute(qname);

    if (attribute != null) {
      if (value == null) {
        deleteChildInternal(attribute.getNode());
        return null;
      }
      attribute.setValue(value);
      return attribute;
    } else if (value == null) {
      return null;
    } else {
      PsiElement xmlAttribute =
          add(XmlElementFactory.getInstance(getProject()).createXmlAttribute(qname, value));
      while (!(xmlAttribute instanceof XmlAttribute)) xmlAttribute = xmlAttribute.getNextSibling();
      return (XmlAttribute) xmlAttribute;
    }
  }