IDEADEV-41816 DOM doesn't handle XML &EntityRefs; right

This commit is contained in:
Gregory Shrago
2009-12-03 18:50:44 +03:00
parent 914b23b1ec
commit 0434983f0f
3 changed files with 18 additions and 2 deletions
@@ -19,7 +19,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.patterns.ElementPattern;
import static com.intellij.patterns.XmlPatterns.*;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlDocument;
@@ -43,6 +42,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Set;
import static com.intellij.patterns.XmlPatterns.*;
/**
* @author peter
*/
@@ -80,7 +81,7 @@ public class DomSemContributor extends SemContributor {
}
});
final ElementPattern<XmlTag> nonRootTag = xmlTag().withParent(xmlTag());
final ElementPattern<XmlTag> nonRootTag = xmlTag().withParent(or(xmlTag(), xmlEntityRef().withParent(xmlTag())));
registrar.registerSemElementProvider(DomManagerImpl.DOM_INDEXED_HANDLER_KEY, nonRootTag, new NullableFunction<XmlTag, IndexedElementInvocationHandler>() {
public IndexedElementInvocationHandler fun(XmlTag tag) {
final XmlTag parentTag = PhysicalDomParentStrategy.getParentTag(tag);
@@ -16,6 +16,7 @@
package com.intellij.patterns;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlEntityRef;
import com.intellij.psi.xml.XmlText;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
@@ -53,4 +54,14 @@ public class XmlElementPattern<T extends XmlElement,Self extends XmlElementPatte
}
}
public static class XmlEntityRefPattern extends XmlElementPattern<XmlEntityRef, XmlEntityRefPattern> {
public XmlEntityRefPattern() {
super(new InitialPatternCondition<XmlEntityRef>(XmlEntityRef.class) {
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
return o instanceof XmlEntityRef;
}
});
}
}
}
@@ -49,4 +49,8 @@ public class XmlPatterns extends PlatformPatterns {
public static XmlElementPattern.XmlTextPattern xmlText() {
return new XmlElementPattern.XmlTextPattern();
}
public static XmlElementPattern.XmlEntityRefPattern xmlEntityRef() {
return new XmlElementPattern.XmlEntityRefPattern();
}
}