From b8a5429fce4c19ce5c9ed99fbd134635e8ac341f Mon Sep 17 00:00:00 2001 From: Peter Gromov Date: Thu, 27 Mar 2008 13:31:58 +0300 Subject: [PATCH] fix class name completion inside xml tag value --- .../psi/impl/source/xml/XmlTagValueImpl.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java index e17819d56a..9e7c9cb64f 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java @@ -3,6 +3,7 @@ package com.intellij.psi.impl.source.xml; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.XmlElementFactory; import com.intellij.psi.xml.*; import com.intellij.util.IncorrectOperationException; @@ -78,13 +79,23 @@ public class XmlTagValueImpl implements XmlTagValue{ public void setText(String value) { try { - if(myElements.length > 0){ - myTag.deleteChildRange(myElements[0], myElements[myElements.length - 1]); + XmlText text = null; + if (StringUtil.isNotEmpty(value)) { + final XmlText[] texts = getTextElements(); + if (texts.length == 0) { + text = (XmlText)myTag.add(XmlElementFactory.getInstance(myTag.getProject()).createDisplayText("x")); + } else { + text = texts[0]; + } + text.setValue(value); } - if(value != null && value.length() > 0) { - XmlText displayText = XmlElementFactory.getInstance(myTag.getProject()).createDisplayText("x"); - displayText = (XmlText)myTag.add(displayText); - displayText.setValue(value); + + if(myElements.length > 0){ + for (final XmlTagChild child : myElements) { + if (child != text) { + child.delete(); + } + } } } catch (IncorrectOperationException e) { -- 2.11.4.GIT