summaryrefslogtreecommitdiff
path: root/xml/xml-psi-impl/src/com/intellij/psi/impl
diff options
context:
space:
mode:
Diffstat (limited to 'xml/xml-psi-impl/src/com/intellij/psi/impl')
-rw-r--r--xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java3
-rw-r--r--xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java3
-rw-r--r--xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java89
3 files changed, 47 insertions, 48 deletions
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java
index a32b51f5fc3f..92c287e8fdbe 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java
@@ -30,6 +30,7 @@ import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.psi.xml.XmlTokenType;
import com.intellij.util.CharTable;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.xml.util.XmlUtil;
import org.jetbrains.annotations.NotNull;
/**
@@ -63,7 +64,7 @@ public class XmlAttributeValueManipulator extends AbstractElementManipulator<Xml
final int offsetInParent = elementToReplace.getStartOffsetInParent();
String textBeforeRange = text.substring(0, range.getStartOffset() - offsetInParent);
String textAfterRange = text.substring(range.getEndOffset()- offsetInParent, text.length());
- text = textBeforeRange + newContent + textAfterRange;
+ text = textBeforeRange + XmlUtil.escape(newContent) + textAfterRange;
} catch(StringIndexOutOfBoundsException e) {
LOG.error("Range: " + range + " in text: '" + element.getText() + "'", e);
throw e;
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java
index de4f9eb6cbc7..e160ba4c14db 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java
@@ -51,6 +51,9 @@ public class XmlTextManipulator extends AbstractElementManipulator<XmlText> {
else {
text.deleteChildRange(text.getFirstChild(), text.getLastChild());
}
+ //String oldText = text.getText();
+ //((PsiLanguageInjectionHost)text).updateText(
+ // oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset()));
return text;
}
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
index 1c33789dfd57..dd70733533f8 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
@@ -75,27 +75,8 @@ import java.util.*;
public class XmlTagImpl extends XmlElementImpl implements XmlTag {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.xml.XmlTagImpl");
-
- private volatile String myName = null;
- private volatile String myLocalName;
- private volatile XmlAttribute[] myAttributes = null;
- private volatile Map<String, String> myAttributeValueMap = null;
- private volatile XmlTagValue myValue = null;
- private volatile Map<String, CachedValue<XmlNSDescriptor>> myNSDescriptorsMap = null;
- private volatile String myCachedNamespace;
- private volatile long myModCount;
-
- private volatile XmlElementDescriptor myCachedDescriptor;
- private volatile long myDescriptorModCount = -1;
- private volatile long myExtResourcesModCount = -1;
-
- private volatile boolean myHasNamespaceDeclarations = false;
- private volatile BidirectionalMap<String, String> myNamespaceMap = null;
@NonNls private static final String XML_NS_PREFIX = "xml";
-
- private final int myHC = ourHC++;
private static final RecursionGuard ourGuard = RecursionManager.createGuard("xmlTag");
-
private static final Key<ParameterizedCachedValue<XmlTag[], XmlTagImpl>> SUBTAGS_KEY = Key.create("subtags");
private static final ParameterizedCachedValueProvider<XmlTag[],XmlTagImpl> CACHED_VALUE_PROVIDER =
new ParameterizedCachedValueProvider<XmlTag[], XmlTagImpl>() {
@@ -111,11 +92,20 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
.create(tags, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, tag.getContainingFile());
}
};
-
- @Override
- public final int hashCode() {
- return myHC;
- }
+ private final int myHC = ourHC++;
+ private volatile String myName = null;
+ private volatile String myLocalName;
+ private volatile XmlAttribute[] myAttributes = null;
+ private volatile Map<String, String> myAttributeValueMap = null;
+ private volatile XmlTagValue myValue = null;
+ private volatile Map<String, CachedValue<XmlNSDescriptor>> myNSDescriptorsMap = null;
+ private volatile String myCachedNamespace;
+ private volatile long myModCount;
+ private volatile XmlElementDescriptor myCachedDescriptor;
+ private volatile long myDescriptorModCount = -1;
+ private volatile long myExtResourcesModCount = -1;
+ private volatile boolean myHasNamespaceDeclarations = false;
+ private volatile BidirectionalMap<String, String> myNamespaceMap = null;
public XmlTagImpl() {
this(XmlElementType.XML_TAG);
@@ -125,6 +115,33 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
super(type);
}
+ @Nullable
+ private static XmlNSDescriptor getDtdDescriptor(@NotNull XmlFile containingFile) {
+ final XmlDocument document = containingFile.getDocument();
+ if (document == null) {
+ return null;
+ }
+ final String url = XmlUtil.getDtdUri(document);
+ if (url == null) {
+ return null;
+ }
+ return document.getDefaultNSDescriptor(url, true);
+ }
+
+ @Nullable
+ private static String getNSVersion(String ns, final XmlTagImpl xmlTag) {
+ String versionValue = xmlTag.getAttributeValue("version");
+ if (versionValue != null && xmlTag.getNamespace().equals(ns)) {
+ return versionValue;
+ }
+ return null;
+ }
+
+ @Override
+ public final int hashCode() {
+ return myHC;
+ }
+
@Override
public void clearCaches() {
myName = null;
@@ -215,19 +232,6 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
return parentTag.getNSDescriptor(namespace, strict);
}
- @Nullable
- private static XmlNSDescriptor getDtdDescriptor(@NotNull XmlFile containingFile) {
- final XmlDocument document = containingFile.getDocument();
- if (document == null) {
- return null;
- }
- final String url = XmlUtil.getDtdUri(document);
- if (url == null) {
- return null;
- }
- return document.getDefaultNSDescriptor(url, true);
- }
-
@Override
public boolean isEmpty() {
return XmlChildRole.CLOSING_TAG_START_FINDER.findChild(this) == null;
@@ -325,15 +329,6 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
return map == null ? Collections.<String, CachedValue<XmlNSDescriptor>>emptyMap() : map;
}
- @Nullable
- private static String getNSVersion(String ns, final XmlTagImpl xmlTag) {
- String versionValue = xmlTag.getAttributeValue("version");
- if (versionValue != null && xmlTag.getNamespace().equals(ns)) {
- return versionValue;
- }
- return null;
- }
-
private Map<String, CachedValue<XmlNSDescriptor>> initializeSchema(@NotNull final String namespace,
@Nullable final String version,
final String fileLocation,
@@ -921,7 +916,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
}
}
}
- return ns;
+ return XmlUtil.getSchemaLocation(this, ns);
}
protected String getRealNs(final String value) {