private void setText(String value, boolean defaultPolicy) { try { XmlText text = null; if (value != null) { final XmlText[] texts = getTextElements(); if (texts.length == 0) { text = (XmlText)myTag.add(XmlElementFactory.getInstance(myTag.getProject()).createDisplayText("x")); } else { text = texts[0]; } if (StringUtil.isEmpty(value)) { text.delete(); } else { if (defaultPolicy && text instanceof XmlTextImpl) { ((XmlTextImpl)text).doSetValue(value, new DefaultXmlPsiPolicy()); } else { text.setValue(value); } } } if(myElements.length > 0){ for (final XmlTagChild child : myElements) { if (child != text) { child.delete(); } } } } catch (IncorrectOperationException e) { LOG.error(e); } }
@Override public PsiLanguageInjectionHost updateText(@NotNull final String text) { try { doSetValue(text, new DefaultXmlPsiPolicy()); } catch (IncorrectOperationException e) { LOG.error(e); } return this; }
public PsiLanguageInjectionHost updateText(@NotNull final String text) { try { doSetValue(text, new DefaultXmlPsiPolicy()); } catch (IncorrectOperationException e) { LOG.error(e); } return this; }
@Override public PsiLanguageInjectionHost updateText(@NotNull final String text) { try { doSetValue(text, new DefaultXmlPsiPolicy()); } catch(IncorrectOperationException e) { LOG.error(e); } return this; }